Phoenix code my MG90 hexapod

Ok i undestand the “feet start positions”

Unmodified code example:

#define cHexInitXZ 105
#define CHexInitXZCos60 53 // COS(60) = .5
#define CHexInitXZSin60 91 // sin(60) = .866
#define CHexInitY 25

Ok the iniatial XZ is 105mm

Cos60= .5
Sin60= .866

So to find Cos60 i take .5 and multiply it by 105mm and you get 52.5. Round that off to the nearest integer =53

To find Sin60 i take .866 and mutiply it by 105mm and you get 90.93. Round that off to the nearest integer and you get 91.

Since we know that to be true…

My modification

I can take my initXZ=45mm…

And to find Cos60 i multiply .5 by 45mm which will give me 22.5. Round that off and i get 23mm

To find Sin60 i multiply .866 by 45mm and get 38.97. Round that to 39.

So it should look like this…

#define cHexInitXZ 45
#define CHexInitXZCos60 23 // COS(60) = .5
#define CHexInitXZSin60 39 // sin(60) = .866
#define CHexInitY 25

Now how should i take care of the initial Y measurement?!

Thank you Coleman for all your help in getting my bot up and going. I do appreciate your help and your customer service is awesome.

Xan thank you for getting back to me and for your advice. I know your busy blowing minds and i appreciate your time as well.

Well i feel like that should have worked but it just went all weird. The comment for the “inity” is thirty maybe i should give it an integer higher than 30.

With the unmodified code it tripods ok but i cant seem to switch gaits. At one point i did get to wave but it was too sloppy to really walk.

Also now the d-pad up lowers the bot and d-pad down raises the body.

Oh you mentioned something about the way i powered can you elaborate?

Is there a way to fine tune it? The walking i mean.

It sounds like the calibration needs to be re-done - and it also needs to be close to perfect. Ensure that it actually saves to the SSC-32U.

Regarding the power, most people just use a 6V battery rather than a much higher voltage battery and a regulator. What you are doing is not wrong, just different.

Power:
When walking in high speed the servos’s can easly draw up to 10 Amps. In some bot’s I use a 6V NiMH battery for the servos and a 9V battery for the board. In others I use a 7.4 lipo with a regulator for the servos. The board is directly feed by the battery since that got it’s own regulator onboard.

Calibrating:
I can not say this enough. Calibrating is the most important thing with a hexapod! If you don’t calibrate correctly you can not get fluent movements. See the phoenix manual for more information. Also make sure that your frond and back legs are in the 60 deg configuration. Use the SSC-32 memory to store the offsets.

PWM to Angle:
It can happen that the servo’s vary in PWM to angle range. I even found that some Hitec servo’s (same type) do not all have the same conversion factor. If you take a look in the servo driver function you will see that there is a conversion factor calculating the PWM to angle. This is an average from the servo’s I use on my phoenix :wink:
It could be that this is different on yours. Try setting your servo’s to +/- 90 deg and see what PWM comes with that. Compare those values with the ones in the code.

IK:
Since you build your own bot you need to enter the dimensions of your bot. Dimensions are, length of the tibia (servo axis to tip) femur (axis to axis) coxa (axis to axis horizontal only) and all coxa positions (relative from the center of the body)

Starting pos:
The starting position can be set using the values you already found. The values are X, Y, Z positions so this should be pretty forward.

Xan

Ok just to be sure since the lynmotion calibrate program has several different set ups. Which one of these are the correct way to angle the legs?

i1254.photobucket.com/albums/hh601/Duhjoker1/Quadruped/2DA5FEB9-0BB0-48D5-8E52-707A3B576FC9_zpsmmoajita.jpg

i1254.photobucket.com/albums/hh601/Duhjoker1/Quadruped/800D4071-A2D7-4437-BFFB-ED368E9DA319_zps9pa8leew.jpg

Also for some reason i cant get the lynxmotion calibrate tool to recognize that there is a board connected to it. Could it be the baud rate. Ive got the board set to 38400 does the calibrate tool run on a different baud rate.

I can use both lynxterm and the servo sequencer utility and i was wondering how exactly do you save the settings to the board after calibration? Theres a button on the sequencer at the top right but i think its only saving it to my computer.

Can you show me a pic of 60 degree configuration please?

I looked at all the code files and im not seeing the conversion factor.

I commented out all the 4dof stuff in the config file, does this need to be done in the rest of the program files as well?

Hitec HS645MG servos

Rotational range = 180*
Pulse cycle = 20ms
Pulse width = 900 - 2100

MG90 servo

Rotational range =180*
Pulse cycle = 20ms
Pulse width= 400 - 2400us

ok I see there is a definite difference in PW between the Hitecs and the Tower pros. Now how do I fix that with in the code.

Also i noticed the code im using is for a CH3-R and mine is more like a phoenix H3. Shouldnt i be using the code here?

github.com/KurtE/Arduino_Phoeni … /Hex_Cfg.h

Temporarily use Lynxterm (legacy software, so our apologies if there are installation issues). This needs to be connected directly to the SSC-32U.
You ten go to “Setup” and choose baud rate etc.
Once that is done, connect the board.
You can then click “Firmware” and then “Read” to see the offsets. Adjust accordingly and then click “write”.

Thank you for that!!!

Still need to know how to change the servo angle conversion factor and which of the files has the conversion factor. Xan’s right with out the correct PWM in the code it will just keep acting the way it does.

Would this be the conversion factor you spoke of?!

#define cPwmDiv 991 //old 1059; #define cPFConst 592 //old 650 ; 900*(1000/cPwmDiv)+cPFConst must always be 1500 // A PWM/deg factor of 10,09 give cPwmDiv = 991 and cPFConst = 592 // For a modified 5645 (to 180 deg travel): cPwmDiv = 1500 and cPFConst = 900.

