t h e o d d r o b o t d o t c o m

Saturday, June 10, 2006

project: how to add gyros to your robonova

I mentioned in an earlier post that I was experimenting with mini-gyroscopes of the digital variety to keep my Robonova biped from falling over as often. I'll admit that a month ago I knew very little about how these worked and I still don't, but I've managed to get them to work on my biped with a lot of help from the community. So here's what I've learned.

These gyros are tiny electronic components that use a piezo crystal and some other odd bits which, when linked to servos or motors can effectively serve to increase stability. RC helicopters use these to help fly straight by canceling out unwanted rotation, as do expensive video camera rigs to cancel out shakiness. To put it simply, A gyro senses any change in the rotational movement of an object and compensates the force moving the angle of the servo, creating a force in the opposite direction thereby nullifying the effect. I can't get less technical than that.

Anyway, several Robo-One fighting bipeds use these gyros and it really makes a huge difference in stability. Soo...here's a quick how-to on adding a single GWS PG-03 gyro to your Robonova to keep it from falling forwards or backwards, or left or right, and some more info on how to add an additional gyro for both!

First check out the
video of my robonova being knocked around in one direction with one gyro compensating for my abuse.

Ok, for making this project you'll need a servo extension cable, and of course a GWS PG-03 gyro. You'll also need a three-pin male housing and the matching wire crimps. You can find these at any hobby store or RC shop. If you can't find any then just buy an extra servo extension cable and cut the male end off and use it. Lynxmotion has a nice tutorial on how to crimp these wires before you stick them into the 3 pin housing. Alternatively if you can find a cable that has male housings on both ends you should use that, but I've yet to find one. Enough with the hardware, let's not forget the code that makes it all work. Only a few lines, not bad at all thanks to a little foresight from the folks at HiTec.

the code:

Let it be known that I'm not a coder but have sucessfully compiled the following thanks to Pev, dshinsel, BauerMech and the rest of the geniuses on the RoboSavvy.com forums. The comments in the code explain what the values do. This stuff is mostly outlined in the RN-1 manual (last couple pages) but I wrote these comments out so you don't need any further reference. All you need to do is copy the code block below and paste it directly above the MAIN block in the robonova template program in the RoboBasic Editor, then program it into your robonova and we'll be ready to connect the gyro.


'======gyro code for forward-backward stability with leg shifts and arm swings====== '=======================================================================

'Gyroset tells both LEG servo sets to initialize
'tell gyro 1 to affect ankle and knee servos. zeros are for unaffected servos

GYROSET G6A, 0, 1, 1, 0, 0, 0
GYROSET G6D, 0, 1, 1, 0, 0, 0

'tell both ARM servo sets to initialize
'tell gyro 1 to affect shoulder servos on each arm, again zeros are for unaffected servos
GYROSET G6B, 1, 0, 0, 0, 0, 0 'gyro1=shoulder, the rest are zero for not being used...
GYROSET G6C, 1, 0, 0, 0, 0, 0 'gyro1=shoulder, nada... '=======================================================================
'Gyrodir tells leg sets direction of movement
'moves knee servo forward or back depending on direction of push, hence value of 1
'and the ankle slot is set to zero for backward movement. Yes, zero's matter here.
GYRODIR G6A,0,0,1,0,0,0
GYRODIR G6D,0,0,1,0,0,0

'tell arm sets direction of movement
'moves shoulders forward or backward depending on direction of push
GYRODIR G6B,0,0,0,0,0,0
GYRODIR G6C,0,0,0,0,0,0
'=======================================================================
'Gyrosense tells leg sets their sensitivity, 0 - 255.
'use this along with the gain adjustment screw on the gyro to perfect balancing
GYROSENSE G6A, 0,200,200, 0, 0, 0
GYROSENSE G6D, 0,200,200, 0, 0, 0

'tell arm sets their sensitivity, 0 - 255.
'use this along with the gain adjustment screw on the gyro to perfect arm swings
GYROSENSE G6B, 255,0,0, 0, 0, 0
GYROSENSE G6C, 255,0,0, 0, 0, 0
'=======================================================================


the wiring:

Wiring IN: the signal cable that comes attached to the gyro gets connected to AD pin 0. This pin resides in the bank of pins on the very top right of the control board. Pin 0 is the one on the far left. See the photo for close up details.

Wiring OUT: Next you need to connect the gyro OUT port to the AD pin 4- again see photo. Remember the servo cable you bought? Well this is the one we're using. Time to break it out and modify it. For this cable I used a standard 6" servo cable and cut the female end off and crimped the new ends with the crimps and then stuck them in the three-pin male housing. If you couldn't find crimps and a housing then cut the end off an extra extension and rewire that. Ok, so that's the hardest part and it's out of the way.

almost there:

The gyro should be mounted on the foam pad onto the left shoulder. Check out the photo for details. Next comes the calibration setup: Make sure the gyro is monted flat, is perfectly level and very still, and slowly turn the setup screw with the gyro's mini-tool until the red and green LED's are both on. Now all that's left is the gain adjust: Turn the gain screw to ~50%, halfway point works really well for me.


Now turn your robot on. You should be seeing something similar to the video. If your biped's stance is a little off, try messing with the gain some more, and the setup screw as well. If it's still off, try resetting your zero points in the Robobasic program under Compile/Set Zero Points. If something's off then retrace your steps or leave a comment below and I'll reply. Alternatively you can try the RoboSavvy forums.

changing the gyro stability direction:

Feeling a little bored? Well if you want to run the gyro for left-right stabilization you would mount it in the same place but rotate it 90 degrees clockwise, and then change the code to reflect the changes. Here's how I do it:

'======gyro code for left-right stability======
'leg sets
'gyro 1 affects foot AND hip servos
GYROSET G6A, 1, 0, 0, 0, 1, 0
GYROSET G6D, 1, 0, 0, 0, 1, 0

'leg sets
'move left or right depends on direction
GYRODIR G6A,0,0,0,0,1,0
GYRODIR G6D,1,0,0,0,0,0

'leg sets
'sensitivity
GYROSENSE G6A, 255,0,0, 0, 200, 0
GYROSENSE G6D, 255,0,0, 0, 200, 0
'=====================================

feeling adventurous? add another gyro:

Take a deep breath. If you want to run two, yes TWO gyros at the very same time, one for forward-back AND one for left-right, you can mount one on each shoulder- the forward-back gyro gets mounted facing forward like in the photos and the left-right one gets rotated 90 degrees clockwise. That's the easy part. Regarding the wiring, simply remember that gyro 1 gets plugged into AD port 0 and 4, gyro 2 gets AD port 1 and 5. These are right next to each other, so it's pretty easy to figure out once you find the ports on the control board (top right). Ehmm...this is confusing, but consequently note that gyro 1 = #1 and gyro 2 = #2 when you are entering values in the GYROSET code...Commented code really helps here:

'======gyro code for both forward-backward AND left-right stability=================
'I get the best results with these values but please experiment and send me comments
'=======================================================================
'leg sets:
gyro2=foot, gyro1=ankle, gyro1=knee, blank, gyro2=hip, blank
GYROSET G6A, 2, 1, 1, 0, 2, 0
GYROSET G6D, 2, 1, 1, 0, 2, 0

'arm sets
'gyro1=shoulder servos on each arm, zeros are for unaffected servos
GYROSET G6B, 1, 0, 0, 0, 0, 0
GYROSET G6C, 1, 0, 0, 0, 0, 0
'=======================================================================
'leg sets
'moves knee servo forward or back depending on direction of push, hence value of 1
'and the ankle slot is set to zero for backward movement
GYRODIR G6A,0,0,1,0,1,0
GYRODIR G6D,1,0,1,0,0,0

'arm sets
'moves shoulders forward or backward depending on direction of push
GYRODIR G6B,0,0,0,0,0,0
GYRODIR G6C,0,0,0,0,0,0
'=======================================================================
'leg sets
'this is sensitivity, 0 - 255.
'use this along with the gain adjustment screw on the gyro
GYROSENSE G6A, 255,200,200, 0, 200, 0
GYROSENSE G6D, 255,200,200, 0, 200, 0

'arm sets
'I get the best results with these values but feel free to experiment
GYROSENSE G6B, 255,0,0, 0, 0, 0
GYROSENSE G6C, 255,0,0, 0, 0, 0

