Gyro sample code?

So I have a phoenix robot and noticed that the gyro is pretty inexpensive and would be pretty cool to play around with… so emm…

Anyone have one of these and use it with an Atom Pro and … I don’t know do something neat with it?

I’d like to see some code for it and how challenging or not it is to pull values off it.

–Aaron

Are you talking about the Lynxmotion gyro? I don’t know if the code is any different for the Robonova gyro. I think you just have to use the ADIN command.

yeah,

I was speaking about the lynxmotion gyro, although if the code is similar or the same to any gyro i guess im looking for, what exactly is the output look like?? is it like the numbers you get when you do a pulsin read on an RC reciever?

900ish-2200ish decimal?

I’d like to toss this on the Phoenix for a couple experiments! would be cool.

–Aaron

You have to use the ADIN command to get the data. The data is then returned as a digital value of 0-1023 (10 bit).

The best thing to do would be to experiment with it and get familiar with the values returned.

It’s actually VERY simple. It takes like 3 lines of code to return the value of the sensor to the output window.

cool, I guess what I might have expected.

are these Gyro’s just 1 axis?..

I have never used them before or had an RC heli either…

is a 3 axis one available somehow? or does one have to build it?

Thanks again.

–Aaron

Have you taken a look at it yet? :wink:
lynxmotion.com/Product.aspx? … tegoryID=8

It says 2 axis. I’m guessing its x and z axis. How it works is there are 2 analog outputs on it and they connect using two data cables that connect to the Bot Boards A/D pins and you would have to actually do the ADIN command twice. One for the Z axis and one for the X axis (i assume those are the axis that it reads).

That is cool… I had no idea it was that simple, you happen to know which one of these gyro’s is better?

sparkfun.com/commerce/produc … cts_id=698

500 degrees a second seems like overkill for this tiny pheonix of mine, although hopefully quite speedy… but $25 isnt bad either… cool cool

I’m going to have to pick one of these up the programming seems very very easy, supprised more people arn’t using these!

Oh i see that’s a Accelerometer…and not a gyro, I remember seeing a discussion about using one or another… I think probably using a gyro in my case might be a better way as what I would like to accomplish with this, and since adding this to my program wont take a ton of cpu cycles to use the adin command, vs the pulsin command how im reading all 7 channels of my T7C…

If you have coded with this, is it possible you can get the same result from either a gyro or accelerometer?

did you have any messanger service?

It might be a good 6 hours or so before i’m able to post again, but I’m pretty interested in picking one or the other up and coding with it since it seems pretty easy…so cool.

–Aaron

I think the Lynxmotion one might be simpler IMO. And its cheaper too.

Um…I’m confused. I thought an Accelerometer was a gyro?

Nope…sorry. I don’t have one atm. I just installed a new OS and I haven’t put all the software on it yet.

Well hook it up then and get that ish installed… if you know some coding be handy to have someone i can shoot ideas back and forth with rather then post short questions…

Yes as far as I know an accelerometer and a gyro are 2 different things…

An accelerometer would maintain the same value after its been in 2 points in 3d space for some amount of time, and the data is only gatherd in the time it takes to move…

a gyro however…“taking a guess here” once its powered on would maintain an angle refrence in the axis its oriented with power applied so the only time you would get the same value from it is if it were positioned in the same angle it was when it was powered on?..

Let me know if that makes sense… granted the gyro description was a guess… so if anyone wants to chime in here and either tell me im correct or wrong, feel free to no harm done.

-Aaron…

I would rather have something that refrences 3 axis in space vs a single axis… all this is for test on my part along with expanding my atom pro basic skills which are expanding daily!

Okie then. I’ll do that when I get a chance.

I still think you should go for the Accelerometer.

An accelerometer can return an angle or orientation but only when the accelerometer is at rest. That’s because it uses the Earth’s gravity to determine orientation. Once it’s in motion, there are several vectors affecting the accelerometer other than the Earth’s gravity.

Alternatively, a gyro can return an angle of orientation at rest and during motion.

Unfortunately, orientation data obtained using just a gyro can result in errors that become larger and larger over time. One solution is to combine both so that readings from a gyro are “reset” when the object is at rest (as determined by the accelerometer).

It turns out, you need at least 6 degrees of freedom to track the movement of an object in 3-Dimensions. They sell things like this on sparkfun and other sites but they’re pretty expensive. Of course, you can get away with less if that’s not your goal.