I am trying to build a self-balancing hovercraft platform that will utilize a pair of electric fans to provide lift. It will only stabilize in one axis only, by either speeding up the left fan or speeding up the right fan from a set value.
I am using an Arduino Nano and a GY-621 MPU-6050 gyro/accel. I have been able to connect the two and read out data no problem. Currently I am using a sketch that I found to get the MPU on the 6050 board to provide me the pitch values which are very stable and self calibrate after about 8 seconds of reading data. I am able to convert the pitch values into Euler angles and read them over the serial monitor. The pitch values vary from -90 degrees to 90 degrees, but I will only be concerned with a much smaller range of degree variation, as the hovercraft will not be tilting that far!
I am stuck on what to do with the pitch values in degrees. Am I correct in thinking I will need to use a PID controller? I have been experimenting a bit with the PID examples in the library but don't know how to get the output to do what I want. I know my input will be the pitch angle and set point is 0 degrees.
I will be connecting the fan motors up through some MOSFETS to the digital pins on the board to use PWM control.
What I don't know how to do is go from what the output of the PID library gives me, to controlling the pair of fans.
My thoughts:
Set fans to 80% of max speed
Read Euler angle
Correct error by either:
-increasing left fan incrementally until platform level, if limit reached decrease right fan
-increasing right fan incrementally until platform level, if limit reached decrease left fan
Perhaps an easier approach would be to have the fans controlled by a single PWM signal, positive to one fan and inverted to the other. That way as one fan increases speed, the other would automatically decrease. 50% power from each fan would be the maximum with this scheme. As the datasheet rather poorly explains, the timers in the Atmega can generate the signal and its complement, and output them on different pins.
Have you tested this and observed the problem you're trying to fix? Hovercraft are usually highly self-stabilising as long as you segregate the air to distribute it evenly around the periphery.
It's for a competition for one of my engineering design classes, we have to carry weight above 1kg in little taped up washer packages. The more weight the more points. So some of the weight might be added in a way that can off-balance the craft, I want to have the fans be able to correct this so it does not dig into an edge while cornering.
Also we get bonus points for some sort of additional electronics controls besides the 2 channel rc controller we are using, in my case I am using the arduino and gyro/accel.
|'m thinking of having the PID controller limit it to perhaps -55 to 55 correction output. The base speed will be a 200 pwm signal. I will use an IF loop to check whether the output from the PID is positive or negative and then add the output to the base speed for the particular fan that will correct the condition. So:
Set fans to lift speed (200)
Check gyro/accel angle
PID to use angle to output value
Check output value if positive or negative
If positive, add absolute value to lift speed left fan
If negative, add absolute value to lift speed right fan
Design your ducting so that each lift fan supplies a separate region of the periphery.
Run all lift fans at full power all the time.
If you want to include some smarts, try to implement a yaw control feedback loop so it is stable in yaw - but get it working first.
The maximum lift capacity will depend on fan efficiency, lift area and efficient internal air flow. If the CoG gets so high that your hovercraft is statically unstable then anything else you do is a waste of time. Stabilty and lift capacity can both be increased by increasing the dimensions of the lifting area.