hitechnic Gyro sensor (NGY1044) noise
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: hitechnic Gyro sensor (NGY1044) noise
So that means that the readings are affected by the voltage, which makes sense 100%. If you have seen the NXT schematic, it is obvious that the voltage directly effects the ADC value. Using USB or motors just lowers the voltage, resulting in different values being returned. Try adding a function that measures the battery voltage, and incorporate that into the final value, then I think you could get better results.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
-
- Posts: 323
- Joined: 29 Sep 2010, 05:03
Re: hitechnic Gyro sensor (NGY1044) noise
Hmm I've not been able to reproduce either of these results. With my sensor I ran a test that did the following...
0. Optionally started a single motor running.
1. Sleep for 10s to allow any vibrations from pressing buttons etc. to settle.
2. Run a loop 1000 times summing the value of the sensor output and delaying 4ms between samples.
3. Divide the total by 1000 to form the current sensor offset.
4. Run a loop 1000 times and count the number of data samples that fall at = offset, +1,+2,+3,+4,+5 and -1,-2,-3,-4,-5 of the offset
5. Print the offset and the distribution of samples
When I run the above both with and without the motor running and with and without USB and with and without an external power supply connected (I'm using the Lego battery pack), then I see virtually no difference in the distribution. Pretty much 95% of the samples are equal to the offset with virtually all of the other samples being +1 or -1, with perhaps 3 or 4 samples being +/-2 none of the values fall outside of this range. I ran the above test for each case many times and the results were pretty consistent. When running with the motor active I saw no change in the calculated offset.
The above tests were run using Java/leJOS but I would not expect this to impact the results. I'm not sure why we see differences but here are some things that you could try....
1. Increase the number of samples to 1000 rather than 100
2. Add a sleep before you run the test to avoid any problems with pressing the buttons and to allow the motor to settle.
3. When using the motor I held the motor away from the NXT (and sensor), to ensure no vibration or EM interference.
4. I made sure that the NXT was on a solid surface well away from any source of vibration (that could be picked up by the sensor) and that the sensor was securely mounted on the NXT.
Other than that perhaps there is some difference in our systems (what sort of power supply are you using, I use the Lego battery), or maybe the sensors are slightly different. Mine does not seem to generate that much noise or suffer from that much drift.
As to the battery voltage impacting the readings I would hope this is not the case. The NXT uses a regulator to provide the supply for the ATMega (which contains the ADC), and the motor supply should be reasonably well decoupled from this. If the motor does cause problems with the ADC readings then I would expect this to impact all analogue sensors, has anyone seen this to be the case?
Andy
0. Optionally started a single motor running.
1. Sleep for 10s to allow any vibrations from pressing buttons etc. to settle.
2. Run a loop 1000 times summing the value of the sensor output and delaying 4ms between samples.
3. Divide the total by 1000 to form the current sensor offset.
4. Run a loop 1000 times and count the number of data samples that fall at = offset, +1,+2,+3,+4,+5 and -1,-2,-3,-4,-5 of the offset
5. Print the offset and the distribution of samples
When I run the above both with and without the motor running and with and without USB and with and without an external power supply connected (I'm using the Lego battery pack), then I see virtually no difference in the distribution. Pretty much 95% of the samples are equal to the offset with virtually all of the other samples being +1 or -1, with perhaps 3 or 4 samples being +/-2 none of the values fall outside of this range. I ran the above test for each case many times and the results were pretty consistent. When running with the motor active I saw no change in the calculated offset.
The above tests were run using Java/leJOS but I would not expect this to impact the results. I'm not sure why we see differences but here are some things that you could try....
1. Increase the number of samples to 1000 rather than 100
2. Add a sleep before you run the test to avoid any problems with pressing the buttons and to allow the motor to settle.
3. When using the motor I held the motor away from the NXT (and sensor), to ensure no vibration or EM interference.
4. I made sure that the NXT was on a solid surface well away from any source of vibration (that could be picked up by the sensor) and that the sensor was securely mounted on the NXT.
Other than that perhaps there is some difference in our systems (what sort of power supply are you using, I use the Lego battery), or maybe the sensors are slightly different. Mine does not seem to generate that much noise or suffer from that much drift.
As to the battery voltage impacting the readings I would hope this is not the case. The NXT uses a regulator to provide the supply for the ATMega (which contains the ADC), and the motor supply should be reasonably well decoupled from this. If the motor does cause problems with the ADC readings then I would expect this to impact all analogue sensors, has anyone seen this to be the case?
Andy
-
- Posts: 18
- Joined: 28 Sep 2010, 23:57
Re: hitechnic Gyro sensor (NGY1044) noise
I have a 1 second wait before I start sampling to get the finger off the NXT. If I run the motor then the motor is running before the one second wait. My NXT is sitting on a solid desk. Motor is held in the air away from sensor and NXT with a long cable (50cm).
I consistently get an average value of around 1.3 less if I am running motor B at the same time that I am collecting samples. One thing that is interesting, even if there is no actual motor connected to Port B, it still affects the sensor value if I power the port.
I think that the power supply may be a factor. I usually run with AA Ni-MH batteries. If I run with the LEGO battery pack and it is plugged in, then I do get better values and less variation even with the USB cable connected. Still, I get less variation without the USB than with the USB. This could also be caused by my PC which may have more variation in the USB voltage level than what you have from your computer.
Gus
I consistently get an average value of around 1.3 less if I am running motor B at the same time that I am collecting samples. One thing that is interesting, even if there is no actual motor connected to Port B, it still affects the sensor value if I power the port.
I think that the power supply may be a factor. I usually run with AA Ni-MH batteries. If I run with the LEGO battery pack and it is plugged in, then I do get better values and less variation even with the USB cable connected. Still, I get less variation without the USB than with the USB. This could also be caused by my PC which may have more variation in the USB voltage level than what you have from your computer.
Gus
-
- Posts: 323
- Joined: 29 Sep 2010, 05:03
Re: hitechnic Gyro sensor (NGY1044) noise
Interesting, I suspect it may be the internal resistance of the power supply that may be impacting the noise levels a little, on my setup if anything I see slightly better results (less spread), if the USB cable is attached... If you get chance it would be interesting to see if increasing the number of samples makes any difference, also maybe running my running a loop for 1000 times before I measure the distribution has some sort of impact...
Whichever way you look at it we are only talking about very small levels of noise (+/-2 in 1024), which is pretty good...
Andy
Whichever way you look at it we are only talking about very small levels of noise (+/-2 in 1024), which is pretty good...
Andy
-
- Posts: 323
- Joined: 29 Sep 2010, 05:03
Re: hitechnic Gyro sensor (NGY1044) noise
One other thought on this. You are performing integration of the sensor values by multiplying the sensor reading by the elapsed time. But in this case the elapsed time is very small compared to the units being used (5ms with a function that returns integer ms units). Which means you may have a pretty high timing error. I wonder if there is a way to reduce this (or measure it)? One of the problems is that the actual data is being sampled at a different rate (3ms via the ATMega), to the rate that you are sampling (at best 2ms in the NXT). Perhaps someone who has had less wine tonight than me can come up with a solution to this!
Re: hitechnic Gyro sensor (NGY1044) noise
(looks like I have not sent the reply I prepared this morning. Sorry if it finally appears twice!)
Whenever you set the motor to something else than coast (either brake or run, even if there is no motor) you wake up the motor driver IC that consumes some energy.gusjansson wrote:I consistently get an average value of around 1.3 less if I am running motor B at the same time that I am collecting samples. One thing that is interesting, even if there is no actual motor connected to Port B, it still affects the sensor value if I power the port.
I don't think USB voltage matters since it is not used by NXT. But when you plug the USB you link NXT ground to PC one... and you can collect quite a bit of PC noise this way!Still, I get less variation without the USB than with the USB. This could also be caused by my PC which may have more variation in the USB voltage level than what you have from your computer.
Philo
-
- Posts: 18
- Joined: 28 Sep 2010, 23:57
Re: hitechnic Gyro sensor (NGY1044) noise
Philo, this is very interesting. This tells me that the correct way to collect gyro sensor samples for an initial offset is to somehow do it with the motor drive IC activated, unless you are using your gyro sensor on a robot without motors.Whenever you set the motor to something else than coast (either brake or run, even if there is no motor) you wake up the motor driver IC that consumes some energy.
I just tested the effect by adding an Off(OUT_A) before I start the gyro sensor sample collection. The result was that the average sensor value dropped by nearly 2 (from 14.04 to 12.22 using the NXC function SensorHTGyro that already has a built-in offset of 600).
I'm going to make sure that the HTWay now does something to activate the motor driver before setting the offset.
Thanks for the explanation, this is very useful information and makes the effect much less mysterious.
The USB grounding explanation is also good to know. The USB cable does not seems to significantly change the gyro sensor value but it does make it a little more noisy, at least for me with my PC.
Gus
Re: hitechnic Gyro sensor (NGY1044) noise
What is slightly more difficult to understand is that the motor drivers ICs are powered by 9V supply while the gyro is powered by the (hopefully) regulated 5V supply. The gyro doesn't use RCX style 9V IO supply, does it?gusjansson wrote:I just tested the effect by adding an Off(OUT_A) before I start the gyro sensor sample collection. The result was that the average sensor value dropped by nearly 2 (from 14.04 to 12.22 using the NXC function SensorHTGyro that already has a built-in offset of 600).
Speaking of this, often mine took forever to set calibration, I finally changed to max-min<2 instead of <1I'm going to make sure that the HTWay now does something to activate the motor driver before setting the offset.
Philo
-
- Posts: 323
- Joined: 29 Sep 2010, 05:03
Re: hitechnic Gyro sensor (NGY1044) noise
Hi,
I'm also a little surprised that the regulator does not take care of this (and intrigued!) . As I posted earlier I was unable to reproduce the problem described here, I tested on a couple of NXTs both using the (old) Lego rechargeable battery (with and without the charger attached). Turning on motors and/or attaching USB had no impact. I wonder what is causing this effect? I only have the one gyro so have not been able to test with anything other than that... I don't think the gyro uses the 9V supply. However the 9V supply is routed to the ADC input pin via a (darlington) transistor (which will be turned off when 9V is not in use), so perhaps there is some leakage via this. Perhaps some NXTs have more/less leakage due to component tolerance? What is the voltage supplied when using the Ni-MH batteries? Perhaps that voltage v the 7.2V from the Lego pack may also have an impact? Hmm interesting...
Andy
I'm also a little surprised that the regulator does not take care of this (and intrigued!) . As I posted earlier I was unable to reproduce the problem described here, I tested on a couple of NXTs both using the (old) Lego rechargeable battery (with and without the charger attached). Turning on motors and/or attaching USB had no impact. I wonder what is causing this effect? I only have the one gyro so have not been able to test with anything other than that... I don't think the gyro uses the 9V supply. However the 9V supply is routed to the ADC input pin via a (darlington) transistor (which will be turned off when 9V is not in use), so perhaps there is some leakage via this. Perhaps some NXTs have more/less leakage due to component tolerance? What is the voltage supplied when using the Ni-MH batteries? Perhaps that voltage v the 7.2V from the Lego pack may also have an impact? Hmm interesting...
Andy
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: hitechnic Gyro sensor (NGY1044) noise
The "5v regulator" does not regulate the voltage, at least it doesn't seem to. Why then is the sensor supply voltage said to be in the range of 4.3v-4.7v? None of MY voltage regulators (lm317, 7805...) have THAT much variance.
I looked up the "regulators", and they are extremely low dropout, variable "regulators" rated for (I think) 150-500ma (based on specific regulator). The dropout is only like 670mv @ 100ma, based on what little I found. That means that the NXT should run on slightly less than 6v (which seems to be the case, based on my experience).
I looked up the "regulators", and they are extremely low dropout, variable "regulators" rated for (I think) 150-500ma (based on specific regulator). The dropout is only like 670mv @ 100ma, based on what little I found. That means that the NXT should run on slightly less than 6v (which seems to be the case, based on my experience).
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Who is online
Users browsing this forum: Semrush [Bot] and 0 guests