Sunday 22 September 2013

WALKING ROBOT USING SERVO MOTORS


I am making some projects with ATMEL AT89S52 and decided to create something that would fully use its potential. Then came the idea to construct a robot that would be able to  walk like a human. It was all realy simple in my head, create a skeleton with the same movement passibilites as a human and then write a program that would make it do the right moves.

 It seems simple but as it turned out there are a lot of things to calculate and take into consideration.

AND THIS IS THE MICROCONTROLLER

ATMEL AT89S52



Like i said before i decided to use ATMEL AT89S52. In the past i have made my own circuit to program it with my computer but it was too big and ugly to even think about puting it in a robot. So i decided to design a new circuit that would only power my kontroler up, provide needed signals and make it possible to connect other devices. I have connected 16 controller bytes which can be used as inputs or outputs and provided each one of them with GND and VCC.
So far my robot uses only 6 servos. It makes it possible to connect some kind of sensors or devices or even more servos in the future.

ASSEMBLING OF SERVOS ( MUSCLES )

After many experiments with motors and hydraulics i came to a conclusion  that with my tools I'm not capable of making anything more efficient than a servo. Fortunately i had few of them in my injured RC glider (very beautiful and effective crush). Servos like these are very strong. Another thing that speaks in favor of servos is the way that they are controled. A typical servo needs a signal at about 50Hz and depending on a time in which it receives a logical "1" it rotates itself to a right angle. If the signal is constantly provided the servo will correct its position in case of any changes, which is perfect for my robot in order to maintain the right angles betwen its legs. It would seem that servos are perfect but unfortunately they have a few disadvantages. Since they are created to be universal they have to be put in a proper housing for them to work the way i want them to, which adds unnecessary weight. The other bad thing about them is that they only have one axis which resulted in very bad consequences, but more about that in the next steps.
A perfect solution would be to create my own "servos" designed specialy for this robot which would minimize weight and exclud other problems as well.
Having your own machine that would create shapes you design at huge precision sure would be nice.



 Creating the skeleton for my robot was the most dificult part. I had to connect my servos together. From the materials at my home i decided to use 4mm plexiglas. In order to achieve a satisfying level of precision I had to spend many hours perfecting each part. If the parts wouldn't match the robot would have uneven legs and wouldnt be able to stand straight. It became clear that continuing making parts this way is impossible because in order to provide casing for the servos to add a second axis and create stable feet it would take months . At this time my robot would not get proper feet and without second axis on each serwo his legs would not stand the presure. Fortunately the four parts that i made are enough to test the koncept of human-like movements.

To program my controler I used my old programing board. As you can see it's much bigger than the board I created for my robot.

When i was writing my program i made sure that it would be easy to change settings of the servos.
My program is writen in Assembly language.
The first thing you see is a table, each column is a move,  thanks to special calculations in the program later on, the numbers next to s1(servo 1) s2(servo2).....are the exact degrees in which servos will lock themselves. Numbers next to TIME determinate how long each move will last, it's the number of periods program will do before it will move on to the next move, since servos are provided with a signal at 50Hz, one period lasts 0,02 seconds. The number of servos and moves can be easily changed.
The program takes the information out of the table and translate it so that each servo will receive a correct signal. The whole thing is pretty complicated and it would take some time to explain how it works but if anyone wants to I can explain it step by step.
Feel free to download the program, maybe you can use it to make your own servo based devices

As you can see my robot is doing some cool moves, and when I put him down he realy tries to walk but since he doesn't have any feet and each joint has only one axis he falls down. Apart from the fact that he cannot balance properly I think it's a succes. Just look at those nice moves! Of course at this time program contains only 4 separate moves but its not a problem to brake them down into much more and much better calculated moves, it's just a matter of time and experimenting with different timing and angles.


I don't want to stop at an "almost walking robot". In the future i'm thinking about adding an aditional servo with a special arm which will work as an counterweight so that the robot would not fall down when it's standing on one leg.
The main lesson from this project is that when constructing things like this the most important thing is low weight and stability. \\\those things can not be achieved with gluing a motor on to a piece of plastic.
I have created a full casing with 2 axis and arms that would fit perfectly on the next casing but it was too complicated and time consuming to make more (and it looked like it would weight too much). I decided to make a mold and cast it 6 times but it turned out that its not possible with materials that i have.
That is why my dream is to have a 3D printer. It would make creating stuff like these much easier and all my projects would become better, less time consuming and more complicated than it was possible before. The possibilities of what you can do with one of those are endless.

PROGRAM:

LJMP    START

S1:     DB      85,125,105,85 ,65 ;-5
S2:     DB      89,49 ,89 ,89 ,89 ;-1
S3:     DB      93,103,73 ,93 ,113      ;+3
S4:     DB      90,90 ,110,50 ,70
S5:     DB      88,88 ,88 ,128,88 ;-2
S6:     DB      82,82 ,62 ,72 ,102      ;-8
TIME:   DB      20,20 ,20 ,20 ,20


