Shop OBEX P1 Docs P2 Docs Learn Events
Generating pulses with BS1 USB — Parallax Forums

Generating pulses with BS1 USB

Richard BaloghRichard Balogh Posts: 8
edited 2006-12-09 09:42 in BASIC Stamp
Hello,

i need to generate a sequence of pulses, where logic values are coded as pulses of different width.
One is represented with 0.56 ms pulse of log.1 followed by the same length of log.0
Zero is represented as 0.56ms pulse of log.1 followed by the 1.69ms log.0
(see attached image, or following link please:
pulses.gif
)

I did this successfully with BS2 module, with following code:

PULSOUT 9, MyData.BIT0 * 510 + 280 ' Bit-0 pulse
PULSOUT 9, MyData.BIT1 * 510 + 280 ' Bit-1 pulse
PULSOUT 9, MyData.BIT2 * 510 + 280 ' Bit-2 pulse
etc.

For my application seems to be perfect idea to use as the controller BS1/USB.
But I am not able to generate such a short pulses with BS1 processor.

Any ideas how to generate pulses with BS1?


Richard Balogh
438 x 151 - 2K

Comments

  • Sarten-XSarten-X Posts: 32
    edited 2006-12-09 09:42
    ah, the joys of the BS1!

    The BS1 can do exactly the same thing, but you'll need to do a bit more code for it. Such as:

    symbol MyData = W0  ' w0 is the only word available in bits. Since it is the only one, 
                        ' we don't need to refer to it specifically below. 
     
    symbol temp = w1    ' This is a temporary place to hold calculated values. It can be any word.
                        ' If you don't use GOSUB while it's in use, you can store it in W6.
    
     
    'Do other stuff here
     
    Temp = BIT0  * 510 + 280  ' Bit-0 pulse 
    PULSOUT 9, Temp
    Temp = BIT1  * 510 + 280  ' Bit-1 pulse 
    PULSOUT 9, Temp
    Temp = BIT2  * 510 + 280  ' Bit-2 pulse 
    PULSOUT 9, Temp
    
    


    As you can see, the BS1's code is essentially the same, but since the BS1 can't do expressions mid-statement like the BS2 can, you have to calculate things separately before running the statement.

    Post Edited (Sarten-X) : 12/9/2006 10:12:08 AM GMT
Sign In or Register to comment.