USB IR Toy v2

From DP

Revision as of 08:33, 28 April 2011 by Ian (Talk | contribs)
Jump to: navigation , search
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
Overview-rcentered.jpg

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)

Get IR Toy v2 for $19.50.

Read about the design below.

Contents

Overview

Irtoyv2overview.png

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:

  1. USB MINI-B connector
  2. Indicator LED, blinks on receive and indicates other functions depending on mode
  3. Infrared transmitter LED
  4. Infrared demodulator
  5. Infrared frequency detector
  6. PIC programming header pins
  7. Serial UART pins, can be used as a USB->serial converter
  8. Access to the infrared transmitter and demodulator signals
  9. Unused pins, including +5volt supply from USB

Hardware

Cct-USB-IRToy-vii.png

Click for a full size schematic image. Schematic and PCB were designed with the freeware version of Cadsoft Eagle.

Microcontroller

Irtoy-v2-microcontroller.jpg

  • 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

Usbirtoy-v2-demodulator.jpg

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

Usbirtoy-v2-detector.jpg

  • 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

Usbirtoy-v2-transmitter-ii.jpg

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

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

Usbirtoy-v2-breakout.png

  • unused and main IR signals are broken out to a pin header.

PCB

Irtoy-v2-pcb.jpg

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

Pcb-usb-irtoy-v2-ii.png

Click for a full size placement image.

partlist
PartQuantityValuePackage
C110.1uFC603
C2,C4,C730.22uFC603
C5,C6227pFC603
C811.0uFC603
D11BAS16JSOD2514X100N
D2,D32BAS16JDO323
I1LEDCHIP-LED0805
IC11PIC18F2550_28WSO28W
J11CON-USB-MINI-BUSB1CONN_USB_MINI-B
Q1120MhzHC49UP
R1110KR603
R212K7R603
R3,R62390RR603
R416R8M1206
R513K6R603
RX1TSOP34838TSOP18XX
RX21QSE159QSE15X
S11SMD_TACT_SMALLTACT_SWITCH_SMALL
T11BC81840MTFSOT23-BEC
TX1100mA IR LEDLED5MM
  • 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