Shop OBEX P1 Docs P2 Docs Learn Events
Propeller Sequencer Help — Parallax Forums

Propeller Sequencer Help

CaliforniaKidsCaliforniaKids Posts: 2
edited 2011-01-25 16:02 in Propeller 1
I am trying to build a basic sequencer. I would like to ripple a high output through 20 output pins. The time duration could be about .5 seconds dwell at each pin before moving on. It could loop forever. It would start when it received an input trigger and stop when it received a pulse on another input pin. I would like to remotely control it from about 50 feet away: Ethernet, USB I2C, RS 232, wireless? Any suggestions?

Thanks, CK

Comments

  • groggorygroggory Posts: 205
    edited 2011-01-25 11:33
    For the sequencing stuff, that could be done within your first attempt at the prop education kit. Piece of cake. Single cog in a loop doing the sequencing

    For the remote control you could do it with Xbee using the I/O pins (through the obex xbee object). ~$20/xbee

    or you could go simpler and cheaper and use something from linx wireless. LC series transmitter & receiver. Then throw on a 'splatch' antenna or 1/4 wave whip or JJB antenna. ~<$4/ radio + <$3/ antenna

    or http://www.sparkfun.com/products/691
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-01-25 13:01
    This is very easy -- the code below will give you an idea of starting and stopping a sequencer cog. The cog also monitors a global variable called hold so that you can hold and resume the sequence if desired.

    This is NOT a full program, just demo code to help you get up and running
    pub startseq
    
      hold := false
      cog := cognew(sequencer, @stack)
    
    
    pub stopseq
    
      if cog
        hold := true
        cogstop(cog~ - 1)
    
    
    pub holdseq
    
      hold := true
    
    
    pub resumeseq
    
      hold := false
    
    
    pri sequencer | t, idx
    
      t := cnt                                                      ' sync timing
      repeat
        repeat idx from 0 to 19                                     ' loop through pins
          outa[19..0] := 0                                          ' clear last
          repeat while (hold == true)                               ' if in hold mode
            t := cnt                                                '   resync timing
          outa[idx] := 1                                            ' output/high
          dira[idx] := 1
          waitcnt(t += clkfreq/2)                                   ' wait 1/2 second
    
  • groggorygroggory Posts: 205
    edited 2011-01-25 13:13
    JonnyMac wrote: »
    This is very easy -- the code below will give you an idea of starting and stopping a sequencer cog. The cog also monitors a global variable called hold so that you can hold and resume the sequence if desired.

    This is NOT a full program, just demo code to help you get up and running
    pub startseq
    
      hold := false
      cog := cognew(sequencer, @stack)
    
    
    pub stopseq
    
      if cog
        hold := true
        cogstop(cog~ - 1)
    
    
    pub holdseq
    
      hold := true
    
    
    pub resumeseq
    
      hold := false
    
    
    pri sequencer | t, idx
    
      t := cnt                                                      ' sync timing
      repeat
        repeat idx from 0 to 19                                     ' loop through pins
          outa[19..0] := 0                                          ' clear last
          repeat while (hold == true)                               ' if in hold mode
            t := cnt                                                '   resync timing
          outa[idx] := 1                                            ' output/high
          dira[idx] := 1
          waitcnt(t += clkfreq/2)                                   ' wait 1/2 second
    

    Also, if you need some precision note that flipping a pin high or taking it low takes about 6 microseconds when you're running the prop at 80 MHz (according to my logic analyzer)
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-01-25 13:27
    could be about .5 seconds dwell at each pin

    ...was a clue that this could be handled in Spin. It would be nearly as easy in PASM, though.
  • groggorygroggory Posts: 205
    edited 2011-01-25 13:45
    JonnyMac wrote: »
    ...was a clue that this could be handled in Spin. It would be nearly as easy in PASM, though.

    Wow, talk about an easy app.

    Might as well just run the prop at 20kHz off the internal oscillator and save some batteries too. :-)
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-01-25 14:04
    If he uses contact closure inputs, absolutely.
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-01-25 16:02
    You could also use a set of serial latches which would require 3 pins (clock, data, reset) plus of course power/gnd. For 50ft, it really depends on what the environment is like - you may require rs232 or rs422/485 or straight prop to latches may work.

    So, it really depends on your app. The pasm code to run this is extremely simple.
Sign In or Register to comment.