Some question for bs2
chinese boy
Posts: 2
How can·we know the time of every BS2' command step?
BS2 send a square wave out,at a same time·can it·do any other thing?
BS2 send a square wave out,at a same time·can it·do any other thing?
Comments
The BS2 consists of several 'family' members, each of which has a different IPS (InstructionsPerSecond) speed. Typically the BS2 'plain' does about 300 uSec per instruction.
You CAN set a pin's output state, and it will hold that state while other things happen. So, you COULD generate a square wave with:
MAIN:
HIGH OutPin
LOW OutPin
GOTO MAIN
in which case, you COULD do something between the 'high' and 'low' set statements. That would give you a square wave with about a 1 mSec period though -- 1000 Hz.
Take the code you want to time and set up a "FOR...NEXT" loop for 100 iterations.
Setup an LED to light up before the "FOR" and shut off after the "NEXT"
Use a stopwatch or a watch with a Lap timer and divide the result by 100.
use more iterations for higher resolutions.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
Your technique is sort of how it's done with a scope, only you want a command that is symmetrical so you can determine an accurate time.
1) Initialize a pin as an output LOW
2) TOGGLE that pin twice (now you have a start pulse)
3) Perform your task that you want to time
4) TOGGLE that pin twice again (now you have a end pulse)
The first time you run this you want to omit #3 so you can determine how "long" the TOGGLE command itself takes. Measure the time from rising edge to rising edge.
This value will be the "Constant" value you will subtract from future readings with step #3 implemented.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
If I want to send a square wave with a exact cycle,how can I do?
And the cycle is as short as possible.
low pin
main:
pulsot pin,cycle+
goto main
and cycle0 is?
low pin
Main:
toggle pin
{Test timing here}
goto main
This way you can still monitor the time it takes for a specific function/command to execute by measuring the time from rising edge to rising edge. (<--...or falling to falling as long as you are consistent)
Run this first without {Test timing here} to obtain your "constant value". Remember to divide your results by 2 to get the correct reading after you subtract your "constant value" from the
result with {Test timing here} in place.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.