loading
Picture of IR Remote Control of PICAXE Micro
PICAXE IR Receiver.jpg
2011 086.jpg
2011 087.jpg
2011 089.jpg
2011 090.jpg
The purpose of this blog is to show how to interface an IR remote control to a PICAXE-18M2 processor for robotics or automation. Universal remotes are cheap (what household doesn't have a few of them?) The code is very simple. I plan on using this to control a little robotic tank.
 
Remove these adsRemove these ads by Signing Up

Step 1: PICAXE Brain and H-Bridge Brawn

Picture of PICAXE Brain and H-Bridge Brawn
A IR receiver module may be had for under $2. TV sets, DVD players and cable boxes all use this device to receive commands from their hand-held remote controls. Its output signal can go into any of the PIC's I/O ports (I chose B.2). The PIC has a function called "irin" that receives the code and stores it in a variable (b0). Using the debug mode on my programming software, I was able to push buttons on the remote control and see the codes being stored in b0. From that I was able to map the remote. It turned out that there were 53 codes between 0 and 52, a unique number for each button on the remote.

Step 2: Remote Decoded

Picture of Remote Decoded
Over the last 50 years, television manufacturers have come up with about a thousand different coding schemes for IR remote controls. The PICAXE-18M2 has built-in encryption for Sony. I set up the universal remote pictured below by depressing the "SETUP" button until it remained red, and entered the code "0152" from their user's guide. Every remote will be different, but any universal can emulate a Sony remote control. Note that on the numeric keypad, the number 1 is received as a zero, 2 as 1, and so forth.

Step 3: Servo, LED and Gear-Head Motor Demo

Picture of Servo, LED and Gear-Head Motor Demo
To demonstrate the capabilities of this circuit, I hooked up a servo, LED and gear-head motor to the breadboard. The PICAXE chip has 2 PWM generators, available on ports B.3 and B.6 (I chose B.3). The signal input to the servo is connected to this port via a 330 ohm resistor. The LED was wired to be driven by port B.4 (high for on). To drive the gear-head motor, the quad H-Bridge driver chip had to be used due to the current demand. It also has the feature of being able to reverse polarity (and direction) of the motor via 2 logic lines from the PIC (B.6 and B.7). If one is high and the other low, we get CW, one low and the other high, CCW, both low, the motor stops.

Step 4: Circuit Diagram

Picture of Circuit Diagram
The PICAXE basic code is easy: the main loop keeps looking for a signal from the IR receiver via the "irin" command. When it gets a code, it places in in variable b0. Then that variable is tested with a series of "if...then" statements. If the condition is true, a subroutine is evoked, then the program returns to the main loop.

;IR Receiver Test Circuit
;for PICAXE-18M2
;James Dinsmore 7/01/2011


init: servo 3,140 ; initialise servo
main:



irin [1000,main],B.2,b0 ;wait for new signal
;debug

if b0=16 then motorfwd
if b0=17 then motorbkwd
if b0=20 then stopmotor
if b0=21 then lightLED
if b0=24 then extinguishLED
if b0=19 then servoleft
if b0=18 then servoright
if b0=26 then servomiddle


goto main


;subroutines


motorfwd: high B.7
low B.6
goto main


motorbkwd: low B.7
high B.6
goto main


stopmotor: low B.7
low B.6
goto main


lightLED: high B.4
goto main


extinguishLED: low B.4
goto main


servoleft: servopos 3,200
goto main


servoright: servopos 3,80
goto main



servomiddle: servopos 3,140
goto main




Step 5: Video of the Demo

Picture of Video of the Demo

Step 6: Parts List

Picture of Parts List

Parts list
[Link]

Code
[Link]

Circuit Drawing
[Link]

My other stuff
[Link]

Other pins may be used for sensor input

saljuarez1 year ago
SALJUAREZ
HI. I´M A 75 Y.O. NEW ELECTRONIC HOBBIST, I TRIED TO FOLLOW YOUR INSTRUCTIONS BUT I DON´T GET ANY RESPONSE FROM THE R.C. ACTUALLY SOME TIMES THE LED FROM PIN 10 LITS BY ITSELF WITHOUT PRESSING ANY BUTTOM AND OTHER TIMS IT COMES ON ONLY BY TOUCHING ITS RESISTOR.
IS THERE A REASON FOR THIS???.
ALSO IS TEHERE ANY WAY OF TESTING IF THE MODULE IS RECEIVING ANY SIGNAL (RIGHT OR WRONG) FROM THE R.C.???
I LIKE VERY MUCH YOUR INSTRUCTABLE IT IS VERY EXPLICIT, UNFORTUNATLY I´M AFRAID I´M DOING SOMETHIN WRONG.
I´L APPRECIATE YOUR HELP..
REGARDS.
jamesthequack (author)  saljuarez1 year ago
Whihc PICAXE chip are you using? (08M2, 18M2, etc.) What are you using to power your project? Is it a good, clean 3 to 5V? I have heard that the coding is different in Europe than in America; where are you geographically? You might try adding a few capacitors across your voltage supply to ground to take care of any stray noise that might be glitching the circuit. Try this code and watch the PICAXE monitor while pressing the remote's buttons:

;IR Receiver Test Circuit
;for PICAXE-18M2
;James Dinsmore 7/01/2011


init: servo 3,140 ; initialise servo
main:

irin [1000,main],B.2,b0 ;wait for new signal
;debug

if b0=16 then motorfwd
if b0=17 then motorbkwd
if b0=20 then stopmotor
if b0=21 then lightLED
if b0=24 then extinguishLED
if b0=19 then servoleft
if b0=18 then servoright
if b0=26 then servomiddle


goto main


;subroutines


motorfwd: high B.7
low B.6
goto main


motorbkwd: low B.7
high B.6
goto main


stopmotor: low B.7
low B.6
goto main


lightLED: high B.4
goto main


extinguishLED: low B.4
goto main


servoleft: servopos 3,200
goto main


servoright: servopos 3,80
goto main



servomiddle: servopos 3,140
goto main



HI. James i´m sorry i did not answer you before.
I´m in Mexico city, and i must tell you taht Ithe next day i sent my comment to you fixed a wron connection and it worked perfectly now I have the program and hardware working O.K. I tested it with leds and it works perfect, now what I can not do is have the motors work, I tried with an ULN 2803 IC but I dont get any response probably I´m doing somethig wrong again, as I told you I´m new at this, any how if you have any advise I will appreciate it..
regards .
SAL.
is it possible to insert a 555 timer in the receiver circuit in order to control the robot or actuator from the sony remote control by a delay mechanism? So instead of the robot instantaneously responding to the sony remote control, it responds 10 seconds, 50 seconds or what ever amount of time you want it to respond.
lemaxnut2 years ago
I have been "playing" with PICAXE for about a year but I have never come across anyone who explains BASIC code and the IR function as clearly and succinctly as you have. I love all your projects !
Thanks for sharing.
jamesthequack (author)  lemaxnut2 years ago
You are very welcome! Thank you for the encouragement. My most recent material resides on http://jmd.dev4.webenabled.net/
They have recently upgraded the PICAXE-18M2+ to include an internal temperature sensor; I am looking forward to playing with it soon.

James
ageorge152 years ago
sir, how did you make the PICAXE serial programming adapter and where did you get the software
jamesthequack (author)  ageorge152 years ago
Also, the SW is freely available from http://www.picaxe.com/Getting-Started/Software-Selection/
jamesthequack (author)  ageorge152 years ago

Page 44 of the Picaxe Manual 1 found at http://www.picaxe.com/Getting-Started/PICAXE-Manuals/ shows how to build the serial programming circuit. You can also purchase one from SparkFun at https://www.sparkfun.com/products/8313 . One catch is that newer computers may not have a D-9 serial port, in which case you woould have to get the more expensive USB programmer https://www.sparkfun.com/products/8312
James

http://www.picaxe.com/
link error