My First PCB Board

I’ve shared some videos on here talking about my infrared remote control that I built using Arduino Uno so that I could operate my TV and other devices with dozens of functions using only for pushbuttons. The device relies on a tiny circuit that has an infrared LED, a transistor, a resistor, an infrared receiver. The one that I’ve been using was thrown together on a little piece of perf-board that looks like this.

Homemade IR Transceiver Module

Homemade IR Transceiver Module

However sometimes the unit isn’t pointed in exactly the right direction the signal doesn’t get through. I needed something that was wider angle and perhaps more powerful. They make IR LEDs in either narrow angle or wide-angle versions. Perhaps if I had one of each or even to have each I would get the power I needed. There’s little gadget called a TV-B-Gone that is a battery-powered device with four IR LEDs and a pushbutton. When you push the button it will shut off any TV of any brand. People use it as a joke to walk into a place like a sports bar, electronic store, fitness center etc. and slyly turn off every TV in the place. I thought if I studied the output portion of the circuitry for that device maybe I could build my own little board that just did the transmitting and add my receiver to it.

Because I don’t know a lot about transistor circuit design I thought I would go to the discussion forums of my favorite parts place adafruit.com where they have an entire forum dedicated to TV-B-Gone and similar devices. They were very helpful in teaching me some basic circuit design skills and in advising me on this project. You can read the discussions here and here.

Here is another prototype version of my circuit using two LEDs. It’s based on information I learned from the people in the Adafruit forum. I call it my “IRIO Board” (Infra-Red Input/Output)

Prototype of My 2 LED IRIO Circuit

Prototype of My 2 LED IRIO Circuit

Part of the reason I wanted to redesign this little circuit was to try out a program called Eagle CAD from a company called CAD soft. It is available at http://www.cadsoftusa.com/ Is an expensive professional design program but there is a free version that will let you design small boards and certainly this one was small enough.

It gives you an extensive library of parts that you can use and there are ways to design parts of your own if you’re using a part that isn’t in the library. You basically do the design work on two different screens. On one of them you layout the schematic by dropping the pieces onto the screen, dragging them around with your mouse, and then connecting them together with wires. You then switch over to the circuit board portion of the program and arrange the components in the way you want them. On the circuit board side of the program, the components are already connected together with little rubber band like wires that stretch as you move the pieces around. There is a function called “rats nest” which helps you untangle the wires. Then you actually draw the traces to connect various parts together replacing the temporary rubber band wires with actual traces. In the free version you can only do a two player board top and bottom. The professional version allows you to do multiple layers. Two layers was going to be more than enough for me.

Here is the schematic that I designed. It has an NPN transistor driving up to 4 PNP transistors. Each of them in turn drives an IR LED. There is a 1k ohm that connects the NPN transistor to your Arduino board pin 3. There is also a place to put the IR receiver. In the schematic shown there are actually two IR receivers because I wanted to be able to mount the device pointing in different directions.

My IRIO Schematic from Eagle CAD

My IRIO Schematic from Eagle CAD

Here is a capture of what the circuit board screen looks like after I have arrange the pieces and put them in place. The red traces are on the top of the board. The blue traces are on the bottom layer. For those of you who are not familiar with it, the logo in the lower right corner is the “Open Source Hardware” logo. The four holes at the bottom are place to connect power, ground, input and output wires. There are a variety of ways you can put the IR receiver in the upper right corner.

My IRIO Board Layout in Eagle CAD

My IRIO Board Layout in Eagle CAD

The white dotted lines show where you could cut off the left side of the board if you only wanted to use 2 LEDs instead of all four.

Now what to do with it? There are a variety of services which will take your Eagle CAD files and actually create the circuit board for you. If you tried to deal with a board manufacturer directly it would be very expensive. But there are services which take designs from a variety of hobbyists like myself, put all the little boards together on one big board, and ship it off to a manufacturer to be produced. They then take the big board, cut it apart, and ship it out to the hobbyists. I decided to use one such service called BatchPCB.com. You pay for the boards by the square inch plus a setup fee and shipping. My boards were under $5 each. I ordered three of them in with the other fees it was about $27. I placed the order on March 2 and it arrived yesterday on March 26. Here are front and back images of my professionally produced PCB board then I designed myself.

My IRIO Board (front)

My IRIO Board (front)

batchpcb_first_bottom

MyMy IRIO Board (back)

And finally… Here is what it looks like assembled. I tried it out and it works perfectly.

Assembled IRIO Board

Assembled IRIO Board

This circuit however takes advantage of the fact that we are only sending brief pulses intermittently. We’re actually pushing more current through the devices then they are designed to take. One of the things I hope to do with this is to control an IR remote controlled toy helicopter. When pretty sure I will need to transmit signals continuously. So I designed another version of the board was some 33 ohm resistors to cut down on the current. Also when powering the Arduino from a PC USB port it draws too much current. It works okay on battery power or a USB charger but not directly on a PC.

I’ve submitted my new design to BatchPCB.com and hope to have it back in a couple of weeks. Here is a link to my updated board. It has not been tested on a real board but I did prototype it and it seems to work fine. I will post more information here when it comes. I also intend to write a tutorial on how to use this board with my IRLib Library for Arduino which you can read about here.

