Ripple Gait - Pleae help

Hexapod Robots

Ripple Gait - Pleae help

Postby swingeyp » Wed Jun 02, 2010 10:10 pm

Hello I wonder if anyone can help me please. I am a relative newbie to microcontollers etc. I have a hexapod that I am trying to make walk. I would really like to go for the 'ripple' gait as I think this one looks better for 6 legs. I am coding in Pic Basic and I have a simple move the legs routine which works with a sevo controller i built around the 16F876 microcontroller. I can see from a timing diagram that things should be happening at rise, midway, and fall of pulses on other legs.

When the code begins with leg 6 something should also be happening on other legs. I have trawlled the net to no avail and all the books just give a timing sequence. I need to know something like :

leg 6 up, leg2 forward, leg4 down, leg1 back for example.

Can anyone please help me with my rather simplified code or tell me what should be happening at each part of the cycle?

Regards - Paul

Pic Basic - Pic 16F876A

Symbol leg1servo1 = PORTB.7 'J3 - Pin 28'
Symbol leg1servo2 = PORTB.6 'J4 - Pin 27'
Symbol leg1servo3 = PORTB.5 'J5 - Pin 26'

Symbol leg2servo1 = PORTB.4 'J6 - Pin 25'
Symbol leg2servo2 = PORTB.3 'J7 - Pin 24'
Symbol leg2servo3 = PORTB.2 'J8 - Pin 23'

Symbol leg3servo1 = PORTB.1 'J9 - Pin 22'
Symbol leg3servo2 = PORTB.0 'J10 - Pin 21'
Symbol leg3servo3 = PORTC.7 'J11 - Pin 18'

Symbol leg4servo1 = PORTA.4 'J12 - Pin 6'
Symbol leg4servo2 = PORTA.5 'J13 - Pin 7'
Symbol leg4servo3 = PORTC.0 'J14 - Pin 11'

Symbol leg5servo1 = PORTC.1 'J15 - Pin 12'
Symbol leg5servo2 = PORTC.2 'J16 - Pin 13'
Symbol leg5servo3 = PORTC.3 'J17 = Pin 14'

Symbol leg6servo1 = PORTC.4 'J18 - Pin 15'
Symbol leg6servo2 = PORTC.5 'J19 - Pin 16'
Symbol leg6servo3 = PORTC.6 'J20 - Pin 17'


Const uplimit = 200 'Set upper limit - max. 255, each step is 10uS
Const downlimit = 50 'Set lower limit - min. 0
Const forwardlimit = 50 'Set upper limit - max. 255, each step is 10uS
Const backlimit = 200 'Set lower limit - min. 0

Const midposition = 125 'Set mid position for servos'

TRISB = 0x00 'PORTB all outputs'
TRISC = 0x00 'PORTC all ouputs'
TRISA = %1111 'PORTA 0,1,2,3 inputs'


Dim pulse As Byte

Gosub centerservos

start:
Gosub movelegs
Goto start

stop:
End



'Routine to centre all the servos'
centerservos:
ServoOut leg1servo1, midposition
WaitMs 18
ServoOut leg1servo2, midposition
WaitMs 18
ServoOut leg1servo3, midposition
WaitMs 18

ServoOut leg2servo1, midposition
WaitMs 18
ServoOut leg2servo2, midposition
WaitMs 18
ServoOut leg2servo3, midposition
WaitMs 18

ServoOut leg3servo1, midposition
WaitMs 18
ServoOut leg3servo2, midposition
WaitMs 18
ServoOut leg3servo3, midposition
WaitMs 18

ServoOut leg4servo1, midposition
WaitMs 18
ServoOut leg4servo2, midposition
WaitMs 18
ServoOut leg4servo3, midposition
WaitMs 18

ServoOut leg5servo1, midposition
WaitMs 18
ServoOut leg5servo2, midposition
WaitMs 18
ServoOut leg5servo3, midposition
WaitMs 18

ServoOut leg6servo1, midposition
WaitMs 18
ServoOut leg6servo2, midposition
WaitMs 18
ServoOut leg6servo3, midposition
WaitMs 18
Return


movelegs:
Gosub leg6
Gosub leg1
Gosub leg5
Gosub leg3
Gosub leg4
Gosub leg2
Return




leg1:
'move leg1'
'should already be in the mid position from power up'
For pulse = midposition To uplimit 'raise the leg'
ServoOut leg1servo1, pulse
WaitMs 18
Next pulse

WaitMs 10 'wait a bit'

For pulse = midposition To forwardlimit Step -1 'move it fully forward'
ServoOut leg1servo2, pulse
WaitMs 18
Next pulse

WaitMs 10 'wait a bit'

For pulse = uplimit To downlimit Step -1 'move it fully down'
ServoOut leg1servo1, pulse
WaitMs 18
Next pulse

WaitMs 10 'wait a bit'

For pulse = forwardlimit To backlimit 'move fully back'
ServoOut leg1servo2, pulse
WaitMs 18
Next pulse

WaitMs 10

For pulse = downlimit To midposition 'legs back to middle height'
ServoOut leg1servo1, pulse
WaitMs 18
Next pulse

WaitMs 10

Return

leg2:
'move leg2'
'should already be in the mid position from power up'
For pulse = midposition To uplimit 'raise the leg'
ServoOut leg2servo1, pulse
WaitMs 18
Next pulse

WaitMs 10 'wait a bit'

For pulse = midposition To forwardlimit Step -1 'move it fully forward'
ServoOut leg2servo2, pulse
WaitMs 18
Next pulse

WaitMs 10 'wait a bit'

For pulse = uplimit To downlimit Step -1 'move it fully down'
ServoOut leg2servo1, pulse
WaitMs 18
Next pulse

WaitMs 10 'wait a bit'

For pulse = forwardlimit To backlimit 'move fully back'
ServoOut leg2servo2, pulse
WaitMs 18
Next pulse

WaitMs 10

For pulse = downlimit To midposition 'legs back to middle height'
ServoOut leg2servo1, pulse
WaitMs 18
Next pulse

WaitMs 10

Return

blah blah blah

leg6:
'move leg6'
'should already be in the mid position from power up'
For pulse = midposition To downlimit 'raise the leg'
ServoOut leg6servo1, pulse
WaitMs 18
Next pulse

WaitMs 10 'wait a bit'

For pulse = midposition To backlimit Step -1 'move it fully forward'
ServoOut leg6servo2, pulse
WaitMs 18
Next pulse

WaitMs 10 'wait a bit'

For pulse = downlimit To uplimit 'move it fully down'
ServoOut leg6servo1, pulse
WaitMs 18
Next pulse

WaitMs 10 'wait a bit'

For pulse = backlimit To forwardlimit Step -1 'move fully back'
ServoOut leg6servo2, pulse
WaitMs 18
Next pulse

WaitMs 10

For pulse = uplimit To midposition Step -1 'legs back to middle height'
ServoOut leg6servo1, pulse
WaitMs 18
Next pulse

WaitMs 10

Return
swingeyp
 
Posts: 1
Joined: Wed Jun 02, 2010 9:56 pm

Return to Hexapods

Who is online

Users browsing this forum: No registered users and 2 guests