Saturday 28 January 2012

Final Year Project


Mechanical
 + 
Electronics
 + 
Electrical
 + 
Idea
 = 
MICRO RUNNER
(LEGGED ROBOT)

******************************************************


******************************************************

This Blog will show the progress development project and circuit. Each step will explain in detail include the material and item that be used.



Week 14
7.0 Preparation and Present about the project
The presentation will start on 8/11/12 (Thursday) week 14 and all FYP Degree semester 2 will present their project. Each student will be examined by two checks, My Assessors are also many suggestions for my project and in syaa allah, I will propose my ideas on Assessors to my supervisor Mr. Abdul Razak Ahmad.

 




Week 13
6.0 Create Poster and Template
            6.1 Poster

            6.2 Template
 




Week 11 & Week 12
5.0 Finishing robot development

Use LI-PO rechargeable battery 7.4 V 4500mAH to support 12 servo motor.
Connect the 9V battery to supply the PIC circuit.
The PIC Microcontroller circuit at the top robot body
The leg robot start moving
In the table below is the number of servo motor step movements, robot leg number, and the function each servo motor.
Step Number
Leg Robot Number
Servo Motor Number
Function
1
3
7
Pull up
1
4
9
Pull up
2
3
10
Forward
2
4
12
Forward
3
3
7
Pull down
3
4
9
Pull down
4
3
10
Backward
4
4
12
Backward
5
1
1
Pull up
5
2
3
Pull up
6
1
4
Forward
6
2
6
Forward
7
1
1
Pull down
7
2
3
Pull down
8
1
4
Backward
8
2
6
Backward

Refer to the table the step number is more, so the robot movement is slowly because need to follow the step flow until the step end and repeat again. Then, with this movement robot stability is high and good performance. This project use six (6) leg but only four (4) legs is function. The two (2) legs at the medium are for robot stand to get the stability from falling. Another that, the stand leg is to support the robot weight and the robot can move easily.
5.1Summary
The testing of the hardware and software for every part had been done and all the results had been analyzed. There are other parts of testing and maintaining that had been done in this week which were testing the functionality of PIC Microcontroller, testing the Servo Controller circuit, testing the functionality of touch sensors with microcontroller and the important part is the leg synchronizing. This project is declared as successful.
 




