Quadropad Headache

http://i31.photobucket.com/albums/c391/ZeRoC00l/FYP/IMAGE_00025-1.jpg
Hi, I’m a final year student in Singapore. Doing my final year project in robotics… the best part of it… the uni is paying for everything :laughing: :laughing:

The body + legs is about 6" length X 8" width
Current setup:
servo controller: DIY PIC18F252
Main processor: PIC18F4550
RF transmitter
CMU cam: 30fps
4 X gnd contact switch
1 X accelrometer
12 X HS422 servo motor
** Using Microchip is a criteria of the project

Objective: Build a 4 legged robot, ability to “walk” over grass patch/ dirt track, send images back to “HQ”, and most importantly move about autonomous :unamused: :unamused:

Uptodate, I’m kinda stuck with the above design… :cry:

I’m suppose to integrate a touch switch (on a budget here) on each foot, have already ordered a acclerometer to integrate onto the bot and reading up on inverse kinematics now…

The robot can stand on it’s own relying on the resistance of the servos, but that’s it. I’ve yet to install the control PCB and the heavy batteries.

I’m looking at using 6 X AA for the servos, and a seperate 9V for the IC chips.

For the 1st stage, I am looking to program the servo controller to have a stable walking gait. Something that is smooth like the hex tripod gait

Wonder if can get some advice from the seniors here, on how should i go about programming this creature :question: :question:

Hi Student,

Sounds like a great project! Rather ambitious, 'tho. I like the idea of the two PIC processors! I’m a fan of that approach myself.

As to how to program it, I’d start by studying the SSC32 for the servo controller (code available on website). And then Atom code for the 'bot computer (also available?). I know the Atom code (BASIC) is available for hexapods, I don’t know about quadrupeds.

In fact, I’m not sure what kind of a gait people are using for quads. For hexapods or octapods, you can use a stable 3 (hex) or 4 (octal) legs move per step. Humans move one foot at a time, quads move two (mostly?). Trouble is, moving one or two legs per step does not make for a stable support step (state)! Tripod or terapod gaits are stable for each step, making them much easier. Techniques needed appear to be shifting the center of gravity, falling and catching, and stepping quickly! (my impression). Sure you can’t shift to a hexapod? ;>)

I’m currently working to develop a gait generator for an 18F4550 PIC. I’m first porting over the Atom BASIC code for a round hexapod 'bot to ‘C’, then after I’m familiar with the IK (inverse kinematics) and have communication with a PS2 joystick (pad), I can work out a small multi-process controller program to do IK, PS2, and some navigation.

For the basic servo drivers, I’ll stick with the SSC-32 for now.

As for the C compiler, Hi-Tech is working for me now.

I’d welcome conversation on your project!

Alan KM6VV

Just sort of quickly thinking about quadrapeds and gaits it seems like the only natural quadrapeds that can establish a static 2-legged pose also have a significant tail mass for balance. every other common critter I can think of does not tend to lift more than 1 leg off the floor unless they are moving. so I think your trick to master will be an ability to calculate not only the IK but factor inertia of your movement into your gait. in short, once a second leg comes off the floor you need to be moving the entire body towards placing the first leg back down and you can’t stop moving until you do or you will likely tumble.

Looks good, im sure that the servos will work fine with the batteries on it if with no power the servos hold the quad up fine

I remembered one of the foum members had a problem with a quad gait which he solved by putting the batteries on a slide and have a servo move the batteries to balance out the weight

KM6VV: I am using 2 PIC to reduce the load off the main processor as there is also a cmu camera and RF antenna to program

Thanks for the advice, will check out SSC32 source codes. I have a hard time finding a gait for quads, as mostly are Hexapods :cry:

IK is really interesting and am slowly getting the hang of it… though yet to start the programming stage yet :confused: :confused:

EddieB: Yup, I’ve read about shifting weights which “walking” to balance, am looking to split the swinging motion into 3 portions: fore / centre/ after

With each new step taken, the other 3 legs will be pushing the bot body forward, hence each leg will move from fore to centre or centre to after. While the leg in the air will swing to fore position b4 placing down on the gnd.

I’ve yet to clearly sort out the specific details, as programming are still in the development stage. I’ve sorting out some psudo codes and algo first. :blush:

Chunga: Thanks for the tip!! :stuck_out_tongue: will look into trying that out if balance is really an issue.

Thanks for the tips peeps.

Will post updates as i go along, and keep the suggestions flowing. I’m open to anything new n radical!! ** My name’s Zack by the way

Really enjoying myself here :stuck_out_tongue:
2 X 3 DOF legs up!! got not thumbs on my bot

Hi Zack!

