Introduction of Robotics

Here Sachin Maurya a mechanical Engineer shares his ideas about ROBOTICS

Subscribe To
Robot Images

Other things
Other things
Wednesday, January 16, 2008
Software For Robot
Interactive C:
The development tool for the used for The Handy Board is called Interactive C (IC). IC is basically consist of two parts, a pseudo-code (pcode) machine language module and the interface/compiler portion (IC program).
IC compiles into pseudo-code (p-code) which is then executed by a custom stack machine. The p-code is interpreted by a run-time machines language program store in the 6811 MPU. This unique approach was taken because it allows IC to have run-time error check, small object code, source code portability and finally the most useful and powerful feature, multi tasking. The only drawback is at the expense of slower execution speed. However, this should not be a problem with most applications.

IC supports a subset of C, it includes:
Control structure; for, while, if, else
Local, global variables
Arrays, Pointers
16, 32 bits integers
32 bits floating point numbers
Here is a block diagram of how IC works.

IC Library functions:

DC Motors :

void fd(int m)
Turns motor m on in the forward direction. Example: fd(3);
void bk(int m)
Turns motor m on in the backward direction. Example: bk(1);
void off(int m)
Turns off motor m. Example: off(1);
void alloff(), void ao()
Turns off all motors. ao is a short form for alloff.
void motor(int m, int p)
Turns on motor m at power level p. Power levels range from 100 for full on forward to -100 for full on backward.

Servo Motor :

void servo_on()
Enables PA7 servo output waveform.
void servo_off()
Disables PA7 servo output waveform.
int servo(int period)
Sets length of servo control pulse. Value is the time in half-microseconds of the positive portion of a rectangular wave that is generated on the PA7 pin for use in controlling a servo motor. Minimum allowable value is 1400 (i.e., 700 sec); maximum is 4860.
int servo_rad(float angle)
Sets servo angle in radians.
int servo_deg(float angle)
Sets servo angle in degrees.

Sensor Input:

int digital(int p)
Returns the value of the sensor in sensor port p, as a true/false value (1 for true and 0 for false).
int analog(int p)
Returns value of sensor port numbered p. Result is integer between 0 and 255.

User Buttons and Knob:

int stop_button()
Returns value of button labeled Stop: 1 if pressed and 0 if released.
int start_button()
Returns value of button labeled Start.
void stop_press()
Waits for Stop button to be pressed, then released. Then issues a short beep and returns.
void start_press()
Like stop_press, but for the Start button.
int knob()
Returns the position of a knob as a value from 0 to 255.

Infrared Subsystem:

int sony_init(1)
Enables the infrared driver.
int sony_init(0)
Disables the infrared driver.
int ir_data(int dummy)
Returns the data byte last received by the driver, or zero if no data has been received since the last call.

Time Commands:

void reset_system_time()
Resets the count of system time to zero milliseconds.
long mseconds()
Returns the count of system time in milliseconds.
float seconds()
Returns the count of system time in seconds, as a floating point number. Resolution is one millisecond.
void sleep(float sec)
Waits for an amount of time equal to or slightly greater than sec seconds.
void msleep(long msec)
Waits for an amount of time equal to or greater than msec milliseconds. msec is a long integer.

Tone Functions:

void beep()
Produces a tone of 500 Hertz for a period of 0.3 seconds.
void tone(float frequency, float length)
Produces a tone at pitch frequency Hertz for length seconds. Both frequency and length are floats.
void set_beeper_pitch(float frequency)
Sets the beeper tone to be frequency Hz. The subsequent function is then used to turn the beeper on.
void beeper_on()
Turns on the beeper at last frequency selected by the former function.
void beeper_off()
Turns off the beeper.


int start_process( function-call( : :):, [TICKS] , [STACK-SIZE] )
start_process returns an integer, which is the process ID assigned to the new process.
int kill_process(int pid) kill_all
kills all currently running processes.
prints out a list of the process status. The following information is presented: process ID, status code, program counter, stack pointer, stack pointer origin, number of ticks, and name of function that is currently executing.
void hog_processor()
Allocates an additional 256 milliseconds of execution to the currently running process.
void defer()
Makes a process swap out immediately after the function is called.

Floating Point Functions:

float sin(float angle)
Returns sine of angle. Angle is specified in radians; result is in radians.
float cos(float angle)
Returns cosine of angle. Angle is specified in radians; result is in radians.
float tan(float angle)
Returns tangent of angle. Angle is specified in radians; result is in radians.
float atan(float angle)
Returns arc tangent of angle. Angle is specified in radians; result is in radians.
float sqrt(float num)
Returns square root of num.
float log10(float num)
Returns logarithm of num to the base 10.
float log(float num)
Returns natural logarithm of num.
float exp10(float num)
Returns 10 to the num power.
float exp(float num)
Returns e to the num power.
(float) a ^ (float) b
Returns a to the b power.

Memory Access Functions
int peek(int loc)
Returns the byte located at address loc.
int peekword(int loc)
Returns the 16-bit value located at address loc and loc+1. loc has the most significant byte, as per the 6811 16-bit addressing standard.
void poke(int loc, int byte)
Stores the 8-bit value byte at memory address loc.
void pokeword(int loc, int word)
Stores the 16-bit value word at memory addresses loc and loc+1.
void bit_set(int loc, int mask)
Sets bits that are set in mask at memory address loc.
void bit_clear(int loc, int mask)
Clears bits that are set in mask at memory address loc.
Here is an hierarchical sturcture of the IC library functions in relations to user programs.