IRLib Tutorial part 1: Hardware set up

This is the first in series of articles on using my infrared remote library for Arduino. In this installment we’re going to show you how to set up the hardware and how to run a quick demo sketch. You can find out more about the library on my IRLib page.

In order to detect a single from IR remote control such as you might use for your TV or home entertainment system you need an IR receiver module. Typically I use a unit I get from Radio Shack. You can also buy a similar module from my favorite supplier Adafruit.com. See the links at the end of this post for places where you can buy all of the parts mentioned in this article.

Pin 1 (on the left as you looking at the lens) needs to be connected to a input pin of the Arduino. It can be any could be any pin that doesn’t conflict with anything else you’re doing with the device. All of the examples in the library assume you are connected to pin 11 so we suggest you use it. The center pin 2 connects to ground any right-hand pin 3 should connect to your +5V power supply. If you are using a different microcontroller that runs at +3V this device will work at that voltage.

The simplest output device is simply an infrared LED and a current limiting resistor. IR LEDs can be purchased from a variety of places. Again see the links at the bottom of this post for sources. You are limited to using PWM pins for output because we use the PWM feature to modulate the signal. The default pin to use on Arduino Uno or other ATmega328-based controllers is pin 3. This particular pin is connected to “timer 2” of the chip. However the Arduino Leonardo and other controllers based on the ATmega32u4 does not have a “timer 2”. On these devices the default is to use timer 1 and pin 9 for output. We will talk more later about other options for timers and how to use this library on other types of hardware. For now all you need to know is if you have an Uno you should use pin 3 or a Leonardo use pin 11. Connect a 100 ohm resistor in series with the LED. Make sure you get the polarity of the LED correct. The shorter of the two leads should connect to ground. The longer lead connects to the resistor which in turn connects to the Arduino. Here is a schematic for the simplest setup. Note this post was edited on 2/5/2014 to correct the polarity. After telling you to be sure to get it right, I had described it wrong. The schematic has always been correct but my description was wrong. Sorry about that.

Simple IR I/O Schematic

Simple IR I/O Schematic

That was the absolute simplest schematic however the output from the IR LED will be pretty weak because the output pins of Arduino cannot supply much current. You might want to consider adding an NPN transistor to drive the LED.

NPN Transistor Driving IR LED

NPN Transistor Driving IR LED

Here is a schematic using a PN2222 NPN transistor and a 470 ohm base resistor with the LED. WARNING: This circuit will drive the LED beyond its continuous current limits of 100 mA. However because we are only pulsing the LED for a brief period using a modulated signal we can get away with this. So you should only use the circuit if you are certain that the output pin is not going to be left on continuously for more than a fraction of a second.

Here is a simple sketch you can use to test if you are receiving IR signals. Is a stripped down version of the example sketch “IRrecvDump” that is in the examples subdirectory of the library.

/* Receiving IR signal and dump the details */
#include
//create a receiver object
IRrecv My_Receiver(11);//Use input pin 11

//create a decoder object
IRdecode My_Decoder;
void setup()
{
Serial.begin(9600);//We will read the output on the serial monitor
My_Receiver.enableIRIn(); // Start the receiver
}
void loop() {
//Loop until we get a signal and pass it to the decoder
if (My_Receiver.GetResults(&My_Decoder)) {
My_Decoder.decode();//decode the signal
My_Decoder.DumpResults();//dump the results on the serial monitor
My_Receiver.resume(); //restart the receiver
}
}

Upload the sketch and start the serial monitor on the Arduino IDE. Point a remote control such as a TV remote at the receiver and press a button. It will dump the information about the signal received. If it’s a protocol with the library understands it will tell you which protocol and it will give you a hex number of up to 32 bits that is the code for that particular function.

To test your transmitter, first determine the 32 bit hex code and protocol that the library can decode. A good example would be the power off/on button of your device assuming that your protocol is supported. As an example I sent a power signal to my Sony DVD player. The dump program tells me that it is a 20 bit code that is Sony protocol and that the value is 0xa8bca. The following sketch is a version of the example “IRsendDemo” in the examples directory of the library.

/*Transmit a power code for Sony DVD*/
#include

IRsend My_Sender;
void setup()
{
Serial.begin(9600);
}
void loop() {
if (Serial.read() != -1) {
//send a code every time a character is
//received from the serial port
//Sony DVD power A8BCA
My_Sender.send(SONY,0xa8bca, 20);
}
}

You will need to substitute the protocol name, the hexadecimal code, and the number of bits for whatever device you are operating. After you upload the sketch type a character into the serial monitor and press enter. Every time you transmit a character from the serial monitor, it will transmit the code you have programmed into the “My_Sender.send(…)” Function call.

In the installments which follow we will explain more of the details of the library including a more advanced circuit for transmitting codes. However for now this should get you up and running.

As promised here are some links to the hardware mentioned in this post

In the next installment will show how to receive and decode IR signals and use them to do something useful such as control a servo.

Yet Another Show-and-Tell

Here the show-and-tell with Adafruit industries where I showed off a little circuit board I designed and some ray traced renderings of what the board will look like when it’s complete.

Adafruit Show-and-Tell sticker I earned for this presentation.

Adafruit Show-and-Tell sticker I earned for this presentation.