I'm writing some code to look for a particular 3 pulse IR stream from a track side beacon. The precursor to this project based on a BX24 is described here along with the pulse timing.
http://javalins.wordpress.com/projects/ir-beacon/
For that project we used a Parallax sx processor to front end the decode, but now I am trying to do it on the zx24 using code and lessons learned from AN-204. A friend did the FEP work so this is my first view of it.
My capture code is simply
Call InputCapture (pulses, pulseStreamLength, 0)
with a 50 element array and then I parse the array looking for my sequence. If I see 65535 I know a large value has been captured.
From what I can work out from my timings (taken with a scope) I don't beleive i should see any 65535 value as the beacon output is constant once on.
Should I consider adjusting the Register.TimerSpeed1 value ?
thanks
IR decoding
Re: IR decoding
With the default timer speed, InputCapture() can handle high and low segments as long as 4.44mS. If the specifications of the IR signal allow for a longer pulse width than that, you'll need to use a different prescaler value.FFMan wrote:Should I consider adjusting the Register.TimerSpeed1 value ?
- Don Kinzer
Re: IR decoding
The time between each 3-pulse burst (in the center of your included screen capture) is about 6mS which is nearly 50% greater than the 4.4mS max.FFMan wrote:From what I can work out from my timings (taken with a scope) I don't beleive i should see any 65535 value as the beacon output is constant once on.
Re: IR decoding
The values for Register.TimerSpeed1 are the timer prescaler selector values. In general, you'll need to consult the datasheet for the AVR upon which the particular ZX device you're using is based to find the mapping from selector values to prescaler values. For most ZX devices, the value of 2 for Register.TimerSpeed1 selects a divide-by-8 prescaler, giving you eight times the range at one eighth the resolution. Each unit of the input capture value will represent about 542nS and the maximum value of 65533 will thus represent 35.5mS (with the CPU frequency of 14.7456MHz).dlh wrote:The time between each 3-pulse burst is about 6mS [...]
Be aware, however, that setting Register.TimerSpeed1 affects other time-based routines, too. See the table in the System Library Reference Manual.
- Don Kinzer
The answer depends on the largest time you need to capture. Using a prescaler of 1, InputCapture() on the ZX-328L can log high and low times up to 8.8mS in length. If the maximum you need is the 6.6mS discussed recently then the default prescaler would work fine. As always, it's a trade-off between range and resolution.FFMan wrote:My current value on 14mhz is 2, should i put this to the default of 1 using compiler directives for the 328l ?
- Don Kinzer