Shop OBEX P1 Docs P2 Docs Learn Events
Having difficulties starting cogs — Parallax Forums

Having difficulties starting cogs

kutalinelucaskutalinelucas Posts: 80
edited 2011-08-17 12:50 in Propeller 1
I'm having some difficulties starting a new cog and was wondering if somebody could help me out...

I'm writing a program which reads in 2 variables, the first to identify a specific motor, the second for the required rotation of that motor. All i'm looking to start a new cog and pass these two variables, do the move (while the first two cogs are waiting for futher instructions) and then exit the cog when completed.

So far the data is read by 2 cogs and succesfully passed to the object posted below, but for some reason I can't get a new cog to run...could somebody please help?
CON
        delay = 3_000_000
VAR
        long rotation
        long motmov
        Long motstack[12]
OBJ

PUB start(reconstructed_data, Motor_ident)
cognew(turn_motor,@motstack)
motmov := reconstructed_data
if motmov < 30
  !OUTA[9]
  
if motmov > 30
  !OUTA[8]
              
PUB turn_motor
  
Repeat
  !OUTA[10]
    waitcnt(Delay + cnt)

Comments

  • kutalinelucaskutalinelucas Posts: 80
    edited 2011-08-17 07:49
    All good...had no idea each cog has its own DIRA register...makes perfect sense but nevertheless poorly documented
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-08-17 09:48
    nevertheless poorly documented

    Really? From the docs (under DIRA): "Each cog maintains its own DIRA register that gives it the ability to set any I/O pin's direction."
  • kutalinelucaskutalinelucas Posts: 80
    edited 2011-08-17 10:44
    of course it is there...but I just refrence the guide when I need to not read through it...I'm not used to this multi-core stuff, generally in any other language or with any other processor you define the pin direction then have to redefine it only when nessesary...just would hve expected it to be mentioned around the old 'cognew' statement. Not that i'm bothered, just would have saved a efw hours scratching my head
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-08-17 10:59
    not read through it

    Well, there's your problem! ;)

    I'm not here to defend Parallax, but as someone who writes a lot of documentation I think it is fair to say that it is impossible, especially with a controller as sophisticated as the Propeller, to explain every possible interaction in every section of the manual -- it would end up as thick as pieces of recent federal legislation and be about as useful.
  • kutalinelucaskutalinelucas Posts: 80
    edited 2011-08-17 12:50
    Please believe me...It wasn't a swipe at parallax or the documentation and support available for the propeller, which I do think is fanstastic...I've been able to progress with little effort in a short amount of time thanks to the spin tutorial published by Parallax and this forum, who's members give the best help and support I have ever come across, without the arrogance found in many other forums

    It was only an observation and I was just surprised that I didn't find much mention that each cog was required to define it's access to each pin (when I was stuck and scrolling through google). I've done some things with 8051's, PICs, FPGA's and everything is relativly standard, to be honest the re-defining of pin directions is the biggest practical difference (regarding programming) I've noticed...it's sooo good.

    But anyway, no biggy, and long live the prop
Sign In or Register to comment.