Parallel loops ?
Archiver
Posts: 46,084
Hi again,
Specifically, I want three TTL outputs (using the HIGH and LOW
commands or TOGGLE, that do this...
one at 10ms square wave
one at 20ms square wave
one at 500ms square wave
In the only program I'm "good" at, LabVIEW, I'd do parallel loops, but
I'm not sure how to do this in pbasic.
This list is great, thanks in advance.
Specifically, I want three TTL outputs (using the HIGH and LOW
commands or TOGGLE, that do this...
one at 10ms square wave
one at 20ms square wave
one at 500ms square wave
In the only program I'm "good" at, LabVIEW, I'd do parallel loops, but
I'm not sure how to do this in pbasic.
This list is great, thanks in advance.
Comments
about 10, 20 and 500 milliseconds on p0,p1 and p2 respectively. The
"about" can be improved if you play with the timing, or if you have
an external period reference. The calculations take time, which
depends on which Stamp you are using.
x var word
dirA=$f ' port A is outputs
loops:
outA=(x/50<<2)|(X//4/2<<1)|(X//2)
x=x+1//100 ' takes ~500ms to count 0 to 99
pause 4 ' the above stuff takes ~1 millisecond, 5 total.
goto loops
the statement with "outA=" is what sets the output bits. For
example, each ~5 milliseconds, x advances by one count, so x//2
alternates zero and one, and that is transferred to p0. "x/50" is
zero when x is less than 50 and one when x is greater than 50, and
that is shifted into the position to control output bit p2.
-- Tracy Allen
>Hi again,
>Specifically, I want three TTL outputs (using the HIGH and LOW
>commands or TOGGLE, that do this...
>one at 10ms square wave
>one at 20ms square wave
>one at 500ms square wave
>
>In the only program I'm "good" at, LabVIEW, I'd do parallel loops, but
>I'm not sure how to do this in pbasic.
>
>This list is great, thanks in advance.