Software model
The main function of the robot is to gather information from all of its sensors and decide what to do from the information collected. It must constantly poll, 4 infrared(edge), 4 ultrasound, and 4 contact sensors. In addition to checking the sensors, the motors are controlled via an open loop system with no feedbacks. Therefore it must use some timing function to control its maneuvers such as turning. The multi-tasking function and time commands of IC seems ideally suited for this application.

The ellipses are individual tasks. The sensors checking tasks writes the result of its sesnsor test to global variables. The "Main Program" polls these global variables and decides on what to do. It also have to make sure that only one "Move Robot" task can be active at a time. This information is communicated to the "Main Program" via task status global variables.
***** Dave's Multi-tasking Sumo Robot Program *****
***** Version .91 May 18, 97 *****

********** Global Variablies **************
********** Common fixed values **************
int moving=1,

********** Analog ports *************
*********** Infared edge sensors ***************
****** Values for edge ******
****** 1 = fl_edge ******
****** 2 = fr_edge ******
****** 4 = rl_edge ******
****** 8 = rr_edge ******/

int rr_edge=0,

************** Digital Ports ***************
int left_ultra=12,

int left_contact=7,

******** Direction, Speed, and Duration **********
int fast=100,

long forever=255l;

********* Process ID's **************
int edge_pid,move_pid,contact_pid,ultra_pid,

********* Process Status **************
int edge_status,move_status,ultra_status,contact_evade_status,
int edge_evade_stage1=not_running;

