understanding data output from gyro

Support for Pololu products that are not covered by one of the above categories.

understanding data output from gyro

Postby jamgrah » Tue May 31, 2011 10:00 pm

Hi, I am using the LPY510AL and reading it with a Wixel.
I have created a test harness, with a Maestro to contol a servo and the LPY510AL mounted on the servo arm.
The Wixel reads the gyro in a tight loop and outputs to the virtual com port the gyro readings X and Z and a time stamp.
I can then capture the output with a terminal program and graph the results in Excel.
What I see is not what I would expect.

The Maestro is running this simple script:
Code: Select all Expand

So the servo swings right pauses then left pauses and repeats. At zero speed and zero acceleration.
I would expect from this motion to get values above resting a pause then values below resting and a pause.
I let the capture run for 10 times through the loop. I expect a graph to look more like a sine wave.
Can you explain this data?
The Wixel code is longer and much is commented out to remove any outside the gyro issues.
Code: Select all Expand

I get the same data with or without the commented code executing.
I am attaching the log file from Terminal and the graph from Excel.
Attachments
Gyro test harness capture.zip
Excel chart of data capture
(113.94 KiB) Downloaded 123 times
960-2000-0-2.zip
data capture from terminal program of Wixel output
(12.9 KiB) Downloaded 127 times
jamgrah
 
Posts: 19
Joined: Sat Apr 23, 2011 10:42 pm
Location: Portland Oregon

Re: understanding data output from gyro

Postby DavidEGrayson » Wed Jun 01, 2011 10:39 am

Hello, the data you gave us has some large gaps in it; for example there is no data between time=6364 to time=11806. This makes me think there is something wrong with your Wixel code or (more likely) the way you are using your terminal program.

At rest, I would expect the X and Z outputs of the gyro to both be equal to VRef (1.23 V) which means their digital value should be about 2048*1.23/3.3 = 763. Your reading for Z at rest is pretty close to that, but your reading for X at rest is only 130. I would inspect the connection between the Wixel's P0_2 and the Gyro's X output and try to figure out what is going wrong. I would try measuring all the outputs of gyro with a multimeter while the Wixel is disconnected and while it is connected. You could try a different pin on the Wixel or try a different X output on the gyro.

How is everything wired together? How is everything powered? Is the gyro oriented correctly? (A picture would help us check some of these things.)

I plotted one part of your data and it looked like this:

jamgrah_z.png
jamgrah_z.png (38.78 KiB) Viewed 8163 times


--David
DavidEGrayson
Pololu Employee
 
Posts: 2720
Joined: Thu Apr 03, 2008 12:30 pm
Location: Las Vegas, NV

Re: understanding data output from gyro

Postby jamgrah » Thu Jun 02, 2011 1:39 pm

Hi David,
Thanks for the response.
The Wixel is powered by USB, the gyro is powered from the Wixel 3.3 output and the Maestro is powered by 4 D cells with the jumper for VSR=VIN.

I ran four tests and two have a gap which I did not notice.
This could be the window terminal program capture issue my laptop is old and slow.
I have transitioned to Mac and have only older Win machines around.

The 130 value was a mistake I had the connector on the wrong pin.
So that was a disconnected pin I was reading as 130.
Photo I took shows this mistake it is corrected and now I am getting the expected value of 756.

The terminal program missing data and the cable on the wrong pin do not change the issue of the readings being not what I would expect.
I expect that as the servo is moving the gyro clockwise I should get relatively stable readings above resting and converse when moving counter clockwise. Instead I see values indicating that during the period while the servo is moving the gyro that it is moving rapidly clockwise then counter clock wise.
Or high values then low values when I expect all high values a pause then all low values a pause and repeat.
More like a square wave with a slow period.

As for coding issues on the Wixel. I posted the code. I do not see in code a reason for the data to be this way.
Some of the motions are completely lost, data is sent but it is near resting values when it should show movement.
jamgrah
 
Posts: 19
Joined: Sat Apr 23, 2011 10:42 pm
Location: Portland Oregon

Re: understanding data output from gyro

Postby jamgrah » Thu Jun 02, 2011 1:41 pm

I am attempting to post images saved on flickr.
at http://www.flickr.com/photos/softwaresp ... 790941637/
jamgrah
 
Posts: 19
Joined: Sat Apr 23, 2011 10:42 pm
Location: Portland Oregon

Re: understanding data output from gyro

Postby kevin » Thu Jun 02, 2011 4:51 pm

Hello,

In the code that you posted, you expect the X axis data from the gyro to be on ADC channel 2 and the Z axis to be on ADC channel 1, but your picture seems to show the X axis (green) going to P0_1 and the Z axis (yellow) going to P0_0, which correspond with ADC channels 1 and 0, respectively.

You mentioned correcting a connection, so maybe you have already fixed this. Just to be certain, though, are you sure the wires are connected to the channels you are actually reading from, and that you don't have X and Z reversed? (Check that you are disabling the correct pull-ups as well.)