Glad to meet 'ya! I saw a video clip of a BIG quad walking (big dog?), and practically running as well. Fantastic! Perhaps if they have a website you could inquire as to the gaits they use. I’ll try to run something down for you.

It’s funny; the six legged robots probably have the most servos and are easier to get walking, while the 4 legged ones are in the middle, and the bipeds have the fewest servos, but are perhaps the hardest to get walking!

update: Boston Dynamics, 28Mb BigDog.WMV file. Looks like opposite corner legs basically move together. The gait is thus two alternating pairs of legs. Humans move alternating legs (naturally), hexapods move two tripods of legs, octopods move two alternating terapods. Ripple gaits are also seen in insects. I don’t think that applies to quads! BigDog TROTS!

“It is a quadruped robot that walks, runs, and climbs on rough terrain and carries heavy loads.”

bostondynamics.com/content/s … ion=BigDog

Alan KM6VV

Thanks for the link. :laughing: Yup saw it and IT’S way out of my abilities, but am taking notes on the walking gait

I’m facing a problem witht he HS422 servos.

I was tolded by my programmers that he can’t get the servo to move from left to right in smooth transition :unamused:

I know at full left is 1ms and full right is 2ms, centre is at 1.5ms for a 20ms period

IS there something wrong with my servo? or something wrong with my defination for the timings?

Can someone kindly enlighten me? :bulb: :bulb: Or direct me to some source codes so I can move my servos? Now I am stuck with moving the servos turning clockwise only

  • I’ll post a sample program once i get my hands on it from my programmer

Cheers

Er, I think the first thing I’d try is displaying the PWM output your PIC is generating up on a scope and determine if it’s the servo or its command signal from the PIC that is, um, bouncy. :wink:

Hi Zack,

That doesn’t sound right. Plenty of other “programmers” are able to make a smooth transition between 1 & 2 mS. Eddie had a good recomendation, put a 'scope on the outputs. I think there are mentions of using a servo tester, a BASIC Atom or SSC32 to give commands to a servo. A “tester”, if you will. Also a good way to learn what a good servo signal looks like.

Yeah, let’s look at the code. C code for a PIC? There is a UBW project that can drive R/C servos. I’ve built it. Order from SparkFun. About $20 US.

