PC Controlled Robot

In this tutorial we will discuss a simple PC controlled robot. The Robot PC link will be a RS232 serial line. The robot will have only five commands.

  1. Move forward (RS232 char ‘F’ or ‘f’)
  2. Move backward (RS232 char ‘B’ or ‘b’)
  3. Turn Left (RS232 char ‘L’ or ‘l’)
  4. Turn Right (RS232 char ‘R’ or ‘r’)
  5. Stop (RS232 char ‘S’ or ‘s’)

To keep things as simple as possible, in this example we will use terminal software RealTerm for sending commands to the robot. Later on a dedicated software can be written on PC end to control the robot.

The Robot’s Hardware

The robot’s hardware will be a simple differential drive using two 200RPM DC Gear motor mounted on a HQ Metal Chassis with a front castor wheel. On the back motors we have mounted plastic wheels. More about differential drive is explained in this tutorial.

gear motors

Gear Motors

 

wheels

Wheels

 

metal chassis

Metal Chassis

 

remove motors nut

Remove motor’s nut

 

insert the motor

Insert the motor

 

fasten the nut again

Fasten the nuts again

 

both motors installed

Both motors installed

 

the front castor

Front Castor wheel

 

installing the front castor

Installing the front castor

 

mounting hole for wheels screew

Mounting hole for wheels screw

 

Mounting the wheels

Mounting the wheels

 

robots chassis is ready

Chassis is ready!

The Electronics

The robot is controlled using xBoard v2.0 which has ATmega32 as main CPU and integrated motor drivers. We have connected xBoard v2.0 with PC using a CP2102 USB to UART module.

xBoard robot controller

xBoard v2.0

 

xboard back view

Mounting Screws

 

xBoard mounted

xBoard v2.0 mounted on chassis

 

motor connection

Motor connectors

Connect right motor to MOTOR-A Connector and left motor to MOTOR-B.

motor connection

Motors connected

 

fasten the motor wires

Fasten the screws

 

pc controlled robot

Neat ! Isn’t it ?

Download and Burn the Firmware HEX file

Download the firmware hex file from the link given below and program it to the xBoard v2.0 using a USB AVR Programmer. Make sure the fuse bits are set as follows :-

HIGH Fuse = 0xC9

LOW Fuse =0xFF

Setting AVR Fuse Byte

Fig.: Setting the Fuse bytes.

CP2102 Module Connection

cp2102 module

CP2102 Module (USB to TTL)

 

xBoards UART pins

Neat ! Isn’t it ?

Connect one side of CP2102 module to USB and other side to xBoard v2.0 as listed below.

xBoard v2.0 CP2102 Module
RxD TxD
TxD RxD
GND Gnd

other pins of CP2102 are unused.

Notes:

  • Make sure that CP2102 drivers are installed.
  • Jumper JP4 is in Off position (non white side)
  • Jumper JP2 and JP3 are in On position (white side)

Finding the COM port number of CP2102 module.

A PC can have several COM ports, each may have some peripheral connected to it like a Modem. Serial Ports on PC are numbered like COM1, COM2 … COMn etc. You first need to figure out in which COM port you have connected the AVR. Only after you have a correct COM port number you can communicate with the AVR using tools such as Hyperterminal. The steps below shows how to get COM port number in case of Virtual COM Ports.

Right Click on "My Computer" icon in Windows Desktop.

my computer icon

My Computer Icon on Windows Desktop

Select "Properties"

right click on my computer

System Context Menu

The System Properties will open up. Go to the "Hardware" Tab.

System Properties.

In Hardware tab select "Device Manager" button. It will open up device manager.

Open Device Manager

In Device Manager Find the Node "Ports (COM & LPT)"

Expand the PORT node in Device Manager

Depending on whether you are using a "USB to Serial Converter" or "CP2102 USB/USART Bridge Module" you have to find the port with following name.

Note down the COM port number next to the port name. You need to open this Port in Hyperterminal.

com port number

COM Port Number

 

com port number

COM Port Number

Setting Up Real Term

If you are running Windows Vista or Windows 7 then the Hyperterminal Program may not be available. So in place of it you can use Realterm. It can be downloaded from here.

Start Realterm from its Desktop Icon. You will get a screen similar to this.

realterm setup

Real term setup

Go to the "Port" tab and make settings as shown above. Port number is the COM Port number of CP2102 you have found above.

Note:

  • Baud is set to 19200
  • "Open" button is in depressed state.

Now turn on the xBoard v2.0, you will see the following message pops on the terminal.

realterm robot message

Greeting message from robot

Sending command to your robot.

sending command to robot using realterm

Sending commands

  1. Go to the "Send" tab
  2. Enter the command Eg. ‘F’ without the quotes.
  3. Click "Send ASCII" button.

If every thing goes well the robot will respond with message "Forward" (or any other command you gave like "Turn Right") which will be shown on the terminal screen.

Command Acknowledge from Robot

Sending commands

In the same time the robot will start moving forward.

Source Code (Members Only)

[download#1]

Facing problem with your embedded, electronics or robotics project? We are here to help!
Post a help request.

Avinash

Avinash Gupta is solely focused on free and high quality tutorial to make learning embedded system fun !

More Posts - Website

Follow Me:
FacebookLinkedInGoogle Plus

49 thoughts on “PC Controlled Robot

  • By Albin - Reply

    Hello sir
    The concept is amazing. But the connection between the car and PC is still wired. Please change the CP2102 Module (USB to TTL) and use a RF module with serial port. Then the robot can move more than this.

    • By Albin - Reply

      Sir..
      I need to know that whether i can control the robot with PC(wireless).

      • By Avinash -

        Answer to all “can”s are “yes”

  • By skb - Reply

    Sir ..i am making the same thing but in wireless mode…So can u suggest the floating ground connection for it

  • By sudarshan - Reply

    well you ALBIN and SKB you just need to do the following
    connect the tx pin of Microcontroller to the RX of wireless transmitter module and connect the Tx wire of reciever module to Rx of the serial com port in pc or laptop.

    thats it. you can find lots of wireless transmitters, recievers and transcievers online

    • By skb - Reply

      Mr.Sudarshan…thank u very much for sending this useful suggestion..i will try out the same…n if i face any problem i will make a mention of it..thank u sir

      • By assad -

        if want to control Rob via wireless communication then i suggest you to use bluetooth serial module for clear data transmission, connect it to rob and then you can control rob with your laptop built in bluetooth.

  • By skb - Reply

    I want to make this with AT89S52…will it be compatible to work with the above suggestion by Mr.Avinash ??

    • By Avinash - Reply

      @Skb

      Sorry I was born after 1987 so don’t know about AT89S52. Is it some kind of chocolate cake ?

      • By skb -

        @Avinash…ha ha…its Atmel’s 8051 MCU…any changes i need to make?

      • By Avinash -


        Hi skb,

        Please keep this request to jokes only.

        I think you don’t deserve the answer to this question.

        Sorry, but this place is not for ARTs students.

  • By pravallika - Reply

    hi sir
    this is pravallika
    iam also doing the same project but it is controlled by wireless using rf communication

  • By Sumant - Reply

    Hi,
    I suggest to everyone who wants a wireless link should go for Bluetooth module(AUBTM 20)…
    I am recently working on it, it’s easy to configure and the error ratio is ‘eXtreme’ly less ?

    • By assad - Reply

      i m using bluetooth module hc-05(configured as both master and slave) i buy it at 7$ and i m controlling my rob from my laptop

  • By rohan - Reply

    i am making pc controlled wireless robot using atmega128 and bluetooth device as wireless device.
    can u provide me the code for this project.

    • By Avinash - Reply

      @Rohan,

      You are making the robot and I provide the code ??? Why ???

  • By pushkar - Reply

    sir , i am having serious problems with communications in usart , i wanted to ask is it necessary to use an external crystal oscillator for usart or we can do serial communication without external oscillator

    • By MANDEEP TIWARY - Reply

      @Pushkar
      It not necessary to use external crystal.And refer the data sheet to know the error in internal oscillator frequency you using.

  • By nitin - Reply

    full project all parts cost, email me

  • By Vishnu - Reply

    Hi Avinash,
    For the 12V DC motors (the one I have are rated 12V, 300mA), I’m experimenting with battery power. Looks like standard 9V or AA batteries are no good. What kind of batteries you recommend to run the motors. (I have four motors as I’m not using a castor wheel or a dummy motor)

  • By srinath - Reply

    Hi

    U have directly given the .hex file to burn into microcontroller
    can u please post the entire programe like u have posted for other tutorials (basic microcontroller and obstrucle detector)

    • By Avinash - Reply

      @Srinath,

      We are slowly making this site members only. So only privileged member gets the code. Their are several reasons to it. Since you are NOT a member we cannot give code to you.

      • By srinath -

        How can I become a privilaged member?
        registering into your website or should I have to pay some money?

      • By srinath -

        Hi

        I have an account in your website and I have bought a development board and USB to UART Bridge – CP2102 also recently. Still I cant see the programe for PC-controlled robot. How can I download that?

      • By Avinash -

        @Srinath,

        Your order ID please!

      • By Avinash -

        Sorry but its NOT something that could be purchased by money.

        We see the over all behavior of a person, how he/she helps others.

        How he/she helps the company grow.

        We have not much data about you in our community.

        If you have a blog or website that helps spread knowledge then you may be approved instantly!

        If you don’t have (that means a zero contribution to our community) then you may have to wait in queue.

        Bye

      • By srinath -

        my ID in your website is my gmail id only that is
        user name : “naath.sri@gmail.com”

      • By Avinash -

        @Srinath,
        Sorry you do NOT qualify for the membership.

      • By srinath -

        thats what I am asking sir
        How can I become a member?

      • By srinath -

        k fine thank you

  • By Sagar - Reply

    I dont have serial port in my laptop.

    USB to UART Bridge – TTL Signals – CP2102 Based (M2)
    or
    USB to Serial Adaptor

    so which 1 is better?

    • By Avinash - Reply

      @Sagar,

      Both are same just different type of USB Connectors and angle of breakout pins.

      • By Sagar -

        ok

        and thnx.

  • By Carlos Ddodmidnguez - Reply

    I want to buy 10 12V dc 10 rpm geared motors.

  • By sairam - Reply

    hi avinash…..here are my works
    http://www.youtube.com/user/sairamrockzzz/videos
    could i get a membership here….im a arduino based developer..just wanna get dipped in avr!!

  • By shafi - Reply

    i want to be a member

  • By Rushabh - Reply

    please send me the installation program for controller for pc control robot

  • By zaiful - Reply

    how to programming PC Controlled Robot?

  • By Andre-90 - Reply

    pliz provide me the link for downloading the source code

  • By srinivas_pintu - Reply

    can we run a robot using arrow keys in keyboard…

  • By srinivas_pintu - Reply

    I AM RUNNING A PC CONTROL ROBOT USING letters and no.s.. but how to run a robot using arrow keys in keyboard.. i am using UART in atmega8..

    • By malav - Reply

      i need the source code…help

  • By sally - Reply

    please i need the source code

  • By Mohamed Ismail H - Reply

    How should i become a member???

  • By Aniket Kathare - Reply

    Sir, I am a student studying in class 7. Please tell me how to make a car controlled by a wireless keyboard by python progrommaning language. Please tell information on my email is kathareaniket@gmail.com

  • By Vahid - Reply

    hi sir
    i’m a student and beginner in this field
    i try to learn work with microproseccor like AVR chip and i like do some project
    one of this exact same with your project and when search about Open Source Project
    i observed this.
    this is very cute and i want ask from you how i can do some thing like this?

    thanks a lot.

  • By Sherry - Reply

    Sir I Followed the tutorial and got succeed in first attempt, then i watched your RF tutorial (mine RF module is little different from yours) 433MHz. I did the connections from one MCU board to another. But it simply doesnt work, It is continuously receiving garbage. I am facing this problems for 2 weeks and cant find help on web, PLEASE HELP

  • By H123456789a - Reply

    sir, how i will be member of your website?plz tell me, i acutely wish to be member.

Leave a Reply

Your email address will not be published. Required fields are marked *


+ two = 3

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>