Week 8, 9 & 10
4.0 Programming source code development
This programming source code is very difficult to build so need more time to get the correct program. For the first time build basically more error occur then after fix it, this program can use to control the robot movements.
//              main function                           (main function of the program)
void main()
{
                                unsigned int i,j,k,a=0, temp=0;
                                unsigned char sp=0;
//              set I/O input output
                TRISB = 0b00000011;            //configure PORTB I/O direction
//              Configure UART
                SPBRG=129;                                           //set baud rate as 9600 baud for 20Mhz
                BRGH=1;                                                //baud rate high speed option
                TXEN=1;                                 //enable transmission
                TX9 =0;                                                   //8-bit transmission
                RX9 =0;                                                   //8-bit reception      
                CREN=1;                                 //enable reception
                SPEN=1;                                 //enable serial port
                SYNC=0;                                  //Asynchronous mode
                LED1=0;                                 // OFF LED1
                LED2=1;                                 // OFF LED2
                sp=70;                                                     //speed value for the servo
                while(1)
                {
                                if(SW1==0)
                                {
                                                while(SW1==0);      //SW1 press and waiting for release
                                                on_off_cmd(0,1);     //ON all the channel
                                                LED2^=1;                                                               
                                }
                                else if(SW2==0)                       //if SW2 is pressed
                                {
                                                while(SW2==0);      //SW2 press and waiting for release
                                                while(1)                   //infinity loop
                                {
/////////////////////////////////////////////////// leg right up //////////////////////////////////////////////////////////////
                                                for(k=1; k<3; k++)  //servo channel 1-8 loop
                                                {
                                                                position_speed_cmd(k,5000,sp);
//              send command Servo posisitoning with speed
                                                }
                                                                while(request_position_cmd(1)<4900)
//              read the position from channel 1 after sending request position command
                                                {
}
//              if the position is smaller than 6900, loop here until the position is bigger then 6900
/////////////////////////////////////////////// leg right forward ////////////////////////////////////////////////////////            
                                                for(k=3; k<5; k++)                                 
                                                {
                                                                position_speed_cmd(k,5000,sp);
                                                }
                                                                while(request_position_cmd(3)<4900)
                                                {                                                                                                              
                                                }
/////////////////////////////////////////////////// leg right down /////////////////////////////////////////////////////////
                                                for(k=1; k<3; k++)                                 
                                                {                                                                                              
                                                                position_speed_cmd(k,1000,sp);
                                                }
                                                                while(request_position_cmd(1)>1100)
                                                {                                                                              
                                                }
/////////////////////////////////////////////////// leg right reverse ///////////////////////////////////////////////////////
                                                for(k=3; k<5; k++)                                 
                                                {                                                                                                              
                                                                position_speed_cmd(k,1000,sp);
                                                }
                                                                while(request_position_cmd(3)>1100)
                                                {                                                                                              
                                                }
////////////////////////////////////////////////////// leg left up /////////////////////////////////////////////////////////////
                                                for(k=5; k<7; k++) 
                                                {
                                                                position_speed_cmd(k,5000,sp);
                                                }
                                                                while(request_position_cmd(5)<4900)
                                                {                                                                                                              
                                                }
////////////////////////////////////////////////// leg left forward /////////////////////////////////////////////////////////
                                                for(k=7; k<9; k++)                 
                                                {                                                                                                              
                                                                position_speed_cmd(k,1000,sp);
                                                }
                                                                while(request_position_cmd(7)>1100)
                                                {                                                                                              
                                                }
////////////////////////////////////////////////////// leg left down ////////////////////////////////////////////////////////
                                                for(k=5; k<7; k++)                                 
                                                {                                                                                                              
                                                                position_speed_cmd(k,1000,sp);
                                                }
                                                                while(request_position_cmd(5)>1100)
                                                {
                                                }
////////////////////////////////////////////////////// leg left reverse //////////////////////////////////////////////////////
                                                for(k=7; k<9; k++)
                                                {
                                                                position_speed_cmd(k,5000,sp);             
                                                }
                                                                while(request_position_cmd(7)<4900)
                                                {
                                                }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                                }
                                }              
                }
}
//              subroutine for Servo Controller 8 channel command ( SC08A)
//===============================================================
//              command Servo positioning with speed
void position_speed_cmd(unsigned char channel, unsigned int position, unsigned char speed)
//              send 4 bytes of command to control servo's position and speed
{
                unsigned char first_byte=0, higher_byte=0, lower_byte=0;
//              First byte combined the mode and servo channel
//              ob xxx   xxxxx    (in binary)
//              mode channel
//              for servo positioning with speed command, the mode value is 0b111xxxxx
                first_byte=0b11100000|channel;                                                                                                            
                higher_byte=(position>>6)&0b01111111;                                            
//              position value from 0-8000 are greater than a byte
                lower_byte=position&0b00111111;
//              so need two bytes to send
//              send command to SC08A in 4 byte - Mode with channel, higher byte of position, lower byte of position, and speed
                uart_send(first_byte);                                                                                                                              
                uart_send(higher_byte);
//              second byte is the higher byte of position 0b0xxxxxxx
                uart_send(lower_byte);
//              third byte is the lower byte of position 0b00xxxxxx
                uart_send(speed);
//              fourth byte is the speed value from 0-100
}
//              command Enable/disable the servo channel
void on_off_cmd(unsigned char channel, unsigned char on_off)
{
                unsigned char first_byte=0;
//              First byte combined the mode and servo channel
//              ob xxx   xxxxx    (in binary)
//              mode channel
//              for servo positioning with speed command, the mode value is 0b110xxxxx
//              channel = 0 meaning all channel
                first_byte=0b11000000|channel;            
//              send command to SC08A in 2 byte - Mode with channel and ON/Off channel
                uart_send(first_byte);                              
                uart_send(on_off);
//              2nd byte: 1 = enable/activate; 0= disable/deactivate
}
//              command requesting position of servo channel
unsigned int request_position_cmd(unsigned char channel)
{
                unsigned char first_byte=0, check_id, higher_position, low_position;
//              First byte combined the mode and servo channel
//              ob xxx   xxxxx    (in binary)
//              mode channel
//              for servo positioning with speed command, the mode value is 0b101xxxxx
//              the channel value cannot be 0 in this command
                first_byte=0b10100000|channel;            
//              send command to SC08A in 1 byte - Mode with channel; after that SC08A will send back the position value
                uart_send(first_byte);                              
//              Received position from SC08A in 2 byte
                higher_position=uart_rec();
//              first byte is the higher byte of position 0b0xxxxxxx
                low_position=uart_rec();
//              second byte is the higher byte of position 0b00xxxxxx
//              combine the higher byte and lower byte into 16 bits position
                position=higher_position<<6;
                position=position|(low_position&0x3F);
                return position;
}
//              command servo starting position for next resetting of SC08A
//              this command is useful when you need the servo motor position to start at different position (not at the middle position which is the default starting position for the servo)
//              this subroutine is not use at the sample program
void init_servo(unsigned char channel, unsigned int position)
{
                unsigned char first_byte=0, higher_byte=0, lower_byte=0;
//              First byte combined the mode and servo channel
//              ob xxx   xxxxx    (in binary)
//              mode channel
//              for servo positioning with speed command, the mode value is 0b100xxxxx
//              channel = 0 meaning all channel
                first_byte=0b10000000|channel;            
//              initial position for the servo start on next time
                higher_byte=(position>>6)&0b01111111;
//              position value from 0-8000 are greater than a byte
                lower_byte=position&0b00111111;
//              so need two bytes to send
//              send command to SC08A in 3 byte - Mode with channel, higher byte of position and lower byte of position
                uart_send(first_byte);                                                                              
                uart_send(higher_byte);
//              second byte is the higher byte of position 0b0xxxxxxx
                uart_send(lower_byte);
//              third byte is the lower byte of position 0b00xxxxxx
//              after that, the SC08A will acknowledge the MCU with a byte, 0x04
                while (uart_rec()!=0x04)
//              wait the 0x04 value from SC08A
                {
                }
}
//              subroutine for UART
//===============================================================
unsigned char uart_rec(void)                   //receive uart value
{
                unsigned char rec_data;
                while(RCIF==0);                                     //wait for data
                rec_data = RCREG;                                                
                return rec_data;                                       //return the data received
}
void uart_send(unsigned char data)
{              
                while(TXIF==0);                                     //only send the new data after
                TXREG=data;                                                          //the previous data finish sent
}
void uart_str(const char *s)
{
                while(*s)uart_send(*s++);
}
/////////////////////////////////////////////////////////// END ///////////////////////////////////////////////////////////////
 




