Shop OBEX P1 Docs P2 Docs Learn Events
I cant find COG #1 — Parallax Forums

I cant find COG #1

TCTC Posts: 1,019
edited 2014-03-26 12:35 in Propeller 1
Hello all,

I was just playing around and trying to get an idea what COG could be doing what for my reflow oven. Well I seem to be missing COG #1, and I dont know why. I am thinking there should only be 4 COGs being used (0 to 3). I have included the all the code I am using, maybe someone could tell me where it is hiding? And so I can get a better idea on what to look for. I also included a pic of what I am seeing on my display.

Line 1, is the current COG number
Line 2, is the Serial Driver COG for my display
Line 3, is 1 of 2 heater drivers COG
Line 4, is 2 of 2 heater drivers COG

Thanks
TC
1024 x 577 - 68K

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2014-03-25 18:33
    All cogs except the primary are reported as cogid+1, IOW 2 means cog 1 etc.
  • TCTC Posts: 1,019
    edited 2014-03-25 18:38
    Ahh, that makes sense. So if I was going to "display" the COG number for any reason, I should do (just to make sure I fully understand)
    BlahBlahBlah.dec(BlahCOG -1)
    
    
  • kuronekokuroneko Posts: 3,623
    edited 2014-03-25 18:43
    It entirely depends on the objects you're using. ATM they all return cogid+1 in which case the -1 adjustment works. Other objects may not even tell you they are using extra cogs or even if they do, it might be an unadjusted ID. IOW don't take this -1 behaviour for granted.
  • TCTC Posts: 1,019
    edited 2014-03-25 18:47
    Fair enough. Thank you for explaining it for me.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-03-26 08:29
    In some cases, Cog 0 might be overlooked as it is used as a program loads into the Propeller and then may be stopped.

    The real example I can think of is with David Hein's pfth Forth. The Propeller has the Spin loader use the first cog (which is Cog 0) and then, the Forth interpreter is loaded into (Cog 1, which shows up as #1 with Cog ID ).

    You can actually play around with starting and stopping Cogs in real time with Forth. That may help clarify what is going on.

    Having the Block Diagram label cogs from 0 through 7, and the COGID replying in the same way is helpful. But some are not aware that Cog 0 is used to boot the Propeller (or forget) and then abandoned.
  • John KauffmanJohn Kauffman Posts: 653
    edited 2014-03-26 08:32
    I don't have my Prop here, so from memory:
    I thought cog 1 was used for a math routine then 2-7 for user programs. But I have no idea why I thought that. Can someone confirm I am wrong?
    For the "-1" technique, I thought on query of cogs I was getting cog 0 as main, so I'm not sure how -1 works for cog 0.
    Thanks.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-03-26 11:49
    @John Kaufman
    Yes indeed, you are confused in several ways.

    A. Any cog can be started and used for any purpose, unless the application itself dictates a special scheme.
    B. The numbering of cogs started out at 0 through 7, but some clever programmers dislike this and have shifted the numbering to 1 through 8 in their specific applications.
    C. Cog 0 is used to load the EEPROM binary into the Propeller which can eventually get back to Cog 0 and start the Cog 0 for other uses.

    My own experience was that I couldn't fully grasp starting and stopping multiple cogs until I actually had Forth, which is interactive, to play with.

    PropForth starts with Cog7 being the interactive cog; pfth Forth starts with Cog1 begin the interactive cog; and I don't know which cog Tackyon Forth starts with. But all can reach the other cogs and used them in different ways.

    It is just not as easy to see in Spin or PASM how starting and stopping cogs can be useful. And yet, this is where the Propeller can become extremely powerful. You may have a few cogs that must be in infinite loops at all times to facilitate communications or sensor monitoring, but other cogs can start and stop as tasks defined by the sensors and the communications dictate.

    The -1 technique is to be used with those programs from OBEX that shift the cog numbering from 0 through 7 to 1 through 8 when reporting to the user or the outside world. Not all programs require this.
  • John KauffmanJohn Kauffman Posts: 653
    edited 2014-03-26 12:35
    Got it, much thanks.
Sign In or Register to comment.