Ok my servos pwm ranges from 400 - 2400. Do i need to calibrate at 1400 in order for everything to be centered since that would be the center?

Ok we changed the PWM settings to

#define cPwmDiv 936; #define cPfconst 538; // 900*(1000/cPwmDiv)+cPFconst must always be 1500 // 900 * 1000 / 936 + 538 = 1499.54
I also noticed un that file a couple lines that look like they define 3dof or 4dof. Do i need to comment out the define 4dof?

I ran across this in the hex_globals.h file and was wondering if it needed changed too.

[code]#define WTIMERTICSPERMSMUL 64 //BAP28 is 16mhz need a multiplyer and divider to make the conversion with /8192

#define WTIMERTICSPERMSMUL 125

#define USRINT_TIMERAV
[/code]
When i put the bot on a pedestal and apply power and hit the start button, then try to walk it, the front legs come all the way to thier most forward position. And all the femurs push the tibias (or Try) down further than ground level.

Do i need to change the mechanical limits in the config file?

Hey guys

Im trying to phoenix a small hexapod using MG90 servos, an SSC-32U, ps2 TX/RX pair and a 3d printed frame.

I was hoping you guys could help me finish my project. Ive changed alot of the code to match my bot but i still cant get it to walk properly so must be something i either have wrong or dont know it needs changing.

I have no problems using the single leg movements or raising and lowering the bot and even turns on the spot okish but it goes haywire when you try to make it walk. It doesnt lift the leg high enough but brings the leg down farther than it needs to go. Also the coxa rotation is way out there bringing the leg to farthest limit.

The list below are the modifications to the code for my hexapo.

Leg IK

Coxa length=== 12mm
Femur length=== 35mm
Tibia length== 51mm

Body IK

-41
51
-51
0
-41
-51

41
51
51
0
41
-51

ChexinitXZ === 47
Cos60 === 24
Sin === 41
Inity === 51 // i couldnt figure out this number so made it the length of tibia.

I also changed the pwm settings in the servo file to

#define cPwmDIV 936;
#define cPfconst 538; // 900*(1000/cPwmDiv)+cPFconst must always be 1500
// 900*1000/936+538= 1499.54

Is there anything else im supposed to change?

I found this in the hex globals file do they need changing?

#define WTIMERTICSPERMSUL 64 //BAP28 is 16mhz need a multiplyer and divider to make the conversion with /8192

#define WTIMERTISPERMSUL 125

#define USPRINT_TIMERAV

Do the arcos and sin tables need to be recalculated to my bot?

I would like to publish a list of variables and other things that need to changed to make it easier for others having trouble.

In reply to your previous post:

The 645MG accepts a signal from 500 to 2500, not 900 to 2100. Most RC servos operate the same way and it seems odd that the MG90 would be different.
We understand why you are modifying the values in the code, but keep in mind that the Phoenix code is used as-is for a range of hexapods (different sizes and configurations), so ideally there should not be any need to change the code unless the servos you are using are either in a different configuration (0 and 180 are reversed) or the pulse range is different (to be confirmed).
Can you reiterate the current state of the robot? From what we recall, it does respond to PS2 input, and does seem to want to walk, but doesn’t walk properly? Can you post a video?

Sorry been a busy last few days and havent had much time to work on the hex.

Ok i refer the this post on the PWM range

phoenix-code-my-mg90-hexapod-t13356/90#p120320

And in this post Xan says about mofifying the code to my particular bot here…

phoenix-code-my-mg90-hexapod-t13356/90#p120352

Yep i got the PS2 controller to work. All i had to do was remove the level shifter from the RX and it started working. I can make the bot sway back and forth just fine, up and down, and even the single leg functions work. But when I use the joysticks it will not raise the femur much and pushes farther down than it needs to go. It also rotates the coxas way to forward.

I can change any modifications i have done to the code back but it actually works better modified.

Im actually thinking i need to change the mechanical limits. As they are now at the front left coxa the leg swings so far out maybe if i change the limit it will swing right.

Another problem i was thinking about was the calibration tool. I know that it saves the legs positions but does it save the body configuration? So if i have it on phoenix body or ch3 body does it save that i calibrated it to phoenix or ch3?

Heres the link to the last video i made. I havent altered the bot since…

youtu.be/eftuerfLkr8

Update ::::

Earlier i mentioned to you that D-pad up lowered the bot while D-pad down lifts the body up. According to the code and the tutorial its reversed. D-pad up should bring the bot up and vice versa.

Now ive also been saying that the legs go farther down than they come up when trying to walk. So that leads me to conclude that the down strokes are supposed to going up the upstrokes are supposed to be bringing the leg down to ground level.

Also want to point out again that turning left or right is pretty good.

Ok just double checked everything. First i checked it using the sequencer to make sure the everything was moving in the right direction according to the slider and all is good. But when moving the stick reverse or forward causes the femurs to go down on the upstroke and up in the down stroke. So the femurs are moving in the wrong direction.

Heres a video of it on the pedestal and you can see the femurs directions are reversed…

youtu.be/1P7CUh-xi5o

I’m still not convinced the shoulder and knee servos are plugged in the wrong way around, but so long as you have confirmed…
In terms of the code itself, Xan is indeed in the best position to indicate what might need to be changed.
The SSC-32 / 32U would only save the offset for each servo - it does not know what each servo does or where it’s located.

Ok i dont think the plugs can be reversed, wouldnt that kill my servo? Other wise the connections are proper and have been tested many times over. The servos are definitely hooked up right according to the hex_config.h file and tested using the sequencer.