- Kevin
User avatar
kevin
Pololu Employee
 
Posts: 588
Joined: Thu Oct 14, 2010 5:22 pm
Location: Las Vegas, NV

Re: understanding data output from gyro

Postby jamgrah » Thu Jun 02, 2011 6:55 pm

Thanks Kevin I should have been clearer.
I did have the connector at the Wixel on P0_0 and P0_1 this has been corrected.
Now the yellow wire is Z and connected to P0_1 and green wire is X and connected to P0_2.
The Ohm meter reads short from Gyro pins at the board to Wixel pins at the board with out USB connection for both X and Z pins. All pins and solder joints have been inspected and metered. I get 3.28v at the vin to gnd on the gyro.

I will run another set of tests tonight and post results.
When I first got the gyro I tested it on the Maestro with the gyro in my hand, using a different cable harness, just to move two servos based on gyro X and Z values as a crude quick test. While it did work it was not consistent. Not always moving the servo on gyro movement. I thought that it was the lack of code depth in the stack oriented Maestro and my project expects the gyro to communicate with the Wixel so I moved to the C platform and more complex code with diagnostics. This was when I confirmed something was not as per my expectation.

The mistake in the connection does not explain the difference between expected data and actual.
To recap the gyro is moving in a flat plane on the Z axis. Riding on top of a servo wheel that is controlled by the Maestro a simple script moves the servo at full speed to the right pauses 500 delay then to left pauses 500 delay and repeats.

How would the expected result from this test harness appear as a graph?

I am expecting something like the red line.
Expected values.GIF
blue line is actual red line is expected
Expected values.GIF (19.07 KiB) Viewed 8079 times

My crude timing estimate is less than one second to move and delay, we know the delay. I predicted that this standard servo at full speed would cover 3/4 of its range in less than 350 ms. The graph does suggest about about 300 ms of movement.

James
Last edited by jamgrah on Thu Jun 02, 2011 7:55 pm, edited 2 times in total.
jamgrah
 
Posts: 19
Joined: Sat Apr 23, 2011 10:42 pm
Location: Portland Oregon

Re: understanding data output from gyro

Postby jamgrah » Thu Jun 02, 2011 7:19 pm

New Pic with the corrected cable connection.
Thanks Ben for the posting pics tip.
GyroTestHarnessCorrectedSmallAbove.GIF
Corrected cabling on gyro test harness reduced in size by 20%
GyroTestHarnessCorrectedSmallAbove.GIF (84.64 KiB) Viewed 8089 times
Last edited by jamgrah on Sun Jun 05, 2011 5:30 pm, edited 1 time in total.
jamgrah
 
Posts: 19
Joined: Sat Apr 23, 2011 10:42 pm
Location: Portland Oregon

Re: understanding data output from gyro

Postby DavidEGrayson » Fri Jun 03, 2011 11:24 am

Hello.

As you can see, GIF is a poor format for photos. It only allows 256 different colors. I recommend using JPG instead, as you have done on Flickr. For diagrams and charts, GIF is ok but PNG looks nicer because it is lossless. Also, I think you don't need to post multiple sizes of the same photo; I was confused at first until I realized that's what you had done.

