Shop OBEX P1 Docs P2 Docs Learn Events
Not enough COGs?? — Parallax Forums

Not enough COGs??

rkrasowskirkrasowski Posts: 16
edited 2011-02-10 06:10 in Propeller 1
Good.zipHere we go again,
Let me first describe my project:
Telemetry box that has GPS, Pressure sensor, 3axis accelerometer, XBee transceiver and SDcard to record the data. The idea is transmit telemetry from "box" to the computer via XBee, on top of that record data into SDcard that is attached into propeller board. Finally with you help I was able to get all "modules" working. Now routine starts from GPS that required 2 COGs to function : one for NMEA interpretation and one for mini serial communicator, after that I start accelerometer that required one COG for serial communication, next go XBee that again one COG for serial communication next pressure sensor that is COG hungry - use 3 COG,s and the last thing - SDcard which I understand use only 1 COG. Everything was working nice untill finally I was able to get my pressure sensor to work, now routine gets to the point of mounting SD card and tells me not able to mount (this is last thing that program is trying to do). My understanding is that probably I run out of COGs. Do I understand correctly?? If so how to overcome this problem, does that means that I will have to stop some of the COG to record into SDcard and than restart it again to do let say stop Pressure routine??
Attached is the code for entire project. it start with file main.spin

Thanks like always
Robert

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2011-02-09 19:28
    ATM I count 10 cogs in use which isn't going to fly. You could replace Float32Full with Float32 and your debug serial could use Simple_Serial as you only use 9600 baud anyway. Why don't you give that a try?

    GPS_IO_mini may also get away with just using Simple_Serial.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-02-09 19:59
    There is also a 4-port serial I/O driver in the Object Exchange that provides up to 4 bidirectional asynchronous serial channels using just one cog. That takes care of the GPS serial communications and the xBee. I don't understand why the pressure sensor would require 3 cogs unless it's because that uses floating point. If so, as kuroneko suggested, you can use Float32 which uses only one cog for the floating point. I also don't understand why the NMEA interpretation requires its own cog. Perhaps you're confusing cogs and objects. They're very different. An object doesn't necessarily use an additional cog and you can have multiple cogs used by an object.
  • TtailspinTtailspin Posts: 1,326
    edited 2011-02-09 19:59
    Also consider that depending on how fast You want Your data sent out, You might not need the GPS cog,
    or maybe the Accelerometer cog, while You are sending data to the XBee.

    stop the data send cogs while You get data and save data to variable of your choice, then stop the data get cogs,
    then restart the data send cogs, then send/record the data... Lather Rinse and Repeat, yes?

    Look up Cogstop in the Prop Manual and see if that helps make sense of what I just typed...:smile:
  • pjvpjv Posts: 1,903
    edited 2011-02-09 21:00
    Or you could write/use a muti-tasker and do all of that in just 3 or 4 cogs....... but only in assembler though.

    Cheers

    peter (pjv)
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-02-09 21:37
    I had similar trouble running out of cogs.

    The 4 port serial object Mike refers to, saved me.

    Time Moore wrote it. Here's a link.
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-02-10 01:37
    I posted a reply hours ago, but it's not here - perhaps I closed the tab before posting (a senior moment again)

    Anyway, if your pressure sensor and accelerometer are I2C, they can share a cog for the low level. This should remove any timing constraint. You can also share the pins with the eeprom here.
    The 4 port serial, as has been suggested will save you too.
    The SD will require 2 cogs, 1 for the low level, and 1 for the FAT routines. However, you maybe able to dispense with the FAT routines if you have a fixed contiguous file or you do not use FAT.
  • rkrasowskirkrasowski Posts: 16
    edited 2011-02-10 06:10
    Great advices guys, thanks, now is up to me to try. This week end I am away from home, but today and next week I will play with it. I will keep you informed about final solution.
    Thanks again.

    PS
    Cluso99, thanks for input, I see fantastic boat as your logo, let me tell you what is this project of mine all about. I have PSKMail server for emailing, at home, I added "Boat Link" that allows chat over the internet with boat that are connected into my server. On top of that you can request telemetry data from internet that you get from "telemetry box" that I am constructing now. Everything is written in PERL - for boat link, PSKMail in Java, internet siede in PHP and now time for Propeller and telemetry box.
    You can see entire project on my internet side www.anchorsat.info. Boat link does not exist in english version of my page, only on Polish, sorry no time to update my side.
    Thanks again for your help
    Robert
    KB2PNM
Sign In or Register to comment.