CH3-R gait using ssc-32

I’ve recently built a hexapod using the LM brackets and servos. I too like the PICs, and used an 18F4620 AND the SSC32. you DON’T want to try to do the servo control for 18-26 servos in the same uP as the IK and navigation! Delegate running the servos to an SSC32 board.

There is a 12 servo gait engine in the SSC32, but one can’t easily “expand” it to 18 servos as I originally thought.

running 4-8 servos in the same uP is fairly easy. I do 4 servos in my Loki (small biped) 'bot.

Alan KM6VV

Yea that is what I was considering anyways, even if gait wasn’t controllable for the 3dof. I did however figure out a workable way to run more than 18 servos AND AI on one PIC. At 40MHz, and running 6 servo signals at once, you can get decent resolution using the ECCP module. Since each servo takes only a few ms, groups of six would need maximum of 7ms, and with 50Hz refresh I have another 13ms to do AI and sensors. The PIC operates at 10Mips, so 10k instructions/msec. I figure that would be more than enough. I can even use most of the 7ms the servos are running to run code, since the ECCP is interrupt driven.

But that would consume a good amount of time and debugging, so the ssc is much easier, like you said. Just to make sure I am on the right track, here is what I was thinking:

*There are 6 directions of travel if I always want the hexa traveling perpendicular to a line between any two chassis servo mounts (so any 2 servos are the front).
*I can narrow it down to 3 directions if I treat the opposite direction as a negative vector.
*To go reverse of one of the directions, I simply decrement instead of increment through the sequence and servo position tables.
*Sequence table will contain entries of which servo moves and when (1 table per servo, all syncronized)
*Servo position table (called by sequence table) will contain end points to send to ssc board.

I tried searching and could not find much on the process. If anyone could point me to a site or specific post on this site, that would be very helpful. Thanks.

Since the ssc has the 2dof gait built in, can I still use it? The 3rd servo only moves the last section of the leg. Other than that, it is pretty much a 2dof leg if you ignore that last section, or if you keep that servo in one position. Or is the gait more complicated than I am thinking?

Interesting!

You probably want to run 9 servos (3 legs of a tripod) at once. And actually you will be moving both tripods at once, on on the ground, and one up in the air. But I suppose 3 groups of 6 may not be that much of a delay (2.5 mS?).

It would be a challenge!

Actually, you might want to consider the directions of travel infinite! You’ll want to “rotate” the desired motion vector (possibly from a joystick) into motion for each leg of a CH3-R, or to a pair of motions for an in-line hex. Even if you just consider having 6 directions of travel, you’ll STILL have to rotate the motion vector for each of the legs (yes, half are mirrored).

Don’t get down to the “increment/decrement” level of the programming, think of it all at a higher level.

Look up IK on this forum. Also check out the Atom BASIC code generated by the free PowerPod program. You’ll see the IK calculations needed to move the legs.

Alan KM6VV

Cool. I will look that up. I am guessing the IK method uses algorithms instead of tables, with joysticks for direction vectors? I was considering using some arctangent routines, but I figured tables would be easiest. But I won’t be using this with a controller, it will be autonomous. I have ordered a ssc-32 btw.

Yes, basically cosine law, and right triangle solutions. You could pre-calculate the sin/cos of the motion vector rotate, thus saving those calcs over and over. Put them in a table!

Good choice! I like mine.

Autonomous yes! But you might still want to make up a vector for the desired motion, and add it the same way to determine the base triangle of each leg’s move.

So what’s the 18F4685 PIC got over the '4620? Do you program in C? If so, what compiler? I like the HiTech C compiler.

Alan KM6VV

I have been wanting to try out the HiTech compiler for the 16f series, but I was planning on using the C18 from microchip. I chose the 4685 because it has plenty of code space, 96k, but it does have less RAM than the 4620. I like getting PIC’s that I can use for multiple projects, that way I can get familiar with fewer PIC’s. Plus I ordered it before I thought of using it in a robot lol. I have not programmed a uC in C yet, just assembly. But I am familiar with C.

I was looking at that excel sheet for making sequences, but I don’t think it will be much use. I am gonna have to find some raw equations for this. Or just use pre-made tables and not worry about anything but getting it moving in 6 directions.

Good compiler! I have both the 16F and the 18F versions. You can get a free “lite” one for the 18F877.

96K would be nice, but I can also use the RAM! The PICs are fairly consistent, and code can be conditionally compiled to run on several variations or sizes.

Do you mean for the Phoenix? Yeah, I’ve been thinking about that too, but I don’t see a simple way to do it. The LM code will get you started.

