More about how to catch pulse edge time
Duke
Posts: 21
Hello,
I'm using BS2P for time and pulse measuring works. I have posted some questions and have good answers but I still have·somes question.
How to write a program that measure the time of an edge, like a signal from button press
IN1··············· Button press
start
Point·········· |
··················
I know that pulsin cannot be use here because it can measure a period of changing High to Low and High again or same by High Level.
Now, I use a loop for measure like this
I=0
Loop:
······ Pause 1
·······I=I+1
······ IF IN1=0 THEN JUMP
GOTO LOOP
JUMP:
······ DEBUG DEG I,CR
By this program I can get the time in unit of 1ms.
Then how can I make a more fine measuring in micro sec
If I erase the line "Pause 1", How to convert the number of "I" to time value
Please help.
Duke..
I'm using BS2P for time and pulse measuring works. I have posted some questions and have good answers but I still have·somes question.
How to write a program that measure the time of an edge, like a signal from button press
IN1··············· Button press
start
Point·········· |
··················
I know that pulsin cannot be use here because it can measure a period of changing High to Low and High again or same by High Level.
Now, I use a loop for measure like this
I=0
Loop:
······ Pause 1
·······I=I+1
······ IF IN1=0 THEN JUMP
GOTO LOOP
JUMP:
······ DEBUG DEG I,CR
By this program I can get the time in unit of 1ms.
Then how can I make a more fine measuring in micro sec
If I erase the line "Pause 1", How to convert the number of "I" to time value
Please help.
Duke..
Comments
I don't really understand what you are achieving with your command -- of what use is knowing how long it is from when you start sampling to when the signal goes low?
In any event, there are tables of how long each command take to occur -- you can look at those and decide what the sample rate is of your code. Personally, I'd connect an output pin to my Ant8 logic analyzer, and read the times directly. You could use a second BS2 to read an output pulse, also.
That's very interesting. where can I find that table ?
The purpose of this program is for finding the initial time that comes from a Photo Interrupter, I want to know
how long does it takes after sending a signal to motor, while the begining position of Photo device cannot be fixed
I really want a program like a stopwatch
When I get the start pulse (not full pulse) I can add this with following pulse measured by pulsin.
The button example is easy so I used it to explain the concept.
Duke..
A table of loop times is here... www.emesys.com/BS2speed.htm but you will have to adjust for the higher speed of the BS2p. Most of the times are for the original non-turbo BS2s. The BS2p is about 20% faster than the BS2sx.
Timing loops:
www.emesys.com/BS2speed.htm#longpulse
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
I'll try RCTIME command.