START:  MOV     R1,#00
MOV     DPTR,#S1
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO1
MOV     DPTR,#S2
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO2
MOV     DPTR,#S3
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO3
MOV     DPTR,#S4
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO4
MOV     DPTR,#S5
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO5
MOV     DPTR,#S6
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO6
MOV     DPTR,#TIME
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   WORK

AGAIN:  MOV     R1,#1
MOV     DPTR,#S1
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO1
MOV     DPTR,#S2
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO2
MOV     DPTR,#S3
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO3
MOV     DPTR,#S4
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO4
MOV     DPTR,#S5
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO5
MOV     DPTR,#S6
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO6
MOV     DPTR,#TIME
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   WYORK

MOV     R1,#2
MOV     DPTR,#S1
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO1
MOV     DPTR,#S2
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO2
MOV     DPTR,#S3
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO3
MOV     DPTR,#S4
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO4
MOV     DPTR,#S5
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO5
MOV     DPTR,#S6
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO6
MOV     DPTR,#TIME
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   WORK
MOV     R1,#3
MOV     DPTR,#S1
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO1
MOV     DPTR,#S2
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO2
MOV     DPTR,#S3
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO3
MOV     DPTR,#S4
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO4
MOV     DPTR,#S5
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO5
MOV     DPTR,#S6
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO6
MOV     DPTR,#TIME
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   WORK
MOV     R1,#4
MOV     DPTR,#S1
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO1
MOV     DPTR,#S2
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO2
MOV     DPTR,#S3
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO3
MOV     DPTR,#S4
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO4
MOV     DPTR,#S5
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO5
MOV     DPTR,#S6
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   SERWO6
MOV     DPTR,#TIME
MOV     A,R1
MOVC    A,@A+DPTR
ACALL   WORK

LJMP    AGAIN


SERWO1: MOV     B,#10
MUL     AB
MOV     R0,#30
MOV     @R0,A
MOV     A,B
ADD     A,#248          ;S1H calibration number
MOV     R0,#31
MOV     @R0,A
RET

SERWO2: MOV     B,#10
MUL     AB
MOV     R0,#32
MOV     @R0,A
MOV     A,B
ADD     A,#248          ;S2H calibration number
MOV     R0,#33
MOV     @R0,A
RET

SERWO3: MOV     B,#10
MUL     AB
MOV     R0,#34
MOV     @R0,A
MOV     A,B
ADD     A,#248          ;S3H calibration number
MOV     R0,#35
MOV     @R0,A
RET

SERWO4: MOV     B,#10
MUL     AB
MOV     R0,#36
MOV     @R0,A
MOV     A,B
ADD     A,#248          ;S4H calibration number
MOV     R0,#37
MOV     @R0,A
RET

SERWO5: MOV     B,#10
MUL     AB
MOV     R0,#38
MOV     @R0,A
MOV     A,B
ADD     A,#248          ;S5H calibration number
MOV     R0,#39
MOV     @R0,A
RET

SERWO6: MOV     B,#10
MUL     AB
MOV     R0,#40
MOV     @R0,A
MOV     A,B
ADD     A,#248          ;S6H calibration number
MOV     R0,#41
MOV     @R0,A
RET
WORK: MOV     TL1,#223
MOV     TH1,#177
MOV     TMOD,#00010001B
MOV     TCON,#01010000B
SETB    P1.0            ;beginning 1
MOV     R0,#30
MOV     TL0,@R0
MOV     R0,#31
MOV     TH0,@R0
CLR     TCON.5
JNB     TCON.5,$
CLR     P1.0            ;end 1
SETB    P1.1            ;beginning 2
MOV     R0,#32
MOV     TL0,@R0
MOV     R0,#33
MOV     TH0,@R0
CLR     TCON.5
JNB     TCON.5,$
CLR     P1.1            ;end 2
SETB    P1.2            ;beginning 3
MOV     R0,#34
MOV     TL0,@R0
MOV     R0,#35
MOV     TH0,@R0
CLR     TCON.5
JNB     TCON.5,$
CLR     P1.2            ;end 3
SETB    P1.3            ;beggining 4
MOV     R0,#36
MOV     TL0,@R0
MOV     R0,#37
MOV     TH0,@R0
CLR     TCON.5
JNB     TCON.5,$
CLR     P1.3            ;end 4
SETB    P1.4            ;beginning 5
MOV     R0,#38
MOV     TL0,@R0
MOV     R0,#39
MOV     TH0,@R0
CLR     TCON.5
JNB     TCON.5,$
CLR     P1.4            ;end 5
SETB    P1.5            ;beginning 6
MOV     R0,#40
MOV     TL0,@R0
MOV     R0,#41
MOV     TH0,@R0
CLR     TCON.5
JNB     TCON.5,$
CLR     P1.5            ;end 6
CLR     TCON.7
JNB     TCON.7,$
DJNZ    A,WORK
RET





No comments:

Post a Comment