Shop OBEX P1 Docs P2 Docs Learn Events
Whats in your cogs? — Parallax Forums

Whats in your cogs?

Zap-oZap-o Posts: 452
edited 2011-03-02 13:54 in Propeller 1
I read the forums at times and I get a kick out of cog usage.

People seem to be using one cog to do one thing and it blows me away. I want to know what your doing in your cogs. I ask this so that people will realize a propellers cogs can do more than just one task.

Ill go first -

1 cog = Reading a 4 channel 16bit ADC, driving a high current H-bridge with a 16 bit DAC, push data to a dual channel digital potentiometer, running a PID and other floating point math calculations, drive a 20 x 4 LCD display, and an I/O expander for LEDs, buttons, while keeping time in seconds.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-03-02 08:06
    There's nothing wrong with using a cog for some kind of simple task. That's one of the beauties of this architecture. Sure, having 8 fast microprocessors on a chip potentially provides a lot of computing power, but it also allows for simplifying the program logic for a given task. Sure, it's possible to have a task manager that allows you to share the throughput of one cog among several tasks, but that still requires you to think about the other tasks that are running. You have to make sure that any given task doesn't overrun its time slice or you have to compensate for that, etc.
  • Ahle2Ahle2 Posts: 1,179
    edited 2011-03-02 08:07
    I have got many ongoing propeller projects, but the most interesting regarding cog usage is this one -> http://www.youtube.com/watch?v=EJcbxrdErkY

    6 of 8 cores are in use:
    1 cog for SID emulation (SIDcog by Ahle2)
    2 cogs for rendering graphics in 60 fps to a single frame buffer without tearing (text scroller and oscilloscope in one cog, wavy background in the other cog)
    1 cog for CVBS video generation (TV.spin by Chip Cracey)
    1 cog for SD card (fsrw by Lonesock)
    1 cog for gluing everything together (the only cog running a spin interpreter)
  • SapiehaSapieha Posts: 2,964
    edited 2011-03-02 10:06
    Hi Ahle2.

    Have You posted else will do that --- Entire spin code to this demo?


    Ahle2 wrote: »
    I have got many ongoing propeller projects, but the most interesting regarding cog usage is this one -> http://www.youtube.com/watch?v=EJcbxrdErkY

    6 of 8 cores are in use:
    1 cog for SID emulation (SIDcog by Ahle2)
    2 cogs for rendering graphics in 60 fps to a single frame buffer without tearing (text scroller and oscilloscope in one cog, wavy background in the other cog)
    1 cog for CVBS video generation (TV.spin by Chip Cracey)
    1 cog for SD card (fsrw by Lonesock)
    1 cog for gluing everything together (the only cog running a spin interpreter)
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-03-02 12:20
    Zap-o wrote: »
    1 cog = Reading a 4 channel 16bit ADC, driving a high current H-bridge with a 16 bit DAC, push data to a dual channel digital potentiometer, running a PID and other floating point math calculations, drive a 20 x 4 LCD display, and an I/O expander for LEDs, buttons, while keeping time in seconds.
    But what are the other seven cogs doing?
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-03-02 13:54
    Of course one COG can do more than one thing, but why should it?

    The point is that you need extra efford to put many tasks in one COG and the resulting code is propably only usefull for the project it has been designed for. The idea of the object exchange is : take it and use it. No need to understand the code, no need to change the code.
    I doubt that you will find a lot more people that would need exactly that combinations of tasks you listed. So, when talking about a COG doing several things you don't talk about finished objects, you talk about code snippets that you can put together.
    So, from my point of view it's simply the propeller-natural order to:
    1. Use an object - which often means 1 or even more COGs for that
    2. If more COGs would be needed than available, check if several objects can share COGs
    3a. Check whether one COG can do several different things
    3b. If you also run out of I/Os, use a multi-prop design

    So, the 1 COG many tasks solution I'd only take into account if nothing else helps. So far I did not reach this limit.
Sign In or Register to comment.