Shop OBEX P1 Docs P2 Docs Learn Events
Question about cogs and objects — Parallax Forums

Question about cogs and objects

MacGeek117MacGeek117 Posts: 747
edited 2007-01-07 22:48 in Propeller 1
When you use a OBJ such as Servo32, do you call the PUB Set(Pin, Width) from another cog, or is that code in the same cog?
RoboGeek

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I reject your reality and subsitute my own!"

Adam Savage, Mythbusters
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.startrek.com
·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-01-07 22:05
    There are two cogs involved in the use of Servo32, like many of the I/O drivers. One cog is started by the Servo32 start routine using cognew and may be running the Spin interpreter (like if you were using Servo4 instead of Servo32) or, as in the case of Servo32, an assembly routine. The other cog is the one running the Spin interpreter that's doing the call to start and the cognew statement. This "original" cog is still running and would be the one that calls routines like Set.
  • MacGeek117MacGeek117 Posts: 747
    edited 2007-01-07 22:09
    So, to use Servo32 you need three gogs?
    RoboGeek

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I reject your reality and subsitute my own!"

    Adam Savage, Mythbusters
    www.parallax.com
    www.goldmine-elec.com
    www.expresspcb.com
    www.startrek.com
    ·
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2007-01-07 22:25
    You need only two cogs, one cog has the code doing all the work and the other cog is your main cog where you called the start function from. This is the same for most of the objects like keyboard and mouse etc. Look at the examples, the start creates a new cog and then the main example program calls the various functions.

    Graham
  • MacGeek117MacGeek117 Posts: 747
    edited 2007-01-07 22:48
    Thanks guys! You're awsome!
    RoboGeek

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I reject your reality and subsitute my own!"

    Adam Savage, Mythbusters
    www.parallax.com
    www.goldmine-elec.com
    www.expresspcb.com
    www.startrek.com
    ·
Sign In or Register to comment.