USB IR Toy v2
From DP
| Project Summary | |
|---|---|
| Name: | USB IR Toy v2 |
| Buy it: | Get one for $19.50 at Seeed Studio |
| Price: | $19.50 |
| Status: | Test production |
| Manufacturing: | Shipping |
| Forum: | USB IR Toy v2 Forum |
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.
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.
Contents |
Overview
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. The TV-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 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
IR Toy v2 parts:
- 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
Hardware
Click for a full size schematic image. Schematic and PCB were designed with the freeware version of Cadsoft Eagle.
Microcontroller
- Microcontroller
- Power and decoupling
- Oscillator
- Programming and reset support
- LEDs
The Design is based on a 28pin PIC 18F2550 with USB. This chip is used in lots of hobby projects that need USB.
It runs at 5volts, so power is taken directly from the USB port without regulation. This 28pin chip has a single power supply pin that 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) displays power, USB, and infrared mode status. The UART pins are exposed for debugging, and could be re-purposed as a serial port or general purpose IO.
The USB transceiver has an internal 3.3volt regulator that requires a 220nF (0.22uF) external capacitor. We always use two 0.1uF capacitors instead because they're so common. You could use a single 0.22uF capacitor in C3 and omit C2, as the manufactured version does.
We used a USB MINI-B connector (J1). This is a somewhat difficult part to solder. We initially tried a PCB-edge connector, but normal circuit boards aren't thick enough for solid contact.
Infrared demodulator
An infrared receiver (RX) detects infrared remote control transmissions. We used a receiver centered at 38kHz, but it will work over a large range of frequencies that includes 56kHz.
The receiver 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.
Infrared frequency detector
- This new part in v2 adds the ability to measure the raw frequency of the signal
- Most Remote controls are at 36-38KHz and work with the demodulator, but some are 56KHz and others.
- Now can measure and even clone remotes that don't work with the demodulator
- Very sensitive - hold RC very close (1-2cm) for best results. Sunlight from a window can mess up the reading.
Infrared transmitter
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 transistor in the older IR Toy designs:
- Constant 100mA of current powers the LED 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.
- 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 from a 5volt supply, 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, so high currents are possible using standard SMD parts.
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. We designed the IR Toy v2 emitter to use the maximum continuous rated current so damage is less likely to happen if the transmitter is ever stuck on.
Transistor T1 switches the LED on and off. In the constant current driver design the T1 collector current (LED side) is equal to emitter current (R4 side). The current is set by R4:
- Emitter current is defined by Ie = (Ve-0) / R4
- Ve = Vb - Vbe = (1.4V - 0.7V) = 0.7V
- Vb is the combined Vf (see datasheet) of diodes D2 and D3, 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
- Ve = Vb - Vbe = (1.4V - 0.7V) = 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:
- RX = (Vcc - Vb)/I_limit = ((5V-1.4V)/1mA) = 3600ohms
Special thanks to XXXX for design help with the constant current circuit.
Breakout area
- unused and main IR signals are broken out to a pin header.
PCB
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.
Partslist
Click for a full size placement image.
| Part | Quantity | Value | Package |
|---|---|---|---|
| C1 | 1 | 0.1uF | C603 |
| C2,C4,C7 | 3 | 0.22uF | C603 |
| C5,C6 | 2 | 27pF | C603 |
| C8 | 1 | 1.0uF | C603 |
| D1 | 1 | BAS16J | SOD2514X100N |
| D2,D3 | 2 | BAS16J | DO323 |
| I | 1 | LED | CHIP-LED0805 |
| IC1 | 1 | PIC18F2550_28W | SO28W |
| J1 | 1 | CON-USB-MINI-BUSB1 | CONN_USB_MINI-B |
| Q1 | 1 | 20Mhz | HC49UP |
| R1 | 1 | 10K | R603 |
| R2 | 1 | 2K7 | R603 |
| R3,R6 | 2 | 390R | R603 |
| R4 | 1 | 6R8 | M1206 |
| R5 | 1 | 3K6 | R603 |
| RX | 1 | TSOP34838 | TSOP18XX |
| RX2 | 1 | QSE159 | QSE15X |
| S1 | 1 | SMD_TACT_SMALL | TACT_SWITCH_SMALL |
| T1 | 1 | BC81840MTF | SOT23-BEC |
| TX | 1 | 100mA IR LED | LED5MM |
- S1 is a reset button. It is optional and NOT populated on the manufactured version.
Firmware
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.
Bootloader
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.
Firmware updates are posted on the blog. You can also join the discussion in the forum.
Get one!
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!
Links
License
- Hardware:CC-BY-SA
- Firmware:CC-BY-SA
- Bootloader:GPL