Week 7
Continue circuit development
After finish etching the circuit, dry it then drill the PCB board to place the component. Make sure use the mini drill to avoid the circuit connection from broken.
Place the component at the board follow the circuit diagram. Then solder the entire component.
The PIC Microcontroller circuit completion
The Voltage Regulator circuit completion
 




Week 6
3.0 Circuit development
After design the circuit use the Proteus simulation software create the PCB layout to print into PCB board.
This PCB layout is for PIC Microcontroller circuit. After that, print this PCB layout use laser jet printer to get the better layout. Then, iron the layout at the PCB board. Effects from this iron heat will leave the black line into the PCB board.
The PCB layout and the PCB board
Iron the PCB layout at the PCB board
The PCB layouts leave the black line into the PCB board
After that, etching the board into the etching liquid to get the cooper circuit layout
 




Week 5
Continue project development
Put the servo motor at the part of leg.
Finish put the servo motor at the robot leg. Make sure the servo motor position for each leg is correct and same.
Combine the robot leg and body together.
Make the shaft rod (clothes hanger) to connect between servo motor and robot leg. Long shaft rod refers to distance between servo motor and robot leg.
 




Week 4
Continue project development
After finishes build the part of leg, we continue to build the robot body follow the design sketches.
The part of robot body. The hole at the center is for servo motor placements. Make sure cut the plates safely because to avoid the plates from broken.
Make the screw hole to the robot body.
Put the servo motor and tight it use the screw. After cut the plates, use the sandpaper or fisted scar to make sure the plates is smooth.
 




Week 3
Continue project development
Use the acrylic plate acid to attach the two plates together. Beware, to use the acid because it will damage the plates.
For the movement part use the screw and nut to tight the plates. Use the suitable drill to make the screw hole.
Then, screw the movement part of leg together. Build 6 set for this part of leg because we develop the hexapod robot. Make sure the measure value between the plates is correct and sharp to get the satisfied leg.
 




Week 2
2.0 Project Development
            2.1 Acrylic
Acrylic had been selected to be a main material because it provides to reduce the overall weight of the robot, holes can be drilled into non-critical portions and easy to shaping and forming. For the Micro Runner, most of the six legged robot including its body and legs are built using 3mm acrylic plate. The body will be the platform that will allow for the robot’s motion as well as carry all the necessary circuits and power supply.
Acrylic plate
Sketch the design at the acrylic plate follow the leg design and body design. Cut the plate use the jig saw machine. Make sure the measure value is correct and sharp.
 




Week 1
1.0 Design Project and Circuit
1.1 Project Design
The Leg Design 
http://1.bp.blogspot.com/-eG7FlO4ec-w/ULiu5lIG7II/AAAAAAAAAE4/8VfjiZZCQP4/s400/design+base.bmp
The Body Design

This design uses the Microsoft Excel software. This 2D design is simple and easy to understand also look clearly.

1.2 Circuit Design 

http://2.bp.blogspot.com/-iwmsQXfVook/ULi0Ddb3c0I/AAAAAAAAAFI/gzal3orH_o0/s400/pic.bmp
PIC Microcontroller circuit

Voltage Regulator 5V 3A circuit

This design uses the Proteus simulation software. This simulation software is easy and simple to use. For the PIC Microcontroller circuit need the programming source code to function. This programming develops use the MPLAB compiler software. This compiler is suitable for C-language.


This MPLAB compiler software is to build the programming for the project. This compiler software is suitable for PIC 16F family and other PIC microcontroller user. However, all interface and program should be developed by user. This compiler software is related to PIC kit programmer and Proteus software circuit development.
http://kpadhnan.files.wordpress.com/2012/02/mplab-ide-8-5.jpg?w=298&h=300
The MPLAB Programming Compiler Software

This Proteus simulation software is that to design the circuit for the project. This simulation software is suitable for all design circuit and others controller circuit. However, all interface and design should be developed by user. This simulation software can relate to another PIC kit programmer and any other compiler software.

http://xtronic.org/wp-content/uploads/2010/05/proteus7.4L1.png
The Proteus Simulation Software