'=====if you need help go to theoddrobot.com or robosavvy.com forums
'=======================================================================

And that's all there is to it. Remember, if something is off then retrace your steps or leave a comment below and I'll reply. Alternatively you can try the RoboSavvy forums.


12 Comments:

  • Hi, i am also new here and only had my robonova for a week. I was very impressed with the video of your robot with the new gyro installed and have just ordered mine to install. I dont no much about gyros or codes but your info looks pretty simple to me and also great pictures to go by.I just wanted to thank you for the info and all that helped you with your project.
    Dave

    By Blogger HOTRODLED, At 7:42 AM  

  • Hey that's awesome, very glad to be of help :)

    By Blogger VJ DeLeon, At 11:54 PM  

  • CAN THAT GYRO AND THE CODE LISTING BE USED FOR ROBONOVA WHILE IT IS WALKING? OR WALKING FAST?

    THANK YOU

    By Anonymous Anonymous, At 7:16 AM  

  • CAN THAT GYRO AND THE CODE LISTING BE USED FOR ROBONOVA WHILE IT IS WALKING? OR WALKING FAST?

    Walking fast is fine for the most part, but a little shaky. You may need to adjust your zero points for the servos in the calibration utility. But for the most part, yes, the stability increases without adjusting any of the stock Robonova moves.

    By Blogger VJ DeLeon, At 9:27 AM  

  • Hi
    great info thanks,just a small problem.On using your code for a single gyro all is well apart from rb being abit jittery but using the twin gyro code he stands ,then leans to one side, then gets caught in a loop of front push up /stand up move and altering the gyros has no affect,What might i have done as the code looks ok ??
    any thoughts please.
    thanks

    By Anonymous rep001, At 9:22 AM  

  • I just noticed your post, sorry for the delay in responding. I think what you are experiencing is normal and you need to initialize the gyros properly. Go back to the setup screw and keep turning it until the leds are green and red at the same time (like in my photo) on BOTH gyros, but do this only when the RN is in the default standing pose. It's hard when it keeps shaking but try having someone hold it for you.

    If you keep playing with the setup and gain screws together you'll get even better results.

    By Blogger VJ DeLeon, At 12:51 PM  

  • Hi, I'm using the same thing on my Humanoid(not Robonova). I noticed my robot dont really work like yours and further it jerk at time causing it to fall down itself.Then I measured the output numbers, some time the gyro some how return 2 extreme values(0 and 128), even the robot is not moving. I noticed that you also experience some problem with the GWS-P03 gryo. Could you help? Thanks

    By Anonymous Anonymous, At 12:08 PM  

  • Thanks tons for this help, I hope you do further mods with such detailed help in the future! Robonovas the world over owe you thanks for their new sense of balance!

    By Anonymous Anonymous, At 7:07 AM  

  • HEY, CAN THIS CODE BE MODIFIED TO USE WITH A DIFFERENT GYRO THAN THE ONE SUPPLIED BY hITECH? I'D APPRECIATE THE HELP.

    By Anonymous Anonymous, At 2:59 PM  

  • Hi,

    I feel that the gyro works for the front and right, but not so much for back and left.
    any ideas why

    thanks for this wonderful effort

    By Anonymous Taimur, At 3:02 AM  

  • I just got the robonova, and based on this ordered the gws gyro right away. Just curious though; I have been flying RC helicopters for quite a while and a gyro mounted in the orientation you show should be sensing yaw information, not pitch or bank. It would not matter if it was facing north/south or east/west, which is the change you suggest for using it for left to right balance. Maybe the gws has a non-standard axis or something? Do you know why it DOES work? Guess I will find out when it arrives. Thanks for the info.

    By Anonymous Spiked, At 4:49 AM  

  • I am completly new to robots. And i saw a robonova demo, had to get one, got it, put it together, played with robobasic (cool), now i want a gyro, HERES my question is the CYCLONE PG-03 the same as a GWS PG-03? And what are the difference if any? Also is ther any good reading that could help further my knowledge. Any and all help is appritiated.

    By Anonymous Anonymous, At 4:56 PM  

Post a Comment



Links to this post:

Create a Link

<< Home