Skip to main content
Topic: USB IR Toy update (Read 18004 times) previous topic - next topic

Re: USB IR Toy update

Reply #30
With IR frequency detector. I'm going to add the new transmit mode and support for frequency measurement today.
Got a question? Please ask in the forum for the fastest answers.

Re: USB IR Toy update

Reply #31
Frequency measurement works ok, but you have to be really close for a good measurement. I've heard this about other similar designs too. A spreadsheet of measurements is attached.

Here are the firmware changes for the update:
*Version detect using IR detector pullup, universal binary for all hardware versions
*Measure us from first rising edge of IR modulated waveform (raw) to second rising edge (period x2)
*Count total raw IR waveform ticks for a whole sample period

New command 0x04 returns the period*2 measurement and the tick count.
Got a question? Please ask in the forum for the fastest answers.

Re: USB IR Toy update

Reply #32
[quote author="ian"]
*Measure us from first rising edge of IR modulated waveform (raw) to second rising edge (period x2)
*Count total raw IR waveform ticks for a whole sample period

New command 0x04 returns the period*2 measurement and the tick count.
[/quote]Cool stuff!

But I don't understand why rising edge to rising edge would be period x2.  Seems like that would be period x1.  Could you explain?

P.S.  I like the hardware revision auto-detect ... nifty!  Is there any chance that the floating input on rev1 could read as high despite the lack of an external pull-up?  I've had circuits work for a number of revisions until I had to specifically add a pull-down to guarantee that initial logic states were always known.

Re: USB IR Toy update

Reply #33
Quote
But I don't understand why rising edge to rising edge would be period x2.  Seems like that would be period x1.  Could you explain?

I'm probably wrong :) I finished code and posted results really late, I'll pick it up today and figure out what stupid mistakes I made :)

Quote
P.S.  I like the hardware revision auto-detect ... nifty!  Is there any chance that the floating input on rev1 could read as high despite the lack of an external pull-up?  I've had circuits work for a number of revisions until I had to specifically add a pull-down to guarantee that initial logic states were always known.

I have also had this concern, but in practice it works ok. They key is to loop 20+ times and test for the low pin. A floating pin will probably oscillate a bit, but it will most likely hit ground at some point during 20 reads. The same trick was used in the BUs Pirate bootloader v2.
Got a question? Please ask in the forum for the fastest answers.

Re: USB IR Toy update

Reply #34
I was wrong. I thought the special event trigger reset the capture timer, but you need to get the values and subtract to find the actual tick count. I always started on the second interrupt because I though it would have 0 interrupt latency, that's why my times were double what I expected.

The new 0x04 command is this:
H/L - start PIC timer count second rising edge of signal
H/L - PIC timer count third rising edge
H/L - PIC timer count fourth rising edge
H/L - total infrared modulated signal light pulses since last 0xff 0xff (will roll over at 0xffff)

Quote
{00}{F4}{02}{43}{03}{91}{01}{B3}

0x00f4 - start timer count
0x0243 - timer count 1
0x0391 - timer count 2
0x01b3 - total infrared modulated light pulses

PIC timer Period 1 count = 0x0243-0x00f4=0x14F (334)
PIC timer Period 2 count = 0x14E (333)
Total infrared pulse count = 0x01b3 = 435

The PIC has a 12MHz internal clock signal, so the actual time is:

(1/12000000)* PIC timer count = (1/12000000)*334 = 0.0000278333 = +0.20% of the 0.0000277778 actual 36KHz period.

Much better than before, thanks for the note rsdio. Updated test spreadsheet attached.
Got a question? Please ask in the forum for the fastest answers.

Re: USB IR Toy update

Reply #35
Here's another test I tried, not sure which to use. This design uses three LEDs. Two 50degree wide-angle LEDs on the side, and a 25 degree narrow beam LED in the center. Total current in 100mA, could be pushed to 200mA. Using 3 LEDs reduced the wattage of the current limiting resistor required.
Got a question? Please ask in the forum for the fastest answers.

Re: USB IR Toy update

Reply #36
Stacking the LEDs to reduce the resistance makes sense, but how do you fit 3 into 5 V?
I guess the SFH 480 is about 1.2 V at 100 mA, or three would be 3.6 V.
But the SFH 480 will handle 1 A with a 2.5 Vf and 2.5 A with a 3.4 Vf.
Seems like you could get more brightness with a single IR LED if you just boost the current high enough, rather than running 3 of them at a small fraction.  You would need a hefty capacitor to burst more than 500 mA on the USB IR Toy.
Caveat: I haven't tried this.