Alan KM6VV

I will be starting to design the PIC software outline using a flowchart later today. If you want I can PM it to you, and when it is all done I can post the finished project. I am a member of the eletro-tech-online forums as well, so I will be posting it there as well. Hopefully I can have it done this week.

Sure!

Sounds good. We can swap ideas. I’m on the two lists below, if you’re interested.

What all are you planning in the way of sensors?

Alan KM6VV

PIR, Ping, current sensors(shunts) on servos for collision detection, ldr’s, sound (will listen for hand claps). I plan on using at least 3 PIR sensors so it can harass the cats. Two would be for wide view, one would have narrow view and be attached with Ping sensor on micro servo. So it will have sonic and IR radar for better tracking. I plan on making a head that will house the “radar”.

Where are you getting your IK formulas? I did find some arctangent routines for the PICs, but it could only calculate up to 45 degrees.

That’s quite a load of sensors! I’m planning on adding an additional controller board for sensors. But IR and Ultrasonic are about it for now.

Too bad they don’t make a 360 servo. Although there is a pair of gears on a plate that gear up for 360 degrees. I should probably buy a gear cutter, and make a large ring gear to rotate a platform of sensors.

Per one of my previous posts, see the code generated by the PowerPod program. It implements the IK calcs needed!

acos() should work OK:

/* C_TmpCos = (a^2 + b^2 - c^2) / 2ab */
/* *** Tibia is "c" side, Femur is "a" side, "b" is previous Cside  side of triangle */

C_TmpCos = (((double)FEMUR_LENGTH * (double)FEMUR_LENGTH) + CCside - ((double)TIBIA_LENGTH * (double)TIBIA_LENGTH) );

C_TmpAngle += RadToDeg(acos(C_TmpCos / (2.0 * (double)FEMUR_LENGTH * Cside)));

HipV_Angle = (signed int)(C_TmpAngle * (256.0 / 360.0));  /* (Atom BASIC Scale) */

Alan KM6VV

I found the picture in that sticky, so I am assuming that is what the code is referring to. I am looking that over now. I will have to find some sin, cos, etc code for the PIC. When you wrote “acos” do you mean arc cosine?

A 360 degree sensor base would be nice, but since I want the head to simulate actual head tracking it won’t be needed. I can always get a rear PIR sensor, and the Ping sensor does not need to look anywhere but forward.

Jim mentioned in one of the other threads that he plans for the SSC-32 to support *H3-Rs. I’m hoping that this 18DOF hexapod support will extend out to the Atmega8-based SSC-32s.

I’m also hoping that the release of this new support will beat me to the punch on my understanding of the IK calculations… :wink:

Yes, that’s the drawing. My code snippet relates to that pix. You ARE writing in C, aren’t you? From your recent posts, I thought you were. as to the trig functions, they’re already in all but the most tiny C compilers! What you get from Microchip or Hitec should be fine.

Yes, acos() IS the C function for arc cosine.

That’s true, with multiple sensors, a full 360 rotate probably isn’t needed. But I still like the idea.

Alan KM6VV

That would be very helpful. I did not realize how big a project this was going to turn into. I have been trying to locate the full IK code everyone is talking about. But maybe I should just make my own basic (no stance adjusting like roll, pitch, etc…) form of movement, since I only need it for autonomous, simple movement. And I am poor at trying to decipher someone else’s code.

OK, I didn’t think microchip would provide math functions in their compiler, but I have not looked yet either. I don’t want the 30 day trial to run out prematurely lol.

EDIT: just checked, it does have those libraries in the C18 compiler.

Hi Tom,

SSC-32 to support H3-R? I hadn’t read that. The new SSC32 doesn’t support 18DOF, as far as I know. I think I’d asked about that possibility at one time.

The older ATmega8 chip is full, and over tasked from what I understand. The new chip has some “headroom”, and greater possibilities. Just think if a full 18 servo IK engine could be “dropped” into the SSC32!

New support would be great, A white paper written on the subject would certainly be of interest me. When is it coming?

Alan KM6VV

If you need more rotation out of a servo, you might try a sail winch servo like below.

servocity.com/html/hs-785hb_ … tions.html

That’s an interesting servo! It could be “strung” with dial cord to a larger pulley to rotate a sensor deck.

Thanks for the URL!

Alan KM6VV

I have one of them, here. They are no good for robotics. It just vibrates when close to the commanded position. I can’t see how they would be good for anything. There must be tension in the rigging to prevent the hunting.