USB IR Toy v2
Use a remote control with your computer, view infrared signals on a logic analyzer, or capture and replay remote control buttons. USB Infrared Toy v2 has an improved IR transmitter and several new features.
- NEW: 100mA constant current IR transmitter with improved range
- NEW: Infrared frequency measurement
- NEW: Pin breakout area
- Infrared remote control decoder (RC5)
- Infrared signal logic analyzer
- Capture and replay infrared signals
- USB connection, USB bootloader for easy updates
- Supported in WinLIRC
- Open source (CC-BY-SA)
Read about the design below.
|Name:||USB IR Toy v2|
|Buy it:||Get one for $19.50 at Seeed Studio|
|Forum:||USB IR Toy v2 Forum|
There's lots of interesting infrared projects on the web. Serial port infrared PC remote control decoders have been popular for years, Ian published a USB version at Hack a Day. TheTV-B-Gone is a popular kit that turns most TVs off by transmitting POWER codes with infrared LEDs. The IR Toy combines all these projects into an upgradable USB dongle, with some extra functions, like a simple logic analyzer that visualizes remote control signals.
IR Toy v2 overview:
- USB MINI-B connector
- Indicator LED, blinks on receive and indicates other functions depending on mode
- Infrared transmitter LED
- Infrared demodulator
- Infrared frequency detector
- PIC programming header pins
- Serial UART pins, can be used as a USB->serial converter
- Access to the infrared transmitter and demodulator signals
- Unused pins, including +5volt supply from USB
IR Toy v2 has three updates that were not in the original hardware:
- Transmit range is increased by using a 100mA constant current driver circuit
- Infrared frequency measurement helps to identify remote control protocols, and to clone remotes with odd frequencies
- Extra pins and infrared signals are brought to a breakout area. Extent the IR Toy with extra receivers, transmitters, and other parts
The added cost of new parts, and the increased cost of PIC 18F2550 chips, made v2 about $2 more expensive than v1.
Click for a full size schematic image. Schematic and PCB were designed with the freeware version of Cadsoft Eagle.
The 28pin PIC 18F2550 with USB is back in IR Toy v2. This chip is used in lots of hobby projects that need USB, but it's starting to show its age. 5volt parts like the 18F2550 are increasing in price, while the 3.3volt versions with more features (18F25J50) keep getting cheaper. The PIC18F2550 has gone up about $1 since we started v1, it accounts for about 50% of the price increase in v2.
Everything runs at 5volts, so power is taken directly from the USB port without regulation. A single power supply pin gets a 0.1uF decoupling capacitor (C1). The USB features require a 20MHz external oscillator (Q1, C5, C6).
The chip is initially programmed thorough a 5pin ICSP header. A 10K pull-up resistor (R1) and a diode (D1) on the MCLR pin protect the rest of the circuit from the 13volt signal used during programming.
An indicator LED (I) with 2K current limiting resistor (R2) displays power, USB, and infrared mode status.
The USB transceiver has an internal 3.3volt regulator that requires a 220nF (0.22uF) external capacitor (C2). The extra capacitor footprint to use with 0.1uF capacitors was removed.
We used a USB MINI-B connector (J1). This is a somewhat difficult part to solder, but the final PCBs have slightly extended pads to make it easier.
An infrared demodulator (RX1) decodes infrared remote control transmissions. The demodulator looks for a signal on a carrier wave and decodes it to a clean stream of 1s and 0s. Learn more about infrared modulation and demodulation.
The demodulator connects to a PIC pin with an edge selectable interrupt (RB2/INT2) so we can detect the start of IR activity. RB2 has a Schmidt trigger to 'clean up' a noisy signal. The RX output is also connected to one of the interrupt-on-change pins (RB4) if you want to experiment with a different interrupt type and a TTL pin buffer.
Resistor R3 and 0.22uF capacitor C4 are a small filter for the power supply recommended by the datasheet.
Infrared frequency detector
While 36-38kHz is the most common frequency for remote controls, some operate at 56kHz, or even more exotic frequencies. The new infrared frequency detector (RX2) measures raw infrared signals.
This is different than the demodulator above. The demodulator looks for a signal on a 38kHz carrier wave and decodes it to a clean stream of 1s and 0s. The detector sees the individual transitions of the carrier wave.
The extra sensor data can be used to measure the carrier frequency. It might also be possible to record signals in frequency ranges that don't work with the 38kHz demodulator.
Detector is sensitive, watch out
Working with the detector will show you why remote controls use modulated signals. Any outside noise will degrade the signal quality a lot. A nearby window on a sunny day will activate it. Use it in a dim room and hold the IR source very close (1-2cm) for best results.
Resistor R6 and 0.22uF capacitor C7 are a small filter for the power supply recommended by the datasheet.
An infrared LED or emitter (TX) is used to transmit signals. It's like any other LED, but the color centered around 940nm outside the visible spectrum. The transmitter is connected to a PIC pin with a hardware pulse-width modulator. The PWM makes it easy to create infrared pulses at frequencies visible to IR receivers.
IR Toy v2 uses a new constant current driver circuit to power the LED at high currents. It's way better than the single resistor in the older IR Toy designs. The LEDs get a constant 100mA of current no matter the supply voltage. The USB power supply varies between 4.5 and 5.5volts, the new design ensures maximum current at all voltages.
More importantly, we don't rely on a huge current limiting resistor. Previous designs burned excess current in the typical LED current limiting resistor circuit. The resistor needs a minimum power rating of 0.34watts for 100mA IR LED, way out of the range of common surface mount resistors (<0.125watts). The constant current driver doesn't rely on the current limiting resistor nearly as much. High currents are possible using standard SMD parts, but just in case we used a beefy 1206 resistor.
IR emitters are typically rated for 100mA of continuous power. Most remote control protocols blink the LED rapidly (modulate it) at around 38KHz, so it is actually off half the time. In this setup many LEDs are rated for double the continuous power rating (200mA). Some are also rated for 1A+, but only for tiny pulses at 50% duty cycle.
The IR Toy v2 emitter is limited to the maximum continuous rated current for the IR diode (100mA). Damage is less likely to happen if the transmitter is ever stuck on. It's a development platform after all, so safety first. You can set your own current by replacing R4 with a smaller value resistor.
In the constant current driver design the transistor (T1) collector current (LED side) is equal to emitter current (R4 side). The current is set by R4:
- Emitter current Ie = (Ve-0) / R4
- Ve = Vb - Vbe = (1.4V - 0.7V) = 0.7V
- Vb is the combined Vf of diodes D2 and D3 (see datasheet), typically 0.7V. Vb = Vf_D2 + Vf_D3 = (0.7V + 0.7V) = 1.4V
- Vbe is the Vf the transistor p-n union (see datasheet), typically 0.7V
Solving R4 for 100mA current with a BC818 transistor, and BAS16J diode:
- R4 = Ve/Ie =(((Vf_D2 + Vf_D3)-Vbe)/Ie) = ((1.4V - 0.7V)/100mA) = 7ohms
Resistor power dissipation is well below the 0.125W max of the 1206 resistor used for R4:
- P = Ie * Vbe = (100mA*0.7V) = 0.070W
On the down side we transferred a lot of the current from the resistor to the transistor. The transistor in IR Toy v2 can potentially run hotter than the transistor in v1.
For an IR LED with a forward voltage (Vf) of 1.35 volts the power dissipation is 0.295W, nearly the rated 0.310W of the BC818 transistor in an SOT-23 package. This is probably fine because we're calculating the worst case scenario of a continues 100mA load, IR transmissions are likely to be short and at a 50% duty cycle.
- P =((Vcc-Vf_IRDIODE) - Ve ) * Ie = ((5.0V-1.35V)-0.7V)*100mA = 0.295W
RX puts the transistor in saturation and limits the current through diodes D2 and D3. For 1mA at 5volts:
- R5 = (Vcc - Vb)/I_limit = ((5V-1.4V)/1mA) = 3600ohms
These calculations are also in a spreadsheet in the hardware folder of the project archive. Special thanks to Rafa and rsdio who helped with the constant current circuit.
Unused pins and the main IR signals are brought to a breakout area. Digital and analog pins are available for experimenting.
Infrared demodulator (IRRX) and IR transmitter (IRTX) output are brought to a header.
- Tap these to extend the transmit and/or receive range of the IR Toy with additional modules
The ICSP group is used to program the PIC. Place a jumper between PGC and PGD to trigger the bootloader. This header was flipped in V2 so the PICKIT2's extra pin doesn't interfere with the breakout area.
We used the freeware version of Cadsoft Eagle to make the schematic and PCB.
The PIC 18F2550 has an internal 3.3volt regulator to supply the USB stuff. That regulator must put out a bit of heat because the smallest 18F2550 is in a huge SOIC package.
Passive components were changed to 0603 so the board would stay about the same size as v1, despite several extra parts. 0603 isn't for beginners, but the DO323 diodes are the worst part to solder in our opinion. Neither the PCB nor the diode have much to solder onto.
Click for a full size placement image.
|TX||1||100mA IR LED||LED5MM|
- S1 is a reset button. It is optional and NOT populated on the manufactured version.
IR Toy v2 uses the same firmware a v1
The firmware is written in C and compiled with the free Microchip C18 compiler.
We used the Microchip USB stack to run the 18F2550 as a virtual serial port. Microchip's code is open but not redistributable. If you want to compile the source, download the stack from Microchip, then drag the source code into the install directory. See the detailed instructions in the PIC compiler how-to.
.inf driver installation
The virtual serial port (CDC) is an open standard, it should work on any modern operating system.
You don't need a driver, but you will need a .inf file to tell Windows how to use the device. A suitable .inf is included in the project archive.
IR Toy v2 can be upgraded over USB. It uses the Diolan bootloader, which appears as a USB HID device.
Taking it further
The QSE159 sensor and rising cost of PIC 18F2550 chips increased the price of IR Toy v2 by more than $2. We’ll try to get the cost back down by using a cheaper 3.3volt PIC 18F25J50 in v3.
You can get one for $19.50. Worldwide shipping is only $2.85 more.
Your purchases at Seeed Studio keep the open source project coming, we sincerely appreciate your support!