PULSIN, PULSOUT Questions
imagemedia
Posts: 3
Hey all. I'm about to start into my first Stamp project. I think I've got the basic logic worked out for my application but had a question.
I need to sense very short pulses of light from a source. These pulses do not match any sort of "protocol" - they will very in length between perhaps 100 uS and a few miliseconds. Also, and very important, the time between the pulses may vary quite a bit also. (Not like a square wave from a remote control where pulse frequency can be predicted, one simply varies the length of pulse to make 1's or 0's - in my application, both the pulse itself, as well as the distance between pulses needs to be measured). After measuring, I'll do some logic, then re-transmit another set of pulses based on the logic.
Ideally I'd like to begin re-broadcasting while the string of pulses is still being measured, but if I have to 'capture' a string of pusles and pulse gaps before doing the logic, then it'll have to work.
Looks like the Stamp 1 will do fine as it registeres between 10 uS and over 100 mS.
I looked over the code for PULSIN and my real question.... how do I run a PULSIN to measure a pulse, then imediately after the measurement is completed, start another PULSEIN to measure the resulting gap before the next pulse, then vise versa and so on?
I basically want a string of data that looks something like this:
Pulse ON - 280 uS
Pulse OFF - 750 uS
Pulse ON - 400 uS
Pulse OFF - 20 mS
Pulse ON - 340 uS
Pulse OFF - 900 uS, etc....
Then "Do some logic on the timings and relationships between those on and off times"
Then "Re-broadcast the resulting set via another photo emitter"
Another Stamp will read that broadcast in the same way and do something with it.
So, the really short question - what is the simplest and fastsest possible code to measure both on and off pulses at the same time, and, is the Stamp 1 up to speed enough to do that assuming that is the only function it is running. This is also a power critical application, so I'd like to stick with the lower power Stamp 1 if at all possible.
THANKS!!!!
I need to sense very short pulses of light from a source. These pulses do not match any sort of "protocol" - they will very in length between perhaps 100 uS and a few miliseconds. Also, and very important, the time between the pulses may vary quite a bit also. (Not like a square wave from a remote control where pulse frequency can be predicted, one simply varies the length of pulse to make 1's or 0's - in my application, both the pulse itself, as well as the distance between pulses needs to be measured). After measuring, I'll do some logic, then re-transmit another set of pulses based on the logic.
Ideally I'd like to begin re-broadcasting while the string of pulses is still being measured, but if I have to 'capture' a string of pusles and pulse gaps before doing the logic, then it'll have to work.
Looks like the Stamp 1 will do fine as it registeres between 10 uS and over 100 mS.
I looked over the code for PULSIN and my real question.... how do I run a PULSIN to measure a pulse, then imediately after the measurement is completed, start another PULSEIN to measure the resulting gap before the next pulse, then vise versa and so on?
I basically want a string of data that looks something like this:
Pulse ON - 280 uS
Pulse OFF - 750 uS
Pulse ON - 400 uS
Pulse OFF - 20 mS
Pulse ON - 340 uS
Pulse OFF - 900 uS, etc....
Then "Do some logic on the timings and relationships between those on and off times"
Then "Re-broadcast the resulting set via another photo emitter"
Another Stamp will read that broadcast in the same way and do something with it.
So, the really short question - what is the simplest and fastsest possible code to measure both on and off pulses at the same time, and, is the Stamp 1 up to speed enough to do that assuming that is the only function it is running. This is also a power critical application, so I'd like to stick with the lower power Stamp 1 if at all possible.
THANKS!!!!
Comments
You could use some external logic to effectively delay both pulses by a fixed amount to allow the Stamp to measure both intervals. I suspect it would be easier and more reliable to use a different processor like the SX or Propeller that has an accessible clock. You'd just need to store the time and polarity of each transition and take the difference of the last two to get the pulse width. You could compute their ratios continually or whatever else you needed to do. Both the SX and the Propeller can easily run in low power mode. The Stamps use either a PIC or the SX processor, so that shows what they're capable of power-wise.
Jeff T.
I had a look at both the StampSX and Propeller. That SX looks great, but I think the high current draw (60mA vs. 3mA). Also this will go into a multiple unit project, so the $60 vs. $20 price tag is of issue. The Propeller looks like it may work perfectly, but looks a good bit more complicated to program. I already understand how to make the Stamps work.
It hadn't occured to me to use 2 separate Stamp1's and run them each on different parts of the wave. Both current power requirement and price tag wise, looks like this may be my best option. It'll be a bit more complicated to program, but if that's what it takes "it's just gotta' work". lol.
Thanks!
·
·· Actually the SX being referred to is the SX Microcontroller itself, which can be found at the following link.· Unlike the BASIC Stamp, which has interpreted BASIC, the SX runs a much faster assembly language and can have interrupts and even counters.· You could also realize 75 MIPS of computing power.· Take care.
http://www.parallax.com/sx/index.asp
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support