View Full Version : Out of Cogs, best items to combine on 1 cog?

Jimmy W.
01-14-2008, 04:52 AM
Ok, I have been messing w/ my design for my prop and I have come to a bit of a problem, I am out of cogs! I figure that I can combine a couple cogs but I would like feedback.
Originally Cog 0 just did diagnostics and display driver, I think it should not be a problem to load it up as follows as none of these items are super critical (as far as speed), the·LOGIC would be as follows

repeat 'run this forever
··· Read hub ram for all status bits
···· Good?
······ Critical?
······· No, send error to serial, data log, act upon non critical error
······· Yes, Kill Cog, Restart Cog
····· Yes, Continue
··· iff new keypad data run Parsekeypad()
··· iff new serial data or telnetdata·run ParseSerial()
··· iff new 1-wire run ParseOW()
··· iff new Zigbee Data run ParseZGB()
··· every 20th run UpdateOW() to set output status of all one wire output devices
··· run LCDData(), send results to LCD Cog
··· run LEDStatus(), send output to i2c Cog
··· every 50th run GetAllOWStatus

If i do it this way this cog can be all in spin, and it will still be fast enough (I think) to be able to take care of any incoming serial/ telnet commands and the LCD display updating

Cog 0: Diagnostics/process watchdog/display driver/command·router / battery watchdog/MAIN LOGIC!, Watches bits that other cogs output to ensure they are still running and have no errors, also compiles what should be displayed on screen and sends it to the lcd cog and communication cogs
Cog 1: Full duplex serial, Talk to the·C# application to reprogram default values
Cog 2: SD Card Driver / SPI, Write logs and update NV information when it changes.
Cog 3: i2c Driver,·run all the i2c Led drivers
Cog 4: Ethernet driver w/ ENC28J60, hosts the webpage to configure the prop, also accepts telnet connections
Cog 5: Zigbee w/ xbee, Connects to ZB only props.
Cog 6: 1-wire interface, Talks to all the DS 1-wire stuff
Cog 7: Keypad matrix scanner, scans the keypad for inputs

·Any thoughts on this or ideas to combine / split things up better for the best performance?


Hopefully I put enough information here to help you understand my problem, if I missed any obvious information let me know :)

01-14-2008, 06:56 AM
Well, it is still unclear what the timing constraints are, whether it is tolerable to miss an event, etc. etc.
Just all the things that are important in real-time programming and interrupt handling. It is a myth that you don't need that just because the Propeller has no interrupts. That only makes things much more difficult...

To become positive again: consider that you do not need COGS staying around just waiting. It might suffice to load them when they are needed - this takes only 100µs! The candidates I see for that immediately are the keypad scanner and the LCD driver....