Friday, January 9, 2009

IR Remote Controlled Car (PWM motor control using ATmega8)



Hi Friends,
in my last post of Simple DC motor Control, I've discussed controlling a small DC motor using the PWM method with MOSFET H-bridge. The circuit was build with microcontroller ATmega8.
Here, I'm extending the same circuit to control the DC motor with IR remote control. The motor is fitted on a toy car wheels with gears, as shown in the figure above.

Following is the schematic (Click on the image to enlarge it):

The circuit uses two PWM channels of ATmega8 for controlling the speed and direction (reverse, forward) of the car, based on the command received from the IR remote. Here, a Sony TV remote was used. The IR codes were received by using TSOP1738 IR detector from Vishay. (Thanks a lot to Michael Spiceland from tinkerish.com, for helping me out with the code for IR signal decoding!).

Following buttons on the remote are used for control:
'1' : Start motor
Volume+ : Increase speed
Volume-: Reduce speed
Channel+: Forward direction
Channel-: Reverse Direction
'0': Stop motor

Check out the video (the LED blinks whenevr a key on the remote is pressed. The remote is not visible in the video as I was holding the camera and remote both!!)
video

The coding is done with ICCAVR compiler. It can be easily adapted to other compilers with minor changes. Complete code is given here:

Download Code


Download datasheet & further info:
TSOP1738 datasheet
Info on Sony remote control codes

Thanks & Regards,
ccd@dharmanitech.com

24 comments:

Michael said...

Do you have a video of it in action?

CC Dharmani said...

I just put it up! check it out.

Arvind Gupta said...

Hello

Did u find a Sony RC encoded remote in India? Coz most of common remotes I came across were NEC format encoded. So I made AVR Interface to them you can check it out here.

http://extremeelectronics.co.in/code-libraries/using-ir-remote-with-avr-mcus-part-ii/

CC Dharmani said...

Hi Arvind,
I've got a Sony TV remote, so I got the codes online for it and tried the code and it worked. So,I think you can get it easily in India. I've not tried other remotes yet, but shortly I'll test them with same code and post the results here.

Thanks for that link, it'll be really useful for many beginners!

Hari Haran.C said...

Hi,
I have doubt in the H-Bridge operation, in your circuit you have connected Q1 and Q4 then Q3 and Q2

and it is very clear for me you are operating High side Cross Low side to operate the Motor, but can you clarify me on the following design where a bridge driver is used and with different configuration

http://hades.mech.northwestern.edu/wiki/index.php/Driving_a_high_current_DC_Motor_using_an_H-bridge

Hari Haran.C

Anonymous said...

Hello sir i just wanted to know whether u can just mail me the hex file of this project..... Please depending on u only coz i cant generate hex file... Email: Prashanth_eng@yahoo.com

Mario Marchese said...

great project! very cool blog

abhilash said...

thanks for such an interesting project... can u plz let me know what is the total cost of the project....

gonio said...

i used diferent sony remote but not worked please tell which Sony TV remote you r used
please give remote or TV modle no.

CC Dharmani said...

Hi,
the Sony TV remote which I used here is: RM-GA002
It is for Sony Triniton TV.

Sunil said...

while going through comments I came to knoe that you hve used same dc motor control ckt for RC car too.But voltage supply is not same in case of motor you r giving 9 v across mosfet.Can it be done with same ckt.

CC Dharmani said...

Yes, you can use the same circuit to drive the motor from VCC, if your motor doesn't need higher power. Make sure that you connect the electrolyte capacitor across the supply, as shown in the circuit, to stop the controller from resetting when motor starts.

Manu said...

Hello Dharmani sir....
can you help me build this remote controlled car project from the scratch - step by step ?
I am a 7th sem B.Tech student and I got to make my final year project...And I think if I am able to make this , I would become a rocking star overnight...
Thank you sir (my ID : manurs87@gmail.com)

Manan Shah said...

Hello Mr Dharmani,
I am working on ATMega128 + H-Bridge + DC motors.

in source code, I saw macros.h and I would like to know get that macros.h
I am still learning about macros.

I am using WinAVR to compile my code.

Thanks in Advance.

TVClassics said...

sorry for grammatical mistake and also I want to past this in other post. but please Help me with macros.h

CC Dharmani said...

Hi,
macros.h is header file specific to ICCAVR compiler. If you are using other compiler, you don't need it, you can simply remove that line from the code.
For example, if you are using winAVR, then including 'avr/io.h' is sufficient.

TVClassics said...

Thanks a lot for replying. That will make my work lot easier.

I am using winAVR.

Chinmay Kulkarni said...

Hi Dharmani sir,
I'm a 4th sem B.Tech student and am making a prototype of a simple wireless rc vehicle. So could you help me with it by explaining this bot you've made in layman's terms? i'm a begineer at robotics, you see.
Thank you.
Chinmay Kulkarni.
chk5391@gmail.com

sandeep said...

can i know voltage tat should be given at vcc..... i'm still new to tis field....

ankit porwal said...

hello
i want do make a wire less remote for robo war ...but i m something new in robotics...
so i require dc remote controlling to drive two or four dc motors....
can u help me for designing the simplest remote controlling for dc motors.....

ankit porwal said...

hello sir
can u provide me the picture of designed pcb connections , used in this car .....

ankit said...

i want to just know that all these motors , used in this car are moving simultaneosly or not ...
can we control the motors one at a time to move the car right or left.....

CC Dharmani said...

Hi Ankit,
these project uses only one motor, so the car can move only in reverse and forward direction. Speed is variable (using remote). If you want to use more that one motor, you need to provide a driver (H-bridge) per motor (and also atlet one PWM channel per motor). Then you can change the speed of motors independently.

Anbazhagan said...

hai

kindly let me know how to connect RF transmitter and receiver instead of IR....do yo have source code for RF tansmitter and receiver.