Code speed for BS2 (highest frequency digital IO pin write)
So I need to create a square wave of which i can send a specific number of pulses I need this code to be as fast as possible.
I am trying to determine how quickly a full cycle would be (From peak to peak)
I don't have my scope here with me and i was hoping someone could either let me know the time or suggest a more efficient way
count = 250
DO UNTIL count=0
High 1
low 1
count = count -1
Loop
I am trying to determine how quickly a full cycle would be (From peak to peak)
I don't have my scope here with me and i was hoping someone could either let me know the time or suggest a more efficient way
count = 250
DO UNTIL count=0
High 1
low 1
count = count -1
Loop
Comments
This is the best summary of execution times.
Post Edited (allanlane5) : 1/8/2010 4:22:19 PM GMT
word steps
steps = 400
steploop 'Start timing here
high1
steps=steps-1
low1
if steps >1 steploop
And that's for a BS2 "plain". A BS2sx will go twice as fast.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
At least the bulk should then run at 4.1Khz with some pauses calling the subs.
However, sometimes you really do need the speed. In which case the SX-28 and SX-48 platforms provide 50 MIPS -- you might look at those boards from Parallax. AND there's the 'Propellor' processor, which also runs in real-time.
Just a thought.
Very good point though, This may just be to much for the stamp.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
Note that a single TOGGLE in the loop makes the loop run faster, but each toggle is only 1/2 cycle, so the overall frequency is less.
There are a couple of ways to make the Stamp generate faster pulse sequences, if the output can tolerate some jitter.
generates 50 clock pulses on pin p1, and 25 data pulses on pin p2. You could use either one, but the p2 pulses would be more square-like. The data pulsewidth on a BS2 is about 60 microseconds and the space between groups of 16 is about 240 microseconds (caveat--old measurements).
generates 100 pulses of 4.5 microseconds width in a total period of 1.15 milliseconds.
And for counted pulse streams of 1 to 128 pulses in the same 1.15 millisecond frame.
The last one stands for the number of cycles, so to get 200 in 2.30 milliseconds:
The LOW is necessary because PWM leaves the pin an input.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Post Edited (Tracy Allen) : 1/8/2010 8:19:57 PM GMT