Arduino Code

Im using the Arduino IDE off OSX Lion, my microcontroller is a Arduino Mega2560.
Kit is essentially the AH3-R with a tiny body, servos however are HS485HB.
I’ve got my construction, and circuitry down, guys!
But unfortunately…
Well before, it was my power supply. Thats all good now, except for an unfortunate measuring problem (My LiPo is a couple of millimeters too big to fit properly in my tiny body).
Anyway, on to CODE!

Im stuck.

Earlier I said I had my programming done. Ehhh… No. I am an idiot.
First off, im not using an ssc-32 or something. Im running the thing off of an Arduino Mega(R2).
I could write it out piece by piece, but… It would be horribly inefficient and long and ugly. And stupid.

I’ve heard about Inverse Kinematics, researched it a bit, and am thoroughly baffled as to how I am supposed to use the arduino’s servo library to control 18 servos using this technique. I got it up and running on Processing, but thats just drawing lines.
So!
How do I make the damn thing to walk? I just need help figuring out how to make legs move in a tripod movement. Omni-Directional would be nice, but at this point I just want help making it move forward in a tripod gait.
Soo… code or help coding please?
Thanks all, and Happy New Year!

Basically, you can translate the Phoenix or PowerPod code to C or whatever you want to use.

Write an interrupt routine to service the 18 servos. It would replace the serial calls to the SSC32

You can get the tripod gate out of the code. Search the forum for code that’s already been converted I think Kurt’s got some Arduino code already.

Alan KM6VV

Alan KM6VV

Yes I ported the Phoenix code to arduino. See thread viewtopic.php?f=20&t=6730&start=119

Kurt

Thanks!

Doh! The Arduino Mega does not have the power to generate the IK for 6 legs AND generate servo pulses… Kurts code uses the Arduino and the SSC-32.

How about the MadHatter, or the ChipKit Mega32?

Alan KM6VV

The Mad Hatter only has 13 digital pins (2 used up for USB) and 6 analog pin, so there are not enough IO pins to do a 3dof Hex… As for horsepower it has the same chip in it as the Arc32, so could be done.

Chipkit Max32 - I believe could easily do it. Using the SoftPWMServo library, which hooks off of the main system timer. If you look at the readme as part of this library:

Kurt

Yeah, the 80 Mhz PIC on the Max32 is not bad!

I may have been thinking of the ARC32.

So many choices!

Alan KM6VV

IK has been nearly abandoned (I might choose to do it pc side), working off of servo pulses generated by the Mega. So far its a lot of little for loops that are switched by case and given values generated by mouse being dragged across screen. Still in progress, but is this too inefficient?

Yeah, that’s a tough way to go!

If you write the servo values in a set of tables for the gait cycles, then you can “step through” the tables to command the servos as you move. The servos would be updated by a timer-driven interrupt. I’ve don this for a 4-servo “Loki” walker (up to 8 servos), it’s a little more work to do 18 servos!

Again, if you had 18-servo interrupt support code, you could almost “drop it into” some of the existing code using IK.

Is there some reason you don’t want to just use the SSC-32? It’s well worth the cost for a project like this. I used one when I wrote my own C code for an 18F4620 PIC. and homemade body.

Alan KM6VV

Oh, I would love to use the ssc32, however this is a project for school and my teacher and I wanted to do without a servo controller. Very unfortunate decision, but It seems that it is teaching me a lot!

do you have to do 3DOF? 2DOF might be more achievable. Simpler gait cycles.

Alan KM6VV

Seeing as I had to personally buy the parts for the class… I’d like to continue using 3DOF. Anyway, ran into a new problem. all servos approach mid at once… which isn’t what I tell them to do. Ideas?

Do you seriously think this is enough information for anyone to be able to help you? :blush:

good point :confused:

anyway in the setup, i run a couple of for loops that tell the servos to attach to pins and then to tell which set of servos to move to middle point of 1500ms. Problem is, instead of moving only the six servos attached directly to the body first, it moves all 18 at once. Ithis was done using two for loops to tell which servos to move. tried w/o the loops, basically wrote out every command for each of 18 servos and had the same problem. delay() does not work, is this a hardware problem?

Please just post the code…

Uee the code brackets like below without the spaces.

code ] if a = b then c your way home / code ]

As Robot Dude mentioned, it is hard to know how to help here without seeing some additional information. I have posted code up in the forum for a few different Arduino based robots. As mentioned in a previous post I have ported the Phoenix code to the Arduino using an SSC-32. I have also ported some biped Brat code to Arduino, which used the Arduino to drive the servos (viewtopic.php?f=48&t=7590&p=77519#p77519). In this thread, I had a modified version of the Servo library that did group moves or timed moves. I have used it for a 6 servo Brat, but have not tried out the servo library for 18 servos, so not sure how well it will work or not.

It is not difficult to convert the phoenix code to drive the servos. Have done that on a couple of different platforms. There are just a few functions that need to be updated to make it work, the main ones are: UpdateServoDriver, CommitServoDriver, FreeServos.

There are issues involved, like is there enough performance to drive the servos and to do the IK calculations…

If you use SoftwareSerial library, it disables interrupts while it inputs our outputs a character which will cause the servos to not be very steady, so you need to avoid this…

But again it is difficult to help more as we have very little to go on.

Kurt

Yeah I wasn’t sure if the Arduino could even do 18 servos in the first place.

Assuming they are using a mega, the servo library documentation, says:

(It uses one 16 bit timer for each group of 12 servos and the Atmega1280/2560 has 4 it can use.

Kurt

Well there you go. lol