Friday 17 August 2012

Mobile controlled Robot


We are using mobile phones to do a lot thing like calling, chatting etc. But have u wondered controlling ur bot from ur mobile phone. In this post i will tell u how to build ur own mobile controlled bot.

DTMF tones

The heart of this bot is the DTMF decoder IC. First u must understand what r DTMF tones?.DTMF is Dual Tone Multi-Frequency signalling which is used in telephones. Whenever we press a key in the keypad we will hear a tone. This tone is distinct for each key. These tones are called DTMF tones. Each tone is a combination of two frequencies. The table below gives the frequencies and the corresponding keys.




DTMF decoder

IC8870 is a DTMF decoder. It will decode the DTMF tones and tell us what key is pressed. The output of the ic will reflect the key pressed. For example if you press 2 the output will be “0010”. The circuit diagram for the DTMF decoder circuit is below.



Building the bot

You can use the simple bot as the skeleton. Then program the microcontroller in such a way that if you press 2 the bot should move forward, 8 means reverse, 4 means left and 6 means right. The important thing to note is that you need two mobile phones for this to work. One mobile phone must be attached to the bot via a 3.5mm jack. The other is used as remote. After assembling everything make a call to the mobile attached to the bot. Press the answer button and from the dialed mobile you can control the bot. 

Mobile controlled bot
Here is the video of my bot



Saturday 4 August 2012

PC controlled Robot


Computers have become an integrated part of our life. We use them for almost everything. So i made a bot which can be controlled from a PC or laptop. It uses the USART feature of the microcontroller. It uses serial communication to communicate between the PC/laptop and the microcontroller.

USART

USART is Universal synchronous and asynchronous serial receiver and transmitter. In Atmega8 there are 3 registers used to control the USART and a UDR register to store the transmitted or received data. The control and status register are UCSRA, UCSRB, and UCSRC. I have explained only the necessary information. A detailed description of these registers is available in the datasheet.

 UCSRA
RXC-set if there is any unread data in the buffer and cleared if buffer is empty. Can be used to check whether reception of data is complete or in progress.
TXC-set if the entire data is sent out of the buffer and automatically clear once transmission is complete.
UDRE-if set denotes that the buffer is empty and ready to receive data.
Other bits are not important for beginners.

UCSRB
RXEN-should be set to enable USART receiver to receive data.
TXEN- should be set to enable USART transmitter to transmit data.
UCSZ2- UCSZ2 bits combined with the UCSZ1:0 bit in UCSRC sets the number of data bits in a frame the Receiver and Transmitter use.

UCSRC
URSEL- must be set to enable writing in this register.
UMSEL- selects between Asynchronous and synchronous mode. If set works in synchronous mode and in Asynchronous if cleared.
USBS – selects the no of stop bits. If set use 2 stop bits and 1 stop bit if cleared.
UCSZ1:0 – character size.

UDR
UDR is a data register is where the data to be transmitted is stored temporarily and sent. During reception the received data is written to this register.

USART Initialization

The USART has to be initialized before communication can take place. The initialization process consists of setting the baud rate, setting fame format and enabling the transmitter and receiver. All this can be done by setting the appropriate bits in the USART control and status registers.

Baud rate

Baud rate can be said as a common frequency both the PC and the microcontroller has agreed to communicate with. In reality both the PC and microcontroller would be operating at different so communication between them would be impossible. To enable communication both must agree on a common frequency called the Baud rate. In PC Baud rate is set in terminal program and in microcontroller the Baud rate is calculated using a formula and the value is store in the Baud rate registers UBBRH, UBBRL. An easy way is that the data sheet has the UBBRH, UBBRL values for various frequencies and baud rate which are already calculated so u can use those values directly.   

Frame Formats

The data which is sent from or to the microcontroller is sent in the form of a frame. A frame consists of a start bit which is always low followed by data bits which can vary from 5 to 9 bits in length. Then the parity bits which are used for error checking and it is optional. Finally the stop bit which can be 1 or 2 bits and are always high.
Terminal Program

A terminal program is software which is used to access the serial pot of ur PC. You can send and receive data through this terminal program. Some terminal programs are hyper terminal, teraterm, bary’s terminal. I ham using Bary’s terminal because it is simple and easy to use. In case of a laptop which has no serial port you can use a USB to serial convertor to enable serial communication.

Building the PC control bot.

Now u know how the USART works, let’s build our PC controlled bot. Use the simple bot u built and just add the circuit board to the bot. The circuit consists of a power source a 9v battery, voltage regulator 7805 to provide a constant 5v to the microcontroller and a motor driver L293D or LMD18200 to drive the motors. Get a terminal program and install it in ur PC or laptop. Using the Winavr write the code. These are the steps u should do while writing the code.
  •         Initialize the USART by setting the Baud rate, frame format and enabling transmitter and receiver.
  •        Set any one port as output by setting its DDRx to 0xff.
  •      Check for the received character and provide the corresponding output at the port.

Received character
Output
Motion
w
1010
Forward
s
0101
Reverse
a
0010
Left
d
1000
Right
  •      In the output the first 2 bits from left are for the left motor and the next 2 bits are for the right motor
  •      After writing the code, compile it and create the hex file and burn it into the microcontroller.
  •      Connect the output to a motor driver.
  •       Then connect the bot to ur PC. Open the terminal program and check for connectivity.
  •      If connected send ‘w’ the bot should move forward.
Bot with circuit board on it  

Here is the video of my PC controlled bot.

Friday 3 August 2012

Simple Bot


In our childhood most of have built a toy car with which we use to play around. In this post i will explain the essential technical terms and parts required to building a bot.

Chassis

Chassis is the basic skeleton of ur bot. It houses the motor, wheels, circuits etc. It can be a mica board, thin plywood or even a breadboard. If u want ur bot to be as simple as possible u can use a double sided sello tape to attach the motor to ur bot. If u planned to participate in any completion with ur bot the above method will lead to disaster. U should use clamps to attach the motor by making holes in the chassis at appropriate places.

Actuators/Motor

Actuators or Motor is the one which brings ur bot to life. It provides motion. The important thing to note in selecting a motor is its RPM/speed. There are various speed grades like 60 RPM, 100 RPM and 200 RPM.

Wheels

There are basically two type of wheels used in the bot shown below. A caster wheel which is Omni-directional and capable of moving in all direction-360 degree and two normal wheels. 

Bread Board as chassis

Mica Board as chassis

  
Bread Board and Mica Board as chassis
Caster Wheel
      

Thursday 2 August 2012

Programming the Atmega8


There are many programming environment like AVR studio, Winavr, Codevision to program the Atmega8. I prefer Winavr because it is a open source software and easy to use. C language is used as the programming language. The 23 pins of  ports B,C,D can be used as input or output individually. To specify any port as an input port set the data direction register of that port to 0xff. Similarly for input set the DDR as 0x00.  After writing the C-code, compile it and create a HEX file. This HEX file will be transferred to the microcontroller using a programmer/burner. Winavr can be downloaded here   

Introduction to Atmega8


Atmega8 is a 8 bit AVR RISC-based Microcontroller from Atmel. It is best suitable for beginners. It has 8KB of programmable flash program memory. It’s a 28 pin IC and has 3 ports Port B which is 8 bit, Port C which is 7 bit Port D which is 8 bit. The clock source can be internal or external. Internal clock is a calibrated RC oscillator which can be operated 1,2,4, or 8 MHz. External clock can be a crystal oscillator or any RC oscillator. It has 32 general purpose registers/CPU registers. The pin configuration is shown below. For detailed information refer to the datasheet.  

Atmega8


Pin configuration