Whats in your cogs?
Zap-o
Posts: 452
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.
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
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)
Have You posted else will do that --- Entire spin code to this demo?
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.