Wednesday, 16 October 2013

ARDUINO based Quadruped robot using 2 servos

I all ways wanted to make a quadruped robot. And finally got a chance to make one. So i wanted to simplify the design with least possible hardware.

working video

I checked in the market to get good servos and found these VS-2 servos. These servos provide up to
 3Kg-cm torque.

To control the servos i wanted to use ARDUINO. I got Arduino mega with me. But that board is little heavy and my robot cant bare it. So tried for arduino uno or nano. I'm not able to find one in the Indian market and the cost is going beyond the budget. So i thought of making my own Arduino. 

 This board consists of an ATmega8 microcontroller working at 16Mhz and almost all the pins are exposed in this board and each and every pin is associated with  supply and ground pins.

 To load the arduino sketch into this board i made a sketch loader for it. In traditional Arduino boards FTDT chips(FT232) are  used. It is a USB  to serial devise. I googled about and found a similar chip which is a little cheaper in my local market called CP2102 from silicon lcbs.




In this circuit diagram i didn't showed the Power supply for Arduino. if you are using any standard Arduino you have to use a separate 9v supply for your Arduino board. In this project i used an ATmega8L microcontroller(operates from 3.3V to 5V) with Arduino boot-loader. So i used a common power supply for both Board and Motors.
NOTE: if you are using a common supply the circuit may get reset continuously due to more load of motors. To overcome this problem i used 2x1000uF capacitors accross Vcc and Gnd 


#include <Servo.h>

Servo mot1;
Servo mot2;

void setup( )
  mot1.attach(9); // servo one to  digital pin 9 of arduino
  mot2.attach(10);// servo two to digital pin  10 of arduino

void loop( )




Sunday, 13 October 2013

Analog 3-Axis Accelerometer interfacing with ATmega8 board

Every body is having a smart phone. The vary first game that you will look for is "TEMPLE RUN".
This game became favorite of many.

In the above situation how the player bends side?

I know what you will say "we tilt the smart phone left".

the question is how your mobile is able to sense the tilt. Here comes the concept of a small devise called


 what is this thing?????????

It is a Micro Electro Mechanical device. For short MEMS.

How the accelerometer work?
when ever you tilt the accelerometer at any axis the module of the corresponding axis will sense the change in "g"(acceleration due to gravity) and produces a corresponding change in the terms of analog voltage. 

Now we are going to use an accelerometer to control the robot. This technique helps a physically challenged person to control the wheel chair with their hand gesture .
As shown in the above figure this sensor module is available at many models from different vendors. But the basic connection are same for all ADXL335 modules.

Actually this sensor module comes with an internal 3.3V voltage regulator. then you can directly use a 5V supply. otherwise you have to go for 3.3V supply. 

These X Y Z pins are the analog outputs from the sensor. As the device internally works at 3.3V the maximum voltage produced at these pins will be 3.3V

As we know that our microcontroller is digital and it cannot process the analog data directly. We need to convert the analog data into digital. An A/D converter is required for this process.

In this tutorial We are going to use an AVR microcontroller (ATmega8) based platform which is having an in built ADC mechanism in it.

This board was developed by ROBOGENESIS.
The specialty of the board is "NO EXTERNAL PROGRAMMER IS REQUIRED" .
It can be programmed through USB port.
comes along with a special library so any one can program the board.
Also compatible with ARDUINO programming.
For more info about This board mail us at :
This board comes with a CD that include the necessary libraries for all the modules compatible with this microcontroller hardware.

So in this project we are going to use "adc.h" header file
which helps in using the ADC port of this board.

to check the ADC values at the respective levels we are going to interface an LCD too..
this will help us in calibrating the ADC data from the accelerometer.
to support the LCD port the "lcd.h" header file can be used.

connect the sensor X,Y,Z axis outputs to the ADC0, ADC1, ADC2 channels respectively

#include<avr/io.h>                    //  I/O port definitions 
#define F_CPU 12000000UL  // frequency of the board
#include<util/delay.h>              // headder file for delay functions
#include"lcd.h"                        // LCD headder file
#include"adc.h"                       // ADC headder file
void main()
 lcd_init();   // initializing LCD
 adc_init();   // initializing ADC
 lcd_string("working"); // displays "working" on first row of LCD
 _delay_ms(1200);      // delay of 1.2seconds
 lcd_clear();               // LCD display cleared
lcd_cursor(0,0);         // setting cursor to row 0 column 0 position
 lcd_string("  X    Y    Z    "); // display on row 0
 unsigned char x,y,z; // variables
  x=getdata(0x00);  //reading data from ADC0 storing in variable x
  y=getdata(0x01);  //reading data from ADC1 storing in variable y
  z=getdata(0x02);  //reading data from ADC2 storing in variable z
  lcd_cursor(1,0);  // setting cursor to row 1 colums 0 position
  lcd_num(x);       //displays the value of x
  lcd_cursor(1,5);  // setting cursor to row 1 colums 5 position
  lcd_num(y);        //displays the value of y
  lcd_cursor(1,10);// setting cursor to row 1 colums 10 position
  lcd_num(z);        //displays the value of z