Your latest pictures and explanation of your setup all look good. The red line you drew on the graph looks good. However, the blue line is incorrect because I made it based on data from your first post where you had the wiring wrong. (I think the blue line in that graph is actually the reading on the X axis, not the Z axis; I would expect to see random looking noise like that on the X axis but I'm not sure about the magnitude.)

Now that you have fixed your wiring, could you try again and post the new data? Please post readings from both the X and the Z axes. I don't have Microsoft Excel; if you just post a CSV file that would be fine.

If the new data doesn't look good, you could try taking the Wixel and Maestro out of the system and just measure the gyro outputs with a multimeter while turning the gyro with your hand. We have some general trouble-shooting tips in this post: Read Before You Post: General Advice for Getting Help.

--David
DavidEGrayson
Pololu Employee
 
Posts: 2720
Joined: Thu Apr 03, 2008 12:30 pm
Location: Las Vegas, NV

Re: understanding data output from gyro

Postby jamgrah » Fri Jun 03, 2011 11:51 pm

David,
Did some tuning on this old dos laptop but still cannot get a complete capture.
Terminal captures about two seconds of data then writes to the drive and losses about 3 seconds of data, before comping back from the disk I/O.
So all I can get is the cycle (pause, move, pause) of reliable data.
You are right the graph from before was only the noise on the X axis, which is very high.

Attached is the capture file from tonight as discussed it has gaps.

Here is the first two seconds of that data graphed, I adjust the time to make it easier to read the chart.
I do this by subtracting the start time from all time values.
gyro test harness motion on Z only test set 4.JPG
First two seconds of 4th test suite first pass motion on Z only
gyro test harness motion on Z only test set 4.JPG (26.81 KiB) Viewed 8005 times


I am going to move the testing to the Mac so I can have the power needed for better captures.
Next tests will be to add a second servo for tilt. Attach the Gyro to a pan and tilt platform controlled by the Maestro so we can see both axis in motion at the same time.
James
Last edited by jamgrah on Sat Jun 04, 2011 9:19 pm, edited 1 time in total.
jamgrah
 
Posts: 19
Joined: Sat Apr 23, 2011 10:42 pm
Location: Portland Oregon

Re: understanding data output from gyro

Postby DavidEGrayson » Sat Jun 04, 2011 10:03 am

Great, I'm glad things are working better for you now.

The graph you posted looks pretty good. The Z axis data looks great. There is a lot of noise on the X axis, but it only happens while the servo is moving, so somehow the movement of the servo must be causing it. I think it's most likely that your platform vibrates along the X axis while it is turning, but I can't say for sure.

Were you going to do anything with the data from the X axis?

--David
DavidEGrayson
Pololu Employee
 
Posts: 2720
Joined: Thu Apr 03, 2008 12:30 pm
Location: Las Vegas, NV

Re: understanding data output from gyro

Postby jamgrah » Sat Jun 04, 2011 11:56 am

The project is head tracking to drive pan and tilt servos.
This will be applied to several applications.
A camera pan tilt controlled by head movement for AP in my RC aircraft.
A nerf turret with wireless video controlled by head tracker (requested by my 9 yr old buddy).
A head controlled mouse for disabled.
A talking head that is controlled by an actor (Halloween).

All will use both X and Z.
Currently I attempting to capture values during controlled movement (attached to servos) to give me an idea of how the data will look under different conditions.

I plan to start testing soon on both axis and at different speeds and travel distances.
Then from the data I hope to develop the algorithm that will translate the gyro data to actual position.
Attachments
Talking Head pan tilt detail.JPG
Talking head pan tilt detail
Talking Head pan tilt detail.JPG (32.14 KiB) Viewed 7976 times
Talking Head side view.JPG
Talking head
Talking Head side view.JPG (49.43 KiB) Viewed 7976 times
jamgrah
 
Posts: 19
Joined: Sat Apr 23, 2011 10:42 pm
Location: Portland Oregon

Re: understanding data output from gyro

Postby DavidEGrayson » Sun Jun 05, 2011 11:59 am

Those all sound like really cool projects. Let us know how they go!

A gyro would be good for detecting specific gestures (like when some turns their head suddenly clockwise), and that might be good enough for the Halloween project, but to accurately keep track of the head's orientation of long periods of time I think you will also need an accelerometer and a compass.

We sell some sensors that might work for you but they are more expensive than what you're working with now:

CHR-6dm Attitude and Heading Reference System
CHR-UM6 Orientation Sensor

--David
DavidEGrayson
Pololu Employee
 
Posts: 2720
Joined: Thu Apr 03, 2008 12:30 pm
Location: Las Vegas, NV

Re: understanding data output from gyro

Postby Ben » Sun Jun 05, 2011 12:43 pm

Hello.

Note that the sensors David linked to are more complete solutions. If you want to save money by implementing something yourself, you could consider using something like our LSM303DLH compass and accelerometer carrier to track the absolute orientation of the head.

- Ben
User avatar
Ben
Pololu Employee
 
Posts: 3454
Joined: Mon Aug 28, 2006 1:05 pm
Location: Las Vegas, NV

Re: understanding data output from gyro

Postby jamgrah » Sun Jun 05, 2011 6:12 pm

David,
For 200.00 to 300.00 I can get plug and play solutions from the hobby industry.
Such as this one http://hobbywireless.com/cart/index.php?main_page=product_info&cPath=31&products_id=544
There are many gyros on the market for RC hobbies that can easily be adapted to head tracking.
But out of the box solutions do not always appeal to us DIY types that like to code and tinker with the electronics.
I am learning alot about gyros.
James
jamgrah
 
Posts: 19
Joined: Sat Apr 23, 2011 10:42 pm
Location: Portland Oregon

Re: understanding data output from gyro

Postby jamgrah » Sun Jun 05, 2011 6:20 pm

Ben,
I have added the item to my next purchase wishlist.
I knew that I would need an accelerometer for the next steps.
I was not sure which sensitivity I needed in a gyro and thought I would buy one and start experimenting.
I am having fun and learning.
I am going to work on a low pass filter in code to remove noise.
Here is a data capture of Z motion at a speed of 30.
gyro test harness motion on Z only test set 4.JPG
Slow moving Z axis X axis at rest
gyro test harness motion on Z only test set 4.JPG (85.27 KiB) Viewed 7907 times

I mounted the test harness to a project box and weighed it down to minimize motion noise transfer to the non moving axis.
James
jamgrah
 
Posts: 19
Joined: Sat Apr 23, 2011 10:42 pm
Location: Portland Oregon

Next

Return to Other Pololu Products

Who is online

Users browsing this forum: No registered users and 4 guests