[greta.dhs.org/UBW/index.html](http://greta.dhs.org/UBW/index.html)

This is code complicated when taken on the whole, but you only need to study the user.c file to see the details on the servo code. It’s not the same as SSC32 code, mind you!

The “BIG DOG” is way past me as well. However I think you can see the gait. Gaits for two and four legged robots probably need to make a slight “push off” the ground. This I believe tends to shift the center of gravity momentarily until the foot/feet come to a new rest. Hexapod and Octapod gaits are normally stable, and this push off doesn’t appear to be needed or used.

Alan KM6VV

Measured with scope and got a 20ms PWM

Here’s the test program I used to rotate the servo :confused:

To turn Left:

PORTB = 0x00; // OFF
Delay_2kcyc(); // OFF delay 19ms
PORTB = 0x01; // ON
Delay_1kcyc(); // ON delay 1ms

To turn Right:
PORTB = 0x00; // OFF
Delay_3kcyc(); // OFF delay 18ms
PORTB = 0x01; // ON
Delay_4kcyc(); // ON delay 2ms

The problem now is the servo only turns clockwise… After centering the servo, it turns to the right (90 degree), then it doesn’t turn back to centre anymore… :confused:

Thought the servo might be a rotten egg so tried with another 2 servos and all give me same result :question: :question: :question:

The code seems correct, so I suspect wiring. Are you sure the servo has a good ground reference to the chip generating the pulses? If not this can cause the symtoms you are describing. However if there is an error with the actual time delays, sending servo pulses that are out of spec can also cause the only one direction problem. If this is a hHitec servo it will move clock wise with larger on pulses. Or in other words the servo will move to the CCW position with 1mS and to the CW position with 2mS. If the pulses are really out of whack, longer than they are supposed to be, then it would turn to the right. Does the servo pulse to the right or move rapidly? Also can you move the servo output shaft back to the left while it’s powered up?

Hi Zack,

I agree with Jim that the code looks correct.

Actually, it’s a 1 - 2 mS PWM, at a 20mS rep rate. There is thus “room” for 10 servo PWM signals, one after another in a 20 mS “frame”.

I’d use the scope again and measure the 1mS and 2mS pulse widths. A loop generating one of the positions continuously will allow you to see the pulses developed. As you know, the pulses must be re-issued every 20mS. This is the rep rate you observed.

I’d also program in a 1.5mS pulse to take the servo to center. Is the servo installed or connected to anything that might be in a bind? It’s also possible as Jim observed that the timing delays are incorrect. Which processor, compiler are you using again?

Alan KM6VV

Hi to the list,

I just got this link for a video on Youtube. It’s a quad with wheels on it’s four legs! Just a little conventional walking up front, then it skates around!

youtube.com/watch?v=sYIzGjLNIyI

Alan KM6VV

To: Robot Dude

Just as you suspect, I’m powering the servo from a seperate power supply.

I’m using Microchip PICDEM 2 PLUS demo board for programming the PIC18F252 chip. Taping a signal from RB0 to the servo signal pin. And the servo is drawing power from a lab power supply of 6V

I’ve managed to move the servo turn CCW, but the pulse width is totally out… I’m using a 0.5ms to turn the servo fully CCW. The movement is one smooth sweep CCW, and my power supply shows a high current spike once it reaches fully CCW :open_mouth:

To: KM6VV

Yup, I do see a stream of pulses every 20ms

Servo is not install to anything, just lying on the work bench

Using Microcip inhouse MCC18 complier, chip as mentioned is PIC18F252


I must be doing something wrong cos when I set the servo to turn CW, i am actually able to turn the servo horn CW without any resistance. But if i try to turn the servo CCW, I see that the servo is resisting, with a much higher draw in current.

Just to be absolutely clear, you should see only a single pulse every 20mS, active high and at nearly the positive supply level, from 1.0 to 2.0 ms in duration for a standard 90 degree servo input.

Hi Zack,

I’ll try to slip your code into the program I’m working on (18F4550 @ 40 Mhz) for a quick test, and see how it does. Too bad I didn’t take a few servos and a 'scope on vacation with me. But my wife would probably have objected!

What timer code are you using? Can you give me a link to the header files and code file(s) for the timer? That’s about all we haven’t checked. Your statement that you were at .5 mS has me wondering. Perhaps you should be using uS delay routines, to get the accuracy needed. Are they part of the delay code you’re using?

Alan KM6VV

Was the entire code posted somewhere and I missed it? The only thing I saw was the 2 small clips of the top level calls it was doing. If you post the code then even folks without the particular chip can run it up in the simulator and verify its output. :wink:

My cable for tying the Gnd on the breadboard was broken… :open_mouth: Anyway, managed to make some progress on the servos…

Am in the process of geting 1 leg moving…

To: KM6VV
I’ve posted my code at the bottom

To: EddieB
Nope. I didn’t post the entire code as my programmer wasn’t around the other time. ** i’ve posted the code at the bottom

Any kind soul can kindly enlighten me on the problem? Cos i’m staring all day and I don’t see what’s wrong. :cry: :cry: I’ve got another 3 other legs to combine once I can get this 1st leg to move accordingly

Cheers :smiley:

My robot codes so far :blush:

Objective: to rotate(-15,0,15) 3 servos 1 after another. Each servo will turn 15 degrees each time, while the rest hold their position.

BUT I am not getting that. Somehow after after the 2nd servo turns, ALL 3 servos goes haywire :imp:

#include<p18f252.h>

int servo[12];
const int FULL=1333;
const int EACH=100;

int servosRunning=3;

int port[12];

void initPorts(void)
{
port[0]=0x01;
port[1]=0x02;
port[2]=0x04;
port[3]=0x08;
port[5]=0x10;
port[6]=0x20;
port[7]=0x40;
port[8]=0x80;
}

void setServo(int servo_number, int angle)
{
long int i=(30)*(45+angle);
i/=90;
servo[servo_number]=32+i;
}

void goToAngle(void)
{
int i,j,temp;
char k,l;
PORTB=0x00;
for(l=0;l<30;l++)
{
i=9;

	for(k=0;k<servosRunning;k++)
	{
		temp=servo[k];
		PORTB=port[k];
		for(j=0;j<temp;j++,i++);
		PORTB=0x00;
		for(;j<EACH;j++,i++);
		i+=4;
	}
	
	for(;i<FULL;i++);
}

}

void main(void)
{

TRISB = 0x00;

initPorts();
setServo(0,-45);
setServo(1,20);
setServo(2,30);


while(1)
{
    goToAngle();
	setServo(0,20);
	goToAngle();
	setServo(2,-20);
	goToAngle();
	setServo(2,30);
	goToAngle();
	setServo(0,-45);
	goToAngle();		
}

}

I still got it! :smiley: Does the happy dance… :smiley:

My bot took it’s 1st step!! :laughing: Will try to post a clip over the wkend

I’ve got 2 questions:

  1. I’ve got 4 foot contact sensors and an accelerometer… where do I connect these? To the main chip or to my walking chip??

  2. My servos: HS422 can’t lift up my bot from a lying position… :confused: Is there anyway, for my bot to stand up by itself? Or is there some technique or “ideal” position to set the bot down so it can stand up by itself?