SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By Gilberto
#109104
Hi friends,

I'm currently in a project in which my mission is to balance an inverted pendulum (IP). The drive system of the IP consists of 2 dc motors whose shafts are connected to 2 fans through 2 rubber belts. The fans are mounted on top of the IP. The IP is about 1.2 (m) in height.

In order to measure the tilt angle of the IP, I used a combination of a gyroscope (LISY300AL - ST Microelectronics) and an accelerometer (ADXL202E - Analog Devices). I used the Kalman Filter algorithm to fuse the data from these sensors, and the result is quite good: I can measure the tilt angle quite accurately.

However, to control the IP, I also need to get the angular velocity, which is output from the gyroscope. My problem is that this output is very noisy, due to the vibration caused by the drive system.

I have tried to soft-mount the sensors (using foam pads) to reduce the vibration, but the result is still not good enough.

I attached here the output from the gyroscope. As you can see from the graph, when I turn on the motors (and hence the fans), the gyro data is extremely noisy.

I have also tried to implement a digital filter. Although it can filter out some noises, but it also causes phase-shift which will add remarkable delays to the system. You can see the phase shift from my second attached file.

So, could you please tell me some effective ways to reduce the noises from the gyroscope's output (without too much phase-shift)?

Thank you for reading my question,

Gilberto
You do not have the required permissions to view the files attached to this post.
By TomasReabe
#109120
Are you doing the filter in code or solder? I would say to use a low pass RC filter and then play with the cap size to filter out the noise from you motors. If you want some good info on cleaning the input try and look at DIYdrones.com, they are doing full IMU systems and they need to work with the vibrations of the motors on the planes.

But a good low pass should help with the fan noise at least.
#109148
It is not possible to comment on the potential success of filtering (DPS or analogue) unless we know your noise bandwidth relative to your IP signal bandwidth (?). I am curious as to how you have 90deg phase lag but no apparent attenuation?

The noise may not be mechanically induced; perhaps your drive electronics are inducing the noise on the power rails to the (a) ADC, (b) op-amp or (c) sensor. You can answer this by disconnecting the sensor from the circuit, powering it from a separate battery and scoping the output.
By tecoist
#109153
If you differentiate the tilt angle (which you say you can filter and measure already from these sensors), don't you get angular velocity?

In general, I wouldn't recommend filtering the sensor data if you're trying to build a feedback loop; put all the filtering in your loop where it's easier to analyze. Stacking filters will quickly kill your phase margin. It sounds like you've already experienced this unhappy situation. Mind you, that must be a monster filter if you're getting a second of group delay out of it (just guesstimating off the pretty picture). Good luck with this project--I really enjoy servo design, and I hope it will be fun for you too.
#109174
Oh yeah, what David said! Attached is a simple Kalman filter demo for fusion of noisy position and velocity data to yield 'cleaned up' states. It is obviously better to prevent the noise in the first place so still check out what I was saying about the noise being electrically induced.

RE: "differentiate the tilt angle." Differentiating any noise results in ALLOT of noise! Consider numerically differentiating 0.1 deg tilt noise at 1 kHz. dv/dt = 0.1 / 0.001 = 100 deg/s !!!.
Good luck.
You do not have the required permissions to view the files attached to this post.
By Gilberto
#109184
@TomasReabe: that is a digital filter, which is implemented in software. I think the result from an analog filter won't be much different, do you think so? And I will give the website a look.

@sebmadgwick: the noise is from the mechanical parts. I am sure about that, because when I detach the rubber belts (the motors still running), the noise almost disappears.

@tecoist: I think that differentiating the angle will magnify the noise. In fact I have tried and the noise is just unacceptable.

@UhClem: That is a good idea. I will try to follow it.

Thank you very much for your answers.
By tecoist
#109192
Yes, differentiation is a high-pass filter, just like integration is a low-pass filter, but of course in this case both tilt angle and angular velocity are being estimated from the same sensors, so the noise is (drum roll, please) identical. That's why the noise looked good on the tilt angle value and bad on the angular velocity value. The key word here is "looked."

So: if you have a good Kalman model of pendulum state, the angular velocity is already in there; you're already doing a Kalman estimate of it, even if the only variable you have is tilt angle. On top of the noise reduction from Kalman, you are using the results in a servo loop, so the loop transfer function's going to take out a lot of noise. That's one of the things servos (even not-very-Kalman servos) do.
By ScottH
#116612
What are you estimating with your Kalman filter? You should be estimating the full state theta and theta_dot. The Kalman filter will give you optimal estimates of both.

There's no reason why you can use a Kalman filter for theta but not for theta_dot.