Shop OBEX P1 Docs P2 Docs Learn Events
New Propeller coder — Parallax Forums

New Propeller coder

pmartinpmartin Posts: 10
edited 2006-06-12 13:49 in Propeller 1
I received my propeller demo board recently and I have been playing with it, trying to figure out how to utilize its parallel processing capabilites. One thing I am having trouble with is starting multiple cogs. Chapter 4 of the documentation lists I can use 'cognew' or 'coginit' to have a function be executed by a cog. Below is a code segment from my spin object MultiBlink:

OBJ
blinkers : "BlinkLed"

...

blinkers[noparse][[/noparse]0].init(pin1, delay2)
blinkers.init(pin2, delay1)
blinkers.init(pin3, delay2)

coginit(2, blinkers[noparse][[/noparse]0].start, @cogStack1)
coginit(3, blinkers.start, @cogStack2)
coginit(4, blinkers.start, @cogStack3)

The goal is to have 3 separate blinking leds runnning on three separate cogs. When I run this code, only the FIRST runs. Is there some other trick I am missing when I assign functions to cogs?

Thanks!
(you may see my code that is attached)

Comments

  • David BDavid B Posts: 591
    edited 2006-06-06 22:44
    If it's any consolation, I'm running into similar problems.

    I've been having mixed successes and failures with starting both assembly and spin cogs. Been re-reading the documents, reading and trying example codes, trying lots of variations. Bean, your BlinkLEDAsm.spin has been real helpful; thanks for posting that.

    I've got a homemade board with only one on-board LED, and it seems like this testing would go much better if I were to add more. I was thinking that maybe a 7-segment LED display would make a nice debugging device; I could either use individual segments, as in this multiple cog testing, or display complete digits, or even display that sort of slithering worm pattern like some old minicomputers had on the rear of their system unit, which would speed up and slow down depending on system load. I always thought that looked cool.

    So I hope somebody has some clues!

    David
  • Phillip Y.Phillip Y. Posts: 62
    edited 2006-06-07 01:20
    Take alook at this topic
    This example program uses all 8 cogs, they each seperatly blink the CogId+1 then wait for all to finish, then ClkSet($80) reboots.

    http://forums.parallax.com/forums/default.aspx?f=25&m=126127
    and this program for the demo board c.
    http://forums.parallax.com/forums/attach.aspx?a=7428
  • David BDavid B Posts: 591
    edited 2006-06-08 04:45
    Here is a working example of four cogs working at once.

    I added a 7-segment display to my homemade board, and used it to develop and demo starting multiple cogs, with a few variations, flashing LEDs at slightly different clock speeds.

    PMartin, this is much like your code but with a few distinct differences. I can't yet say which difference is what fixed the multiple cog demonstration, but this does work, so maybe this will help you get yours up and running.

    David
  • pmartinpmartin Posts: 10
    edited 2006-06-09 01:30
    Thanks for the tips. Separately I worked on solving the problem and came up with the solution attached. I am a Java programmer by day, and I was intrigued by the use of objects in a mircocontroller. So the new file makes BlinkLEDs real objects; I wanted to experiment with making propeller 'threads'. I use the MultiBlink top object to start a whole set of them. This is basically my 1st fully running app for the propeller demo board.

    Cheers!
  • Phillip Y.Phillip Y. Posts: 62
    edited 2006-06-09 02:40
    I ran your program and then made 2 changes.
    PUB start(s)
    cogVal := cognew(blink, @stack) + 1
    I changed to
    PUB start(s)
    cogVal := cognew(blink, s) + 1
    and
    blinkers[noparse][[/noparse]0].start(@cogStack1)
    blinkers.start(@cogStack2)
    blinkers.start(@cogStack3)
    now can each pass @cogStack1,2,3 to "s" so that it acts as if it were @cogStack1,2,3

    Or with your original program
    OBJ
    blinkers : "BlinkLed"
    is called 3 times and creates 3 seperate objects,
    are there 3 seperate
    long stack[noparse][[/noparse]10]
    1 for for each object ?

    both versions blink the same.

    Phillip Y.
  • Phillip Y.Phillip Y. Posts: 62
    edited 2006-06-09 02:44
    The cut and paste missed something should be;
    blinkers[noparse][[/noparse]0].start(@cogStack1)
    blinkers.start(@cogStack2)
    blinkers.start(@cogStack3)
  • Phillip Y.Phillip Y. Posts: 62
    edited 2006-06-09 02:51
    I posted it correctly and the and were deleted after I hit SUBMIT.
    blinkers[noparse][[/noparse]0].start ~~~
    blinkers.start ~~~
    blinkers.start ~~~
    I think the @ is looking like a email address or something when posting, and the font size is being alterd.
  • Phillip Y.Phillip Y. Posts: 62
    edited 2006-06-09 02:57
    It is the [noparse][[/noparse] 1 ] and [noparse][[/noparse] 2 ] that·were deleted with quick reply.
    It is the [noparse][[/noparse]1] and [noparse][[/noparse]2] that are deleted, looks ok in the preview before posting.
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2006-06-09 03:05
    You need to use the Code tags for it to go right.
    -Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Martin Hebel
    Southern Illinois University Carbondale - Electronic Systems Technologies

    Personal Links with plenty of BASIC Stamp info
    StampPlot - Graphical Data Acquisition and Control
  • Phillip Y.Phillip Y. Posts: 62
    edited 2006-06-09 03:39
    I made report in Parallax Forums > Public Forums > Support for Using this Forum > Trouble with quick reply altering SPIN CODE quoted in posting.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-06-09 03:42
    You cant use the Quick reply to post whitespace formatted code such as spin, you can only do it in a full post and using the "code" box.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Life is one giant teacup ride.
  • GadgetmanGadgetman Posts: 2,436
    edited 2006-06-09 09:05
    You can't?

    TEST
        TEST
            TEST
    
    

    Edit: That was written in a quick-reply box... I just added the [noparse]/noparse code and /code tags manually.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't visit my new website...
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-06-09 13:23
    Gadgetman, I would like to know how you do that...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
  • SSteveSSteve Posts: 808
    edited 2006-06-09 19:29
    KK: You simply type the tags: "[noparse][[/noparse] c o d e]" and "[noparse][[/noparse] / c o d e ]" (without the spaces).
    Code entered in Quick Reply
    


    It works for any tag (e.g. urls My band's website)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-06-09 19:44
    And if you want to demonstrate [noparse][[/noparse]code] and [noparse][[/noparse]/code] tags without the spaces, you can substitute [ for the left square bracket, so the forum's HTML formatter doesn't confuse it with the beginning of a tag. (Unfortunately, you can't reedit a post containing these symbol codes without reentering each one separately, since they're converted back to brackets in the edit box.)

    -Phil
  • SSteveSSteve Posts: 808
    edited 2006-06-10 05:17
    Nice trick, Phil.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-06-12 13:49
    SSteve:
      This is cool
    
    


    Thanks a lot!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
Sign In or Register to comment.