******** Sensor Checking Taskes ***********
******** Edge detection Analog ports 0-3 ***********
void check_edge()
int x,e;
for (x=first_edge; x<=last_edge; x++) { e <<= 1; /* shift e 1 bit to the left */ if (analog(x) <= white_value) /*||analog(x) >= off_edge_value)*/
e |= 1; /* OR e with 0001 */
/*printf("edge=%d e=%d\n",edge,e);*/
if (e != edge)

****** Contact sensors, Digital ports 7-10 *******

void check_contact()
int x,c;
for (x=first_contact; x<=last_contact; x++) { c <<= 1; /* shift c 1 bit to the left */ if (digital(x)) c |= 1; /* OR c with 0001 */ } /*printf("contact=%d c=%d\n",contact,c);*/ if (c != contact) contact=c; } } /***************************************************** ****** Obstacle detection Digital ports 12-15 ******* *****************************************************/ void check_ultra() { int u,x,y,z; while (1) { u=0; for(x=first_ultra; x<=last_ultra; x++) /* left to right */ { u <<= 1; /* shift u 1 bit to the left */ if(digital(x)) u |= 1; /* OR u with 0001 */ } printf("ultra=%d u=%d\n",ultra,u); if (u != ultra) ultra=u; } } /***************************************************** ********* Move robot ************** *****************************************************/ void move(int direction, int speed, long duration) { int sp1,sp2; long dur; move_status=running; if(direction==forward||direction==reverse) { sp1=direction*speed; sp2=sp1; } else if(direction==right) { sp1=reverse*speed; sp2=speed; } else if(direction==left) { sp1=speed; sp2=reverse*speed; } robot_status=moving; motor(0,sp1); motor(1,sp2); motor(2,sp2); motor(3,sp1); if (duration!=forever) { dur=mseconds(); while(duration >= mseconds()-dur);

************ Edge Evasive Maneuver ***************
void edge_evade()
int dir,temp;


/********** move away from edge ***********/
/* front edge detectors dir=reverse */
/* rear edge detectors dir=forward */
if (temp==1||temp==2||temp==3)
else if (temp==4||temp==8||temp==12)
while (robot_status==moving);


/****** turns towards the centre of platform ******/
if (temp==2||temp==8)
else if(temp==1||temp==4)
while (move_status==running);

/******* move towards centre of platform **********/


********** Contact Evasive Maneuver **************
void contact_evade()
int c_dir;


/* left contact c_dir=right speed=fast_pivot duration=500l */
/* right contact c_dir=left speed=fast_pivot duration=500l */
/* front contact c_dir=forward speed=fast duration=forever */
/* rear contact c_dir=reverse speed=fast duration=forever */
if (temp_contact==1) /* right contact */
else if (temp_contact==2) /* left contact */
if (temp_contact <= 2 && temp_contact !=0) move_pid=start_process(move(c_dir,fast,forever)); while(contact==temp_contact); contact_evade_status=not_running; kill_process(contact_evade_pid); } /***************************************************** ************ Obsticle Tracking *************** *****************************************************/ void tracking() { tracking_status=running; if(temp_ultra==1) move_pid=start_process(move(right,slow,forever)); if(temp_ultra==2||temp_ultra==3||temp_ultra==4||temp_ultra==6||temp_ultra==12) move_pid=start_process(move(forward,slow,forever)); if(temp_ultra==8) move_pid=start_process(move(left,slow_pivot,forever)); tracking_status=not_running; kill_process(tracking_pid); } /***************************************************** ***************************************************** ***************************************************** ***************************************************** ***************************************************** ************ Main Program *************** ***************************************************** ***************************************************** ***************************************************** ***************************************************** ***************************************************** *****************************************************/ void main() { int e,m,k,x,y,z; ao(); /* make sure that all motors and relays are off */ k=1; /* Initalize edge sensor values */ for(x=first_edge; x<=last_edge; x++) { z=0; for(y=0; y<=10; y++) z=z+analog(x); z=z/10; suface_value=suface_value+z; k++; } suface_value=suface_value/k; white_value=suface_value-20; if (suface_value+5 > 253)
/* Main loop */
while (1)
if (move_status==running)
else if(contact!=temp_contact&&edge_evade_status==not_running)
else if(contact_evade_status==running || robot_status==moving)
if (contact_evade_status==running)
else if(ultra!=temp_ultra && edge_evade_status==not_running &&


posted by Sachin Maurya @ 8:02 AM   1 comments
  • Share It: vIndianz  Digg  Reddit  Netscape

  • Sunday, January 13, 2008
    How to convert rotary motion into linear motion

    If you are thinking about constructing a small robotic platform, maybe control a few motors for some special applications and you want to get off cheap and use dc motors. Then it’s going to cost you. DC motors usually need things like gearboxes and location sensors if you want to get any use out of them. But if all you need is continuous rotational motion or linear motion until a switch gets bumped, this is the motor. Speaking of linear motion, here is a little recipe side dish:

    Linear Motion Using DC Motors

    A good linear setup can be easily made with a Radio Shack 3 volt DC motor, a square 1/8 inch styrene tube, and about 5 inches of 256-threaded rod. Cut an inch of the styrene tube and pressing it onto your motor, making sure the shaft still rotates. Now you simply start screwing the threaded rod into the other end of the styrene tube. Isn’t it cool how the threaded rod taps the styrene for you? For a real good hold, use modeling or crazy glue to hold it in place.

    Now you can mount the motor into your project, or attach a slide to it. I like to use a 0.3 inch piece of 1/8" styrene as the part that slides up and down the screw. Once again I just use the screw to tap it, and I usually just glue the outside of the piece to whatever it is I’m trying to move. Or I press the small styrene piece into a larger brass tube using a little glue to secure it. Piece of cake.

    Now all you need to do is determine where the slide is on the screw and you’ve got it made. True gear heads use optical encoders, I like to use a switch. With a switch it’s easy to determine where the beginning of the slide is, and I can just send a pulse to the motor and get the assembly to move to approximately where I want it. It seems like I’m forgetting to tell you something…


    So now that you have this cool linear slide, you probably think this would be a great app. to use up some of those micro-switches that you’ve had in your junk box since you where seven years old. Sure, you can use those switches to sense when the slide is at the end/beginning of the it’s range, right? Nope. It’s ok I use to think I could use those too, I even convinced myself that those switches where actually made to stop when something bumps into them.
    The reality is those switches where made to fill space in your toolbox. If micro-switches where meant to stop anything with any kind of momentum, they would have made them so they activate sooner and not bind up the second an object in motion. But fear not! We will simply construct our own.
    Switches are actually pretty easy to build. A spring, a contact point with a stopper, a little insulation, an outer case, you’re in business. Let’s build one real quickly.


    Its pretty easy to make a spring. Using a 6" length of 1/16" square brass tube, insert one end of the steel wire into the tube, and crimp the tube shut, thus securing the wire. you are now free to wind the wire tightly around the tube, leaving no gaps between the coils. After you have wound wire down about an inch of the tube, snip the excess wire off at the top and the bottom of the spring using an old pair of wire cutters since the steel wire tends to nick the edge of the cutters.
    The wire will recoil slightly, making a pretty cool little spring about 0.1" across with bends in it that form hexagonal coils. Now just pull the two ends of the coil apart and stretch the wound wire until the distance between the coils is a little less than 0.1", and the spring is unable to pull back to it's original shape. Snip off a smaller spring about 0.4" long.


    0.4 inches of 1/8" Styrene. You’ll learn to love this stuff.


    For the case I just used some square brass tube 5/32" actually, about 0.4" of it. The contact is just a thin piece of square brass tube (1/16" about 1.4 inches long) that runs down the center of the styrene. The styrene is glued into the larger piece of brass. For the stoppers I cut two 0.2-inch pieces of styrene, one piece fits flush on the end without the spring, and the other piece is glued on so as to add a little bit of tension to the spring.
    Solder a wire onto the contact piece and one onto the outside of the case. I use silver solder, it holds well. Now assemble like the picture using glue to hold the styrene stops onto the contact rod, and the styrene insulation in the case. Easy on the glue, if you get it on the contact rod and it glues to the insulation, things won’t slide.

    Now I glue or solder the case of the switch right below the motor and allow the slide assembly to bump into the contact switch. On my projects the slide assembly is metal and grounded. So now I can just run a 10k-ohm resistor from say, +5 volts to the contact rod. Now when the contact rod hits the slide assembly I get a nice TTL low for my microcontroller. The spring allows the assembly to come to a slow without binding.
    The assembly is now ready to start moving back out with no problems.

    Your going to have to make adjustments in the tension of the spring and the position of the switch to suite your application. You might even want to eliminate the back stopper and replace it with a couple pieces of brass tube so you can make a normally closed switch. As long as you understand the basic concept of what your application requires and what you need to do to get your project to work, you’re cool. After all, that’s what hobby robotics is all about.


    If you have a small DC motor and you want to hook it up to a processor or a controller easily, I would highly recommend using L293D motor controller chip has good prices and even got me the surface-mount version. For most of my applications I use the Basic Stamp II but I know SRS Rob hackers aren’t like the rest of us- they’re different. Here is a generic schematic with the control lines labeled.

    Notice that the L293D supports two DC motors. Pin 16 is the +5 voltage for the chip, while pin 8 is the voltage for the motors. The first motor gets hooked directly to pins 3 and 6. The motor is turned on by sending a high signal to both the enable (pin 1) and one of the two direction pins, lets say pin 2, while keeping pin 7 low. To go the other direction keep the enable pin and pin 7 high while pin 2 goes low. To stop enable pin is high while both 2 and 7 are low.
    The same goes for the other side of the chip. When driving two or more motors I like to hook pins 2 and 15 together and pins 7 and 10. Sorry to say I don’t remember what the specs are for this chip, I usually send about 6 volts through it with a 0.7-volt drop for the L293D internal transistors, and I expect a 200 to 300 milli-amps total for both motors.

    Labels: ,

    posted by Sachin Maurya @ 9:54 AM   0 comments
  • Share It: vIndianz  Digg  Reddit  Netscape

  • The Techniques of connection

    While building a robot you need to connect multiple devices together. There are lots of ways to connect them. Some are better than others!
    I have built lots off things that turn into a real rats nest. I would need one thing connected to my power source so I just solder a wire to the positive side and another wire to the ground side. As Chef Tell would say "Very simple, very easy". Then I needed a second device so I soldered those wires on. It's still not bad, yet... Or you can just twist the wires together, solder them and cover it with tape...
    As you add more devices it becomes a real problem!

    The picture on the left shows multiple wires soldered to a common point. It's not obvious from this picture but one of the red wires is soldered to another common point on the back of the board. And it has another 2 or 3 wires soldered to it. Both photos show examples of multiple wires soldered together and covered with tape.

    Connections will generally fall into one of two categories:

    • Individual signals
    • Bussed or grouped signals

    I will present different methods to make these connections.

    Individual Connections

    There are various ways to make a single connection. The following techniques come to mind:

    • Solder
    • Banana plugs and jacks
    • Jumper wires
    • Wire-Wrap
    • Screw terminals
    • Block pin connectors
    • Pin connectors
    • Combination pin/screw connectors
    • COAX cable connectors

    Solder Connections

    As simple way to attach a wire is to solder it to a pin. This is a good way to permanently attach a wire. For instance, you may want to solder wires directly to a motor. Then use a quick-disconnect on the other end of the wires.

    These photos show different devices with soldered connections. The first one shows a voltage regulator which is bolted to a heat sink. The second one shows wires and a capacitor soldered to motor terminals. The third one shows wires soldered directly to a PC board. Just keep in mind these are permanent connections.

    Banana plugs and jacks

    Jumper wires


    Wire-wrap has been around a long time. Basically you have square pins and wire is wrapped around a pin to make the connection. Wire-wrap sockets are available for standard DIP I.C. packages. If you look around you can also find other types of sockets available.
    You can connect two boards together with wire-wrap wire. But the standard 30 gauge wire is made from steel (or iron) and is more brittle than copper wire. This leads to the wire breaking if it is flexed much. So it is best to have the boards mounted solidly if using 30 gauge wire-wrap wire to connect them.
    The actual connection is made using a wire-wrap tool. It looks much like a screwdriver. It has two holes in the business end. One in the center which slides over the pin to be wrapped. The other hole is offset from the center. The wire to be applied is slipped into this second hole. As the tool is turned the wire wraps itself around the pin.
    You can also find power wire-wrap guns. They are electric or pneumatic. But for occasional use the hand operated wire-wrap tool is adequate.
    Back when I did a lot of wire-wrapping I was amazed that it usually cost more for the socket than for the I.C. Over the years I have collected wire-wrap sockets when I found them at a cheap price.

    Screw terminals

    Screw terminals can be handy. They come in various sizes. You can get PC mount type and also simple terminal blocks you connect multiple wires to. The smaller PC mount types are designed to have a wire inserted and screwed down. The larger type work well with a crimp-on connector.

    If you use stranded wire with a screw terminal I recommend tinning the wiring with solder before connecting it to the screw terminal. This prevents the individual wire strands from fraying and possibly causing a short.

    Even though the terminal blocks (as seen in the first photo) are very handy, they seem to take up a lot of valuable space. My robot projects are usually quite large so it isn't a big problem for me. They are available in smaller screw sizes also.

    Crimp-on terminals

    Crimp-on terminals provide an easy way to terminate individual wires. This provides a clean connection to a screw terminal. The terminals come in a variety of sizes and types. They are applied using a crimper. You can get "cheap" crimpers at auto supply stores and hardware stores. They work, but not very well. (In my humble opinion) The high quality yellow handle crimpers in the picture are a pair I picked up at a swap meet for 4000 Rs. A pair from AMP or other major brands seems to run around 3200 Rs for some unknown reason...
    The terminals are available at Radio Shack, auto supply, hardware and lots of other stores.

    Block pin connectors

    This type of connector allows an easy way to make a cable removable. You can cut the cable and install this in between the two ends. These are available at Radio Shack and most electronics suppliers. (Maybe even auto parts stores) They come in at least two different pin sizes. Right off hand I know you can get them with pins ranging from 2 to 12, maybe bigger.

    PCB pin connectors

    Pin connectors provide a very flexible way to terminate your wires. They come in two basic types. Single wires and multiple wires (like ribbon cable). The multiple connections are presented on the next page. I use two different size of connectors.
    The smaller, red ones are Molex/Weld
    There are many, inexpensive ways to lay out the electronic components which interface to your Stamp board. A good layout has the following features:

    1. All components are secured to some kind of rigid backing. Nothing is flopping in the breeze.

    2. Wires are only as long as they need be. No wire loops rising above the board.

    3. Component leads are trimmed so that there is no danger of leads shorting should they be bent.

    4. The entire project, including batteries, can be lifted with one hand. Everything is one backing board.

    5. The project can survive modest drops and modest shaking without connections coming loose.

    6. All motor housings are secured so that the housing doesn't move when the motor is powered.

    7. Switches are anchored so that they can be operated with one hand.

    Here are some pictures of circuits which interface an LED, a small motor and a switch to the Stamp. Use them for ideas. on connectors. The pins are .1" on center so they fit in standard perf board. I get them from Digit Key. You buy the pin blocks, socket blocks and pins separately. They come in lots of sizes so you pick the size you need for the application. (Some times it is good to have all the connectors on a board be different sizes. Then you can't plug the wrong one in by mistake.) You can get a crimper for the socket pins, but I can't find mine at the moment. I usually solder the pin whither I crimp it or attach it by hand. I've had too many come loose if I don't solder them.
    The other types have the pin permanently mounted in the socket block. You crimp the wire into the socket itself. These come in at least two different sizes. I have .1" and .156" pin spacing sizes. The larger size are rated at around 3 to 5 amps. They are made by AMP and Pundit and others. I managed to find a pistol crimper for the large and small ones and surplus stores. (These are something else that cost too much when they are new. I think they are over $100. :-O ) I also found a hand crimper which you can see in the photo.

    AMP MT pin connectors

    This is another type of pin connector. They come as single in-line or dual in-line. They are end and edge stackable. (Which means you can insert them side-by-side.) So you can mix and match them on a larger block of connector pins.

    Combination pin/screw connectors

    A pin/screw connector offers an interesting alternative. It allows individual wires to be attached at random since each pin has a screw terminal. It also allows the whole connector block to be pulled off the pins when removing the board. (Note: I didn't have the pin block handy for the photo.)

    COAX cable connectors

    There are various ways to terminate COAX cable. COAX stands for Co-Axial. A COAX cable has a central wire surrounded by a concentric shield wire. COAX is usually used for analog or RF signals. You can use RCA phonon connectors, BNC connectors and lots of other types.

    Grouped Connections

    There are various ways to make a group of connections. The following techniques come to mind:

    • Crimp-on ribbon cable pin connectors
    • Crimp-on ribbon cable card-edge connectors
    • Crimp-on DIP cable connectors
    • Solder cup DB type connectors
    • AMP MTA pin connectors
    • Modular telephone type connectors

    Crimp-on ribbon cable pin connectors

    Crimp-on ribbon cable card-edge connectors

    Crimp-on DIP cable connectors

    Solder cup DB type connectors

    Modular telephone type connectors


    There are many, inexpensive ways to lay out the electronic components which interface to your Stamp board. A good layout has the following features:

    1. All components are secured to some kind of rigid backing. Nothing is flopping in the breeze.

    2. Wires are only as long as they need be. No wire loops rising above the board.

    3. Component leads are trimmed so that there is no danger of leads shorting should they be bent.

    4. The entire project, including batteries, can be lifted with one hand. Everything is one backing board.

    5. The project can survive modest drops and modest shaking without connections coming loose.

    6. All motor housings are secured so that the housing doesn't move when the motor is powered.

    7. Switches are anchored so that they can be operated with one hand.

    Here are some pictures of circuits which interface an LED, a small motor and a switch to the Stamp. Use them for ideas.

    Labels: ,

    posted by Sachin Maurya @ 6:46 AM   0 comments
  • Share It: vIndianz  Digg  Reddit  Netscape

  • Friday, January 11, 2008
    How to Build a Microcontroller Based Robotic Arm

    The arm control by robotics is very popular in the world of robotics. The essential part of the robotic arm is a programmable micro controller based brick capable of driving basically three stepper motors design to form an anthropomorphic structure. The first design was for experimental use on a human size industrial robot arm called PUMA 560 .This article explains the method of interfacing the robotic arm stepper motors with the programmed 8051-based micro controller

    Keywords: MCU, PUMA, PIO, LATCH, I/O


    Our primary objective is to make the Robotic arm, having three stepper motors, to interface with the In-Development of a Microcontroller Based Robotic Arm tel 8051-based micro-controller. It provides more interfaces to the outside world and has larger Memory to store many programs


    We were able to perform a detailed study of the robotic arm and the 8051 micro-controller. We Tested the built robotic arm, and the stepper motors when the robot is loaded. We also learnt and Familiarized with the 8051 micro-controller using assembly language, and converting the assembly language codes to hexadecimal codes using a development board.

    Mechanical Structure of the Arm:

    In constructing our arm, we made use of three stepper motors and gears since our structure is a three dimensional structure. A typical prototype that we employed is as shown in Figure.There is a stepper motor at the base, which allows for circular movement of the whole Structure; another at the shoulder which allows for upward and downward movement of the Arm; while the last stepper motor at the wrist allows for the picking of objects by the magnetic hand.


    The various components of the MCU shown in Figure 2 are explained below:

    Random Access Memory (RAM): RAM is used for temporary storage of data during runtime.

    ROM: ROM is the memory which stores the program to be executed.

    SFR Registers: Special Function Registers are special elements of RAM.

    Program Counter: This is the "engine" which starts the program and points to the memory address of the instruction to be executed. Immediately upon its execution, value of counter increments by 1.

    Control Logic: As the name implies, it which supervises and controls every aspect of operations Within MCU, and it cannot be manipulated. It comprises several parts, the most Important ones including: instructions decoder, Arithmetical Logic Unit (ALU) and Accumulator.

    A/D Converter: A/D stands for analog to digital. They convert analog signals to digital signals.

    I/O Ports: To be of any practical use, microcontrollers have ports which are connected to the pins on its case. Every pin can be designated as either input or output to suit user’s needs.

    Oscillator: This is the rhythm section of the MCU. The stable pace provided by this instrument allows harmonious and synchronous functioning of all other parts of MCU.

    Timers: timers can be used for measuring time between two occurrences and can also behave like a counter. The Watchdog Timer resets the MCU every time it overflows, and the program execution starts anew (much as if the power had just been turned on).

    Power Supply Circuit: this powers the MCU.


    The method employed in designing and constructing the robotic arm are based on the operational Characteristics and features of the microcontrollers, stepper motors, the electronic circuit diagrams and most importantly the programming of the microcontroller and stepper motors.

    Block Diagram

    The block diagram of our work is as shown in Figure

    Circuit Diagram

    The electronic circuit diagram of the development board is as shown in Figure 4. The connection of the identified components and devices are as shown. The components shown are: the MCU, the LATCH 74LS373, the EPROM 2732, Intel 8255 PIO, diodes, resistors, capacitors, inductors, transistors, and op-amps. This components work together to achieve the set goal of controlling the anthropomorphic-like arrangement of the stepper motor. The microcontroller is the processing device that coordinates all the activities of all the components for proper functioning.

    Power Supply

    This is used to power the whole system i.e. the Control Unit, Magnetic Sensing Unit, and the Stepper Motors. The transformer is a 220/12V step down transformer. We used a bridge rectifier to convert the 12V alternating current to direct current. The unregulated output from the filtering circuit is fed into a voltage regulator LM7805 andLM7812. These two are chosen for the design because the LM7805 has an output of +5V which’s required to power the Control Unit, and the Magnetic Coil while the LM7812 has an output of +12v which is required to power the Stepper motors. The TIP41 connected to the IC regulators functions as an emitter follower amplifier making sure that at least the required voltage by the Control Unit, the Magnetic Coil and the Stepper Motors produced.

    MCU 8051

    This is the processor. It coordinates the operation of the robotic arm by collecting information from the EPROM, the LATCH, and the PIO; interprets and then execute the instructions. It is the heart of the whole system.

    LATCH 74LS373

    This is a D-type transparent latch. It is an 8 bit register that has 3 state bus driving outputs, full Parallel access for loading, and buffer control inputs. It is transparent because when the enable
    (enable) input is high, the output will look exactly like the D input. This latch particularly Separates the data and address information from the MCU before sending to the instructed destination.The high-impedance state and increased high logic-level drive provide these registers with the capability of being connected directly to and driving the bus lines in a bus-organized system without need for interface or pull-up components. These latches are particularly attractive for implementing buffer registers, I/O ports, bidirectional bus drivers, and working registers.We are using this latch because there is a need to separate our 8 bit data and 8 bit address information from the common line of the MCU, and send them to the appropriate device(s).

    8255 PIO

    This is a programmable input/output device. It interfaces the connection between the 8051, the LATCH 74LS373, and the EPROM 2732 to external devices such as the stepper motors, (as is our own case) thereby allowing for communication.

    (EPROM) 2732

    EPROM stands for Electrically Programmable Read Only Memory. We made use of this external EPROM specifically because it makes the controller cheaper, allows for longer programs, and Because its content can be changed during run time and can also be saved after the power is off The overall diagrammatical layout of the complete circuit diagram of the whole control unit is shown in Figure.

    Stepper Motor

    The stepping motor is a motor that is driven and controlled by an electrical pulse train generated by the MCU . Each pulse drives the stepping motor by a fraction of one Revolution, called the step angle.

    The Magnetic Sensing Unit

    The magnetic sensing unit consists of a magnetic coil which can be magnetized simply by the action of the port P1.0 of the 8051. The port 1.0 was made use of because when designated as output, each of the pin can be connected up to four TTL inputs. That is why we have connected the pin 1.0 to the magnetic coil through three TTL logic The design is such that on the downward movement of the wrist, the 8051 sends an electrical signal to the Darlington pair connected to the magnetic coil. The magnetic sensing unit is powered on by three BC548 Darlington NPN pair transistor, through a diode each and a 5k resistor. The pair amplifies the current and makes the magnetic coil turn into magnet. Then any magnetic material could be picked (by attraction) and then movement continues. The magnetic material can then be dropped at another point when the wrist is made to come down, this also is an action from the 8051 as it withdraws the electrical signal from the coil.

    Control Circuit

    This is the control panel of the system as it oversees the operations of the mechanical arm, and the magnetic sensing unit. The MCU 8051 of the control unit acts as the brain of the control panel as it coordinates all the activities of the other devices. When power (+5V) was supplied to the control unit, the MCU started off by loading the program from the EPROM M2732A, interpreted and executed the instruction codes through the various operational principles which had been described in details in chapter three (session 3.2).The 8051 then sends signal to the stepper motor which moves 9° per step. The stepper motor(M3) at the wrist first moves five times (45°) turning the gears to cause a downward movement of the hand. The stepper motor at the shoulder (M2) moves next stepping five times (45°) and makes the connected gears to cause the movement of the arm 45° forward. Then the stepper motor at the base(M1) moves either ten times (90°) or twenty times (180°), depending on the button pressed, causing the whole structure to turn from right to left( or vice versa) through the connected gears. The magnetic coil resting on the hand becomes magnetized immediately the last gear on the hand stops moving. Then, it magnetizes (picks) any magnetic material it can find and then M3 and M2 moves the arm up while M1 moves (rotates the structure) from left to right (or vice versa) and then the 8051 demagnetizes the magnetic coil thereby making the hand to drop the metallic object.


    This work is able to successfully accomplish the defined functionality. A sample robot which can rotate, magnetize an object, lower and raise its arm, by being controlled by the 8051 microcontroller is built successfully. The 8051-development board is soldered and it used the required procedure for the correct operation of the controller. The 8051 development board has been interfaced to the stepper motors such that the anthropomorphic like structure can be controlled from the buttons at the base of the structure (robotic arm).

    There are four buttons being controlled by the control unit at the base of the arm:

    ON/OFF: the ON button puts on the system while the OFF button puts off the system

    START/STOP: the START button starts the movement of the whole arm from its reset point, while the STOP button takes the arm back to its reset button after completion of its movement.

    RIGHT-LEFT/LEFT-RIGHT: when this button is switched to the RIGHT-LEFT part it causes movement from right to left, while the LEFT-RIGHT part causes movement from left to right.

    180/90: when the button is on 180, it causes a rotation of 180 degree of the base stepper motor, but when put on 90 degrees, it causes rotation of 90 degrees.

    Labels: ,

    posted by Sachin Maurya @ 6:33 AM   4 comments
  • Share It: vIndianz  Digg  Reddit  Netscape

  • Wednesday, January 9, 2008
    How to Make Simple Small Robot Drive Train

    This article helps you to know about the different techniques used to build the chassis and drive train of relatively small robots.

    "Here you must know what I mean by small robots, is the category of light weight robots where aspects like aerodynamics and vibration damping Are not taken in account"

    Most of the fundamental theory remains the same for all kinds of robots, such as robot stability, traction and steering techniques. However, this article is dedicated to the construction of relatively small robots, which explain how to the implement your designs using material and equipment at the reach of any average level hobbyist.
    There are many types of mechanisms that have been developed to move a robot from a place to another, more than you could imagine, however, we will only study some of those techniques which are the most adequate to relatively small robots:

    1-Traction and steering mechanisms

    1.1- Differential Drive system:
    This is the most common locomotion scheme in the world of robotics. It's easy to build, easy to control and can permit the robot to move in all required directions. In that system, two motors are connected, one to each of the two drive wheels at the right and at the left of the robot's base. Those two motors are responsible of driving the robot back and forth as well as steering in any required direction. This system can even allow a robot to pivot in its place.
    Figure shows in a simplified way the principle of operation of differential drive. When the left and right motors are turning at the same speed, the robot moves forward or backward in a straight line. In order to turn right for example, the right motor is slowed down and the whole robot steers to the right. The bigger the difference of speed between the two wheels, the tighter will be the steering curve.
    As you can also notice in the upper figure, this system needs one or more caster wheels (also called free-wheels) to support the rest of the chassis
    while freely following the movement of the robot engaged by the two main drive wheels. Some robots use 2 caster wheels, adjacent to the drive wheels for better stability, but again, in the category of small robots, one caster wheel can be enough.

    shows the chassis of one of our line follower robots where skids are used along with the drive wheels to support it in a horizontal position. This technique becomes interesting when used for lightweight robots, where caster wheels can cause even more friction than the skids, and add additional and unnecessary weight to the robot.
    You can also notice in the figure that the rear skid is not touching the ground, and thus is not a primary skid, but rather a secondary one just in case the robot pivots around the drive wheels to the back during a sudden acceleration.

    1.2- Four wheel differential drive system:
    Another variation of the differential drive system is the 4 wheel differential drive system, which resembles the drive trains of tanks and bulldozers.
    As figure shows, it consists of only two motors and 4 wheels. Each pair of wheels are mechanically connected together, usually by the mean of a belt forcing them to move together, driven by a single motor. The behavior of this drive train is similar to the previous differential drive system; if the two motors turn at the same speed, the robot moves forward or backward, if there is a difference between the speeds of the two motors, the robot will steer in the direction of the slower motor. The advantage of this system is that it is very easy to build and is most suitable for running on low friction and dusty surfaces where other drive systems would suffer.

    1.3- Car-type drives system:
    This drive system has many names, but calling it "car-type" make it clear to any reader, that it consists of 2 wheels coupled on the same axe at the back and one or two wheels capable of steering to control the displacement of the robot. While this technique is very difficult to implement mechanically, it provides two major advantages over other traction systems: Ease of control and accuracy. The best way to build your first 'car-type' drive train is to look at any old RC toy car. You can also use some parts of it's drive train to build your own, Following Figure shows a simplified layout showing the principle of operation this drive system. Connecting the front (steering) wheels to the motor can be very complicated, but a basic rack and pinion arrangement can be enough for very low steering angles, otherwise, for relatively high steering angles, the rack and pinion arrangement will have to be enhanced with a sliding mechanism allowing the green axe linking the two front wheels together to move freely along the axis of the chassis.

    1.4- Divided chassis drive train:
    This is another locomotion scheme that we experienced, which has the advantage of being very powerful and highly configurable. Indeed, this system relies on 4 independent motors, each one coupled to one of the four wheels, allowing the robot to move forward or backward with the accumulated power of four motors or to turn right and left with approximately equivalent power, but with minimum frictional losses.
    Figure shows how to implement such a configuration, and shows how the chassis is divided into two parts, hinged together, allowing it to change its shape to turn in tight curves. One last special feature of this system is that it has neither head nor tail, in other words, there is no difference between the front part of the chassis and the rear one, making it possible for the robot to change it's direction, to adapt to any situation, without
    having to execute a 180 degrees turn.

    2-Mounting the Motors

    There are many items that you can buy at your nearest hardware store, to use it to mount the motor on the chassis, I present some ideas that I find to be the most adequate to this category of robots.

    2.1- Pipe Clamps:
    Figure shows how a pipe clamp can be used to mount the motor on the chassis. As you can notice, one of the main advantages of using a pipe clamp, is that you can easily adjust the distance between the motor and the base of the robot to which the motor is fixed, which is not the case with other solutions, like the U-Bolt idea.

    2.2- U-bolts:
    The U-bolt is designed to hold a circular object by pushing it against a fixed surface. As figure shows, in our application, the circular object is the motor and the fixed surface is the chassis. so the height of the motor from the ground depends on the height of the part of the chassis where the motor is fixed. In contrast, with Pipe clamps, you can easily adjust the distance between the chassis and the motor.

    2.3- Building your own bracket:
    You have to use your imagination, and cope with the components, tools and materials that are at your reach. At this point i'll only give you hints of materials you could use to easily attach your motors.

    A rubber band:
    can hold your motor in place exactly like a U-Bolt, while giving it some elasticity to absorb shocks and vibrations. You can obtain really strong rubber belts from old cassette players.

    Thick copper wire

    can also be used instead of the U-bolt, although it has the major disadvantage of being a permanent solution, any modification will be destructive and new wires will have to be installed. Figure shows actual pictures of DC motors that's I've mounted on one of my first robots.

    Plastic strap fastener
    It is still a permanent solution, but has the advantage of providing a strong attachment, while being easily introduced and fastened in small places where it would be harder to install copper wires or rubber bands.
    3-Transmitting power to the wheels

    3.1. Direct transmission from a DC Motor,
    Shows an example of how a small plastic wheel can be mounted to the tiny shaft of small motors. As you can see this is the same idea used in most toy cars, where parts are simply forced in their place. This is more interesting than more advanced shaft coupling techniques when you're working with tiny motors, because it would be very difficult to drill it's output shaft to install setscrews or pins.

    3.1 Direct transmission from a gear head DC motor
    This is the most common method used by robotics, specially for the category of robot we are talking about. If the wheel you are using doesn't have an extended shaft as shown in figure, you will have to find another mean of fastening the motor's shaft to the wheel, but virtually any wheel you will find is designed to be mounted on a shaft, so using your imagination, you'll end up finding a solution to that problem, depending on the shape and size of the wheel.

    3.2- Undirected transmission
    Figure shows a classic undirected transmission system; where the rotation of the motor's shaft is transmitted through a reduction pulley arrangement, lowering the RPM of the wheel, while increasing the torque. Notice how the full weight of the robots is distributed only on the two rolling bearings, making this drive train much more robust than other where the wheels are directly mounted on the motors.
    Both Figures shows a practical implementation of this technique on one of our early robots, where each wheel is mounted to a 6mm steel shaft, supported at both ends with rolling bearings. There is no obligation to put the rolling bearing at both sides of the wheel but you have to put two of them, each one as distant from the other as possible, to reduce shear stresses on the rolling bearings. While you're looking at the pictures, you can notice how the motors are mounted with pipe clamps as explained before.

    6-Finding motors and building material

    The easiest way to acquire all the material and equipment you need to build a robot, is to buy it! But that's not the cheapest way, and sometimes You won't find all what you need in the stores. That's why - if you plan to dig your way in the field of robotics - you should start collecting all kind of devices from which you can scavenge all kind and sizes of DC motor, mechanical parts, gears, pulleys, etc.

    From my experience, I tried to classify the kind of devices from which you could extract useful items; at least, this is what I do with those devices before throwing them away.

    Old cassette players and walkmans: Small Motors, pulleys, belts, gears.

    Old Floppy disk and CD-ROM drives: Very small motors, worm gear, sliding mechanism, gears, limit switches

    Old Photocopier machines, printers and scanners: quality Gear head DC motors, sliding mechanisms, rubber wheels, gears.

    As for the chassis, it can be built with a multitude of materials. My preferred material is Copper boards (made for PCBs) as you can solder many metals to it like screws and nuts, you can also design the main board of the robot on the same board to reduce size, weight and cost.

    My second best choice is the Fiberglass. It can be easily formed with a cutter, can be easily drilled, can sustain high stresses, and looks very neat an professional.

    Another good choice for building the chassis of the robot is the 3mm Medium Density fibers (MDF wood) which has the advantage of being very cheap, and can be very easily cut, drilled and grinded to any shape you want. The only disadvantage of this material is that it can easily deteriorate with water or even too high humidity.

    Those were the material I found to be more suitable for this category of robots.


    posted by Sachin Maurya @ 7:10 AM   5 comments
  • Share It: vIndianz  Digg  Reddit  Netscape

  • About Me

    Name: Sachin Maurya
    Home: Lucknow, Uttar Pradesh, India
    About Me: born thinker
    See my complete profile
    Previous Post
    Robot Images