Shop OBEX P1 Docs P2 Docs Learn Events
Hello, all 8 Cog Worlds ! each cog blinks a led with its #+1, challenge. — Parallax Forums

Hello, all 8 Cog Worlds ! each cog blinks a led with its #+1, challenge.

Phillip Y.Phillip Y. Posts: 62
edited 2006-05-19 17:42 in Propeller 1
This example program uses all 8 cogs,
they all·blink CogId+1·then wait for all to finish,
then ClkSet($80) reboots.

My 3 challenges·are;

#1·to use the;
PUB BlinkNextLED (loaded into·cogs 1-7)
to load cog 0 instead of loading it first seperatly.

#2 (Use an aray to) shorten this;
VAR
· long stack1[noparse][[/noparse]6]
· long stack2[noparse][[/noparse]6]
· long stack3[noparse][[/noparse]6]
· long stack4[noparse][[/noparse]6]
· long stack5[noparse][[/noparse]6]
· long stack6[noparse][[/noparse]6]
· long stack7[noparse][[/noparse]6]
· long stack8[noparse][[/noparse]6]·· .
··
#3 (Use an aray to) shorten this;
PUB
· cognew (BlinkNextLed, @stack2)
· cognew (BlinkNextLed, @stack3)
· cognew (BlinkNextLed, @stack4)
· cognew (BlinkNextLed, @stack5)
· cognew (BlinkNextLed, @stack6)
· cognew (BlinkNextLed, @stack7)
· cognew (BlinkNextLed, @stack8)· .

Phillip Y.

Comments

  • cgraceycgracey Posts: 14,133
    edited 2006-05-16 05:17
    Phillip,

    Is this what you wanted?
    VAR
    · long stack[noparse][[/noparse]6*8]
    ··
    PUB
    ·repeat i from 7 to 0
    ·· ·coginit (i, BlinkNextLed, @stack[noparse][[/noparse]6 * i])

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • Phillip Y.Phillip Y. Posts: 62
    edited 2006-05-16 07:48
    That worked· excellent, I especially liked ;
    "This includes the current cog; i.e.: a cog can use COGINIT to stop and restart itself to run, perhaps, completely different code."
    Now I need some data to persist past the ReBoot so I can alternate the blink direction at each ReBoot.
    Should this be in main ram or cog0 ram ?
    How do you force the location of a var to either location ?
    Phillip Y.


  • GadgetmanGadgetman Posts: 2,436
    edited 2006-05-16 09:01
    You don't.

    Spin keeps ALL its variables and code in System(HUB) RAM.
    The only thing that is loaded in the COGs is the interpreter and whatever tokens it is interpreting at the moment. (There's not room for anything else.)

    The only way to 'persist' data through a Reboot is to store it externally.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't visit my new website...
  • Phillip Y.Phillip Y. Posts: 62
    edited 2006-05-19 17:07
    I found 3 bits of external storage that do persist through reboot P8, P10 and P11 on the demo board.
    After 6 cycles·P10 or P10 ·reaches the proper treshold to work properly and alternate the direction of blinking.

    This is·like a·Dram bit.

    I am concerned with the 0.1uF cap on P8 and the 50ma output ability of each pin,
    ·since this will look like a short circuit while it is charging or discharging with out a current limiting resistor
    ·like P10 and P11 have, espeialy if it was used at a higher frequency.

    Is the ELECTRET MIC active or passive ?
    Is there a part # to look it up ?
  • cgraceycgracey Posts: 14,133
    edited 2006-05-19 17:42
    Phillip Y. said...
    I found 3 bits of external storage that do persist through reboot P8, P10 and P11 on the demo board.
    After 6 cycles·P10 or P10 ·reaches the proper treshold to work properly and alternate the direction of blinking.

    This is·like a·Dram bit.

    Interesting observation.

    I am concerned with the 0.1uF cap on P8 and the 50ma output ability of each pin,
    ·since this will look like a short circuit while it is charging or discharging with out a current limiting resistor
    ·like P10 and P11 have, espeialy if it was used at a higher frequency.

    It will just cause current draw. Remember that the pin has an internal impedance that limits how much current it can pass. We tried to make it very low-impedance (for an I/O pin), but it's still wimpy in the greater scheme of things. If you wiggle that pin, all you'll do is create a little voltage ripple on VDD and draw more current. In practice, that·pin is used as an input, anyway.

    Is the ELECTRET MIC active or passive ?
    Is there a part # to look it up ?

    Electret mic's are active, though very simple. Their transducer modulates the gate/base of a transistor to modulate the pin that is also their power supply. On the Demo Board, this pin is capacitively coupled into an RC integrator which makes the ADC circuit. Digi-Key and Mouser sell hundreds of different types of electret microphones. Some are $.39 in volume. That means maybe $.10 in China. I don't have the part number right now that we used, but it's on a post about the Demo Board. It's·a Kobitone part.
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
Sign In or Register to comment.