====== Glider project ======
Following MiHAB 1 and 2, I've decided to try something new, hence the glider project. This project may merge with the
UKHAS glider project, and I'm designing it to be applicable to other gliders.
===== Mark #2 Glider ====
With the glider used in flight 1 completely trashed, something new will be needed ;-) Having considered a 2 axis stabilised rigid glider (probably using thermopiles and an ARTF off ebay) and also a parafoil, I'll probably go for a semirigid rogallo. These are very stable and forgiving on control inputs, and also easy to make, and foldable for transport to the launch site. Parafoils also meet these criteria, but readily avaliable parafoil kites are harder to adjust and test unless you're good at sewing and have a nice high platform to test from.
Judging from the previous test flights, a "PIDR" loop with SIRF2 would almost certainly be adequate for a rogallo, but I'll try and be on the safe side (money and time allowing) and go for a rate gyro ( off spark fun) and kalman loop. This should be able to give an extremely accurate and responsive heading value for the PID loop. Temperature compensation of the gyro will be essential, but a peltier cooler system has been constructed for that purpose, and should be capable of -30 centigrade (-14 reached so far). One problem will be small steps in the Kalman filter output with each new GPS heading, which would mess up the D term in the PID controller unless it is turned off each time this happens. (i.e. turned off for one iteration of the Kalman filter)
A second, and more serious problem is the GPS lag, approx 1.1 seconds for a sirf2. Solving this may mean that the correct error treatment cannot be used in the kalman filter, but more work is required. Running the filter back and forwards to pick up each GPS heading is not an option as there will be insufficient recources (ie SRAM and clock cycles).
Here is an overview of the planned system, it would appear that there is a lot to do, but much of the work has already been done for flight #1, so it may not be as hard as it appears :-)
{{projects:mihab:evil_plan_to_take_over_the_world.png|}}
===== Rogallo experiments =====
This RC rogallo is approx 1 meter long. The pitch control is not being used at present, but the "payload" is currently being rebuilt to include pitch control as well. The vertical and horizontal cross spars were added to improve the stability and remove the possible problem of the wing folding up or diving. It now seems extremely stable, and should fly in virtually any weather conditions.
{{projects:mihab:p4130055.jpg?700|}}
It seems a rogallo can be made to descend vertically by moving the c of g well towards the back. This feature would be brilliant for landing. A small micro servo with pot removed for continuous rotation could be used to adjust the guy lines when the rogallo reaches 100 meters or so.
[[http://video.google.co.uk/videoplay?docid=-247659611589004030|Demonstration (unfortunatly a bit dark)]]
===== Flight 1 =====
This appears to have gone into a spiral dive soon after release, descending at 15m/s into an industrial estate at the edge of St-Neots, it was found the next day and will be recovered shortly. [[Launch photos (at EARS)]]
== Lessons for future ==
* Although the glider appreared quite stable in tests, a drop from a balloon is more violent, and there is a greater probability of the glider spiral diving.
* 9V lithium batteries cannot supply more than 100ma on a continuous basis
* Dividing up power supplies increases reliability i.e. flight computer and gps off a seperate battery from servo(s) and cutdown
* Only fly with 100% reliable code
* Use a high quality compiler
* Unless the aerodynamics is thoroughly tested, rigid gliders are only reliable with thermopile stabilization. Rogallos and parafoils are c of g stabilized, so more stable in that respect
* A wing trailing edge dipole antenna works very well
* Tethered drops are useful as an intermediate stage between "hill" tests and drop tests.
* It's best to test in the calmest possible weather
===== Simulation =====
Using just a basic approximation for the yaw behaviour of the glider, the oscillatory behaviour can be analised.
A more advanced extropolation technique has now been tried out, taking the aerodynamic damping effects and current rudder position into consideration. It can be seen that the results are very encouraging. The +-15 degree range is reached within 2 seconds! and the glider stays there. This is very important as turbulence occurs on the 10 second timeframe, so the glider can recover from one disturbance in time for the next.
{{projects:mihab:forward_extropolation.png|}}
It would appear that approximating the current GPS heading from the current one and the previous makes the system more responsive and less prone to oscillation. A and B show the heading offset and servo position using the approximation technique, whilst C and D show the same data for uncorrected PID loop using the same constants (P=0.15,I=0.03,D=0.25) in E and F the value of D has been adjusted so that the overshoot is the same as in the corrected case, and it can be seen that for the same P and I, ie the same resistance to trim errors(I) and tendancy to head towards the target(P) we have far superior behaviour. Next step will be automated PID optimisation! [[Source code]]
{{projects:mihab:simulation.png|}}
==== EEPROM flight recording ====
After some unsuccessful powered flights and semi successful glides, I've removed the motors and speed controller, increased the size of the rudder and added flight data recording.
Here are some flight tests, as it can be seen the system is unstable in the first (PI) series, and does not stabilize, a D term was added in the second series, and this looks more promising, but there were heavy gusts of sidewinds during the tests. Here is a third tests series just completed
Here are the values used, as can be seen, the problem is still not solve, I'm looking into more advanced filtering techniques to try and reduce the lag.
^ Test ^ P ^ I ^ D ^
| G | 0.1 | 0.01 | 0.38 |
| H | 0.1 | 0.03 | 0.45 |
| I | 0.14 | 0.03 | 0.45 |
| J | 0.1 | 0.02 | 0.4 |
| K | 0.08 | 0.01 | 0.38 |
| L | 0.09 | 0.01 | 0.45 |
| M | 0.15 | 0.02 | 0.45 |
| N | 0.09 | 0.01 | 0.39 |
{{projects:mihab:pid2.png|}}
Here are the values used in the second test series
^ P ^ I ^ D ^
| 0.1 | 0.01 | 0.42 |
| 0.1 | 0.01 | 0.45 |
| 0.15 | 0.05 | 0.65 |
| 0.15 | 0.04 | 0.75 |
| 0.15 | 0.03 | 0.7 |
{{projects:mihab:PID.PNG|}}
{{projects:mihab:tests.png|}}
Interestingly, when the rudder was made smaller, the period of oscillation increased, but the stability did not improve noticably. Runs D and E took place with a larger rudder (approx twice the area) of the later tests.
Here is a test running down the street. Some turns were made to avoid parked cars. Column C is servo position in degrees multiplied by approx 2.5 and D is heading offset from target.
{{projects:mihab:test.png|}}
==== Parawings/foils ====
Okay, well everybody is getting excited by them, so I've been experimenting with parawings, it does seem promising. Parafoils can be made from parafoil kites (off ebay for less than £20), but IMHO trimming them could be a pain and they are not brilliantly stable. Using a hang glider type design the parawing is probably more reliable, but only if it is semi rigid. I've made a [[http://video.google.co.uk/videoplay?docid=-6576176457419263303|video]] of a semi rigid parawing or Rogallo wing test.
I have now made a large Rogallo wing (sides 1.2M long) and got a 27MHz radio (Green band) to control it. This should be flying in the next few days :-)
==== Blueprint ====
This is the current idea, I have found 433Mhz antennas over at [[http://www.active-robots.com/products/radio-solutions/antennae.shtml|active robots]], or [[http://www.simplesolutions-uk.com/index.php?do=products&sub=showdetails&pid=89|Simple solutions]] so one of these looks good for the downlink. It will need a ground plane, a sheet of PCB might work, the radio could even be built on the other side. Rocketboy has some 300 baud modems for the 433Mhz band, the same as on MiHAB2. The gps ant may be moved to under the wings, and I hope to get a GPS helix antenna as well. The cutdown has not had much consideration, currently the hardware I've built is for a resistor based cutdown, but I may go for pyro one. The camera will hopefully have a UV filter over the lens, as these seem to help a lot. Fuselage will be made of blue insulation foam "styrofoam". The wings will be off an RC plane, and the tail will need some consideration, I will need little hinges similar to off some RC planes. The phone may be left out as radio has been very sucessful and phone coverage is by no means total, as UKHAS1 demonstrated. Leaving out the phone will save a lot of weight and space.
{{projects:mihab:glider.png|}}
(The 433Mhz antenna may be moved to under the wings, and the gps antenna may also be repositioned)
==== Master unit development ====
Following MiHAB3 this was heavily damaged, but repairs have now been made. Also the camera from MiHAB2 and 3 (yes it still works!) has been modified to use AA batteries for approx 5 hours battery life.
{{projects:mihab:p3080019.jpg?800|}}
==== Modular design ====
The aim is to build an autopilot module that can be integrated with other payloads and gumstix and take control of a
glider. There will be a command set for controling the module over a bidirectional serial link running a 19200 baud TTL logic levels, with RTS and CTS lines. There is a 10ms pause between the transmittion of each line from the autopilot.
=== Commands ===
- SLEEP puts the autopilot into sleep mode, servo off, replies "GOING TO SLEEP"
- WAKE UP wakes it up, replies "AWAKE"
- TARGET enables setting of target in decimal degrees, north followed by east.
- WIND enables setting of the predicted wind at this altitude, angle followed by speed in knots
- STATUS replies with list of variables, see code
- ABOUT displays a message about the autopilot
- CONSTANTS enables the setting of the P and I loop constants
- CUTDOWN cuts down the glider
=== Size ect ===
For the present autopilot size is approx 9x4x4cm, weight 70 grams for the electronics
==== Theory of operation ====
The plan is to make an autopilot that requires GPS only. I've considered digital compasses but decided that the errors caused by non horizontal positioning were a problem. However a rate gyro might be used in the future to increase the update speed, which at the moment is 1 Hz. Meaning that the glider will have to execute slow turns. The GPS velocity is only accurate at high speed >10mph , but hopefully this should not be a serious problem, as speed will be around 20mph at landing and higher in lower density atmospheric conditions. Wind data is collected on the way up and used to find the airspeed on the way down. There is not enough ram on the atmega8 to store accurate wind data, so this must be sent to the autopilot via the interface, hence the wind command. The code keeps the air vector pointing towards the target. There are a number of stages that can be seen in the code, first the gps fix must be converted into decimal degree format, then the distance to the target in equatorial degree units is found, i.e. units of distance where 1 is equal to 1 degree of longditude along the equator. We can then use arctan to find the bearing to the target, and rotate the wind vector and absolute heading vector into target=y frame of reference. Next we convert to cartesian coords, so wind can be subtracted from absolute velocity (what the GPS gives us) to give the air speed as a vector in the target_direction=Y frame. Finally we use a final arctan to get the offset angle of the airspeed from the target direction, and feed this into the final stage of servo control. There is also some code to drive indicator LEDs (power, GPS lock and left or right of target bicolor led), and some sanity checks at various stages to get our angles back to the +-180 degree range. If we are heading away (airspeed wise) from the target then the servo just goes to servomax. The final stage of servo control is via a PI loop, see wikipedia for more info on that. The servo pulses are generated by interrupts running off two registers, compare1a and compare1b, than go high when timer1 reaches their value.
==== Autopilot Module source code ====
Sorry this is poorly commented, hopefully its understandable. It's writtem in bascom basic, which can be found over at [[http://www.mcselec.com/]]
$regfile = "m8def.dat"
$crystal = 16000000
Const Servomax = 2895
Const Servomid = 2290
Const Servomin = 1685
Const Factor =(servomax - Servomin) / 60
Dim S As String * 80
Dim B As String * 6
Dim Contents(12) As String * 11
Dim N As Byte
Dim I As Byte
Dim K As Single
Dim Recievedstring As Byte
Dim Intcount As Integer
Dim Test As Integer
Dim L As Integer
Dim Integral As Single
Dim T As Single
Dim Target As Single
Dim Offset As Single
Dim Wind_theta As Single
Dim Wind_theta_store As Single
Dim Wind_speed As Single
Dim X As Single
Dim Y As Single
Dim V As Single
Dim Wind_x As Single
Dim Wind_y As Single
Dim North As Single
Dim East As Single
Dim Target_e As Single
Dim Target_n As Single
Dim Store_east As Single
Dim Store_north As Single
Dim V_x As Single
Dim V_y As Single
Dim Minutes As String * 7
Dim Degrees As String * 3
Dim Command As String * 10
Dim P_constant As Single
Dim I_constant As Single
Baud = 4800
Open "comb.0:4800,8,n,1,inverted" For Input As #1
Open "comc.2:19200,8,n,1,inverted" For Input As #2
Open "comc.3:19200,8,n,1,inverted" For Output As #3
Declare Sub Serialio()
Config Serialin = Buffered , Size = 128 , Bytematch = 10
Config Pinc.5 = Input
Config Portc.4 = Output
Config Portb.1 = Output
Echo Off
P_constant = -0.60
I_constant = -0.15
Config Portd = Output
Config Timer1 = Timer , Prescale = 8
On Compare1a Tim1_isr1
On Compare1b Tim1_isr2
Intcount = 0
Recievedstring = 0
Portc.4 = 0
Portb.1 = 0
Compare1b = 40000
Compare1a = Servomid
Enable Interrupts
Enable Compare1a
Enable Compare1b
Do
Again:
If Pinc.5 = 1 Then
Call Serialio()
End If
If Recievedstring = 1 Then
Input S
Recievedstring = 0
B = Mid(s , 2 , 6 )
If B = "$GPRMC" Then
Goto Process
End If
End If
Goto Again
Process: 'code to get decimal degrees
I = Split(s , Contents(1) , ",")
Degrees = Left(contents(4) , 2)
Minutes = Right(contents(4) , 7)
Wind_theta = Wind_theta_store - Target
Wind_theta = Deg2rad(wind_theta)
Wind_x = Sin(wind_theta) 'WORK OUT WIND IN TARGET =Y FRAME
Wind_x = Wind_x * Wind_speed
Wind_y = Cos(wind_theta)
Wind_y = Wind_y * Wind_speed
North = 0
North = Val(minutes)
North = North / 60
K = 0
K = Val(degrees)
North = K + North
Degrees = Left(contents(6) , 3)
Minutes = Right(contents(6) , 7)
East = 0
East = Val(minutes)
East = East / 60
K = 0
K = Val(degrees)
East = K + East
If Contents(7) = "W" Then
East = -east
End If
Store_east = East
Store_north = North
East = Target_e - East
K = Deg2rad(north)
K = Cos(k)
East = East * K 'distance to target in equatorial degree units
North = Target_n - North
K = East / North
Target = Atn(k)
Target = Rad2deg(target)
If North < 0 Then 'direction to target
Target = Target - 180
End If
If Target < -180 Then
Target = Target + 360
End If
K = 0
K = Val(contents(9))
Print K
V = 0
V = Val(contents(8))
V = V + 0.01
K = K - Target
K = Deg2rad(k)
X = Sin(k)
X = X * V
Y = Cos(k)
Y = Y * V
V_x = X
V_y = Y
X = X - Wind_x
Y = Y - Wind_y
X = X / Y
If Y = 0 Then
X = 0
End If
K = Atn(x)
K = Rad2deg(k)
If Y < 0 Then
K = K - 180
End If
If K < -180 Then
K = K + 360
End If
Test = Val(contents(4)) 'indicator leds
If Test = 0 Then
Portd.3 = 0
Else
Toggle Portd.3
End If
If K > 0 Then
Portd.4 = 0
Portd.5 = 1
Else
Portd.4 = 1
Portd.5 = 0
End If 'start of main stuff
Offset = K
If Y < 0 Then 'tracking algorithm only active for air vector-> target
K = Servomax 'to avoid possibility of going in opposite direction
Else
T = K * 0.1
Integral = Integral + T
T = Integral * I_constant
If T > 10 Then 'integral windup prevention
Integral = 10 / I_constant
End If
If T < -10 Then
Integral = -10 / I_constant
End If
K = K * Factor
K = K * P_constant
K = K + T
'SERVOMID is servo center position
K = K + Servomid
If K > Servomax Then
K = Servomax
End If
If K < Servomin Then '+ - 30 degree servo limits
K = Servomin
End If
End If
L = K
Compare1a = L
Loop
'tells us if we've got a string
Serial0charmatch:
Recievedstring = 1
Return
Tim1_isr1:
Portd.2 = 0
Return
Tim1_isr2:
Timer1 = 0
Portd.2 = 1
Return
Sub Serialio()
Waituntilservooff:
If Portd.2 = 1 Then 'wait until the servo is off
Goto Waituntilservooff
End If
Disable Interrupts 'then disable interrupts
Print "Rts-->Cts"
Portc.4 = 1 'allow transmittion from master
Input #2 , Command
Portc.4 = 0
Select Case Command
Case "SLEEP" : Waitms 10
Print #3 , "GOING TO SLEEP"
Goto Sleepmode
Case "STATUS" : Waitms 10
Print #3 , Command 'reply saying what the command was
Waitms 10
Print #3 , Target_n
Waitms 10
Print #3 , Target_e
Waitms 10
Print #3 , Wind_y
Waitms 10
Print #3 , Wind_x
Waitms 10
Print #3 , Store_north
Waitms 10
Print #3 , Store_east
Waitms 10
Print #3 , V_y
Waitms 10
Print #3 , V_x
Waitms 10
Print #3 , Target
Waitms 10
Print #3 , Offset
Waitms 10
Print #3 , Integral
Waitms 10
Print #3 , Compare1a
Case "TARGET" : Waitms 10
Print #3 , Command
Input #2 , Target_n
Waitms 10
Print #3 , Target_n
Input #2 , Target_e
Waitms 10
Print #3 , Target_e
Case "WIND" : Waitms 10
Print #3 , Command
Input #2 , Wind_theta_store
Waitms 10
Print #3 , Wind_theta_store
Input #2 , Wind_speed
Waitms 10
Print #3 , Wind_speed
Case "ABOUT" : Waitms 10
Print #3 , Command
Waitms 10
Print #3 , " # This is an autopilot module, commands are: "
Waitms 10
Print #3 , " # TARGET, WIND, SLEEP, WAKE UP, STATUS, CONSTANTS, CUTDOWN, and ABOUT."
Waitms 10
Print #3 , " # Firmware was written by Laurence Blaxter in Bascom basic, 2006"
Waitms 10
Print #3 , " # enjoy :-]"
Case "CONSTANTS" : Waitms 10
Print #3 , Command
Waitms 10
Print #3 , P_constant
Waitms 10
Print #3 , I_constant
Input #2 , P_constant
Waitms 10
Print #3 , P_constant
Input #2 , I_constant
Waitms 10
Print #3 , I_constant
Case "CUTDOWN" : Waitms 10
Print #3 , Command
Portb.1 = 1
Wait 10
Portb.1 = 0
Case Else : Waitms 10
Print #3 , "WTF?"
End Select
Goto Subend
Sleepmode:
If Pinc.5 = 0 Then 'wait until rts recieved
Goto Sleepmode
End If
Portc.4 = 1
Input #2 , Command
Portc.4 = 0
Waitms 10
If Command = "WAKE UP" Then
Print #3 , "AWAKE"
Goto Subend
Else
Print #3 , "WTF?"
End If
Goto Sleepmode
Subend:
Enable Interrupts
End Sub
Close #1
Close #2
Close #3
End
==== 4HZ GPS ====
Finally after much h4xoring I have worked out how to set the GPS to 4hz mode, 38400 baud and change the "dynamic platform model" to aircraft autopilot. Used u-center configuration tool and a serial port monitor. I've now got some code for the micro to print when it boots to reset the GPS.
Unfortunately the GPS module seems to be drawing 350ma of current, it should be using less than 160ma, so there appears to be a ploblem, but I can't find it. I may try to contact u-blox and ask for advice. However, using 4 AA lithium batteries, the glider should still have in the order of 5 hours battery life.
Print Chr(181) ; Chr(98) ; Chr(6) ; Chr(19) ; Chr(0) ; Chr(0) ; Chr(25) ; Chr(81) ; Chr(181) ; Chr(98) ; Chr(6) ; Chr(8) ; Chr(0) ; Chr(0) ; Chr(14) ; Chr(48); 'config
Print chr(181);chr(98);chr(6);chr(8);chr(6);chr(0);chr(250);chr(0);chr(1);chr(0);chr(1);chr(0);chr(16);chr(150);chr(181);chr(98);
Print chr(6);chr(8);chr(0);chr(0);chr(14);chr(48);chr(181);chr(98);chr(6);chr(0);chr(1);chr(0);chr(1);chr(8);chr(34);chr(181);
Print chr(98);chr(6);chr(18);chr(0);chr(0);chr(24);chr(78);chr(181);chr(98);chr(6);chr(14);chr(0);chr(0);chr(20);chr(66);chr(181);
Print chr(98);chr(6);chr(2);chr(1);chr(0);chr(0);chr(9);chr(41);chr(181);chr(98);chr(6);chr(1);chr(2);chr(0);chr(1);chr(6);
Print chr(16);chr(57);chr(181);chr(98);chr(6);chr(3);chr(0);chr(0);chr(9);chr(33);chr(181);chr(98);chr(6);chr(3);chr(28);chr(0);
Print chr(6);chr(3);chr(16);chr(24);chr(20);chr(5);chr(0);chr(60);chr(60);chr(20);chr(232);chr(3);chr(0);chr(0);chr(0);chr(23);
Print chr(250);chr(0);chr(250);chr(0);chr(100);chr(0);chr(44);chr(1);chr(15);chr(0);chr(0);chr(0);chr(145);chr(84);chr(181);chr(98);
Print chr(6);chr(0);chr(1);chr(0);chr(1);chr(8);chr(34);chr(181);chr(98);chr(6);chr(0);chr(20);chr(0);chr(1);chr(0);chr(0);
Print chr(0);chr(208);chr(8);chr(0);chr(0);chr(0);chr(150);chr(0);chr(0);chr(7);chr(0);chr(3);chr(0);chr(0);chr(0);chr(0);
Print chr(0);chr(147);chr(144);chr(181);chr(98);chr(6);chr(0);chr(1);chr(0);chr(1);chr(8);chr(34);
Mark 2 adaptor board !:
{{projects:mihab:p3100022.jpg?450|}}
GPS now has adaptor board:
{{projects:mihab:p3080020.jpg?450|}}
However I am very worried about components overheating in low air density conditions, so the voltage regulators will be swapped for a high current version.
I now have a 4hz gps from u-blox, off ebay for £20 :) Also, u-center, off the u-blox website, which is a very nice application that can also be integrated with maps, could be used for real time tracking with a radio. This demo board is nice and has a 3W switched mode power supply, so I may use it in the glider if I have spare space.
{{:projects:mihab:p2140038.jpg?700|Plane2}}
==== RC plane testing ====
Following the failure of boat testing, I need something faster, preferably an RC plane where control can be passed to the autopilot by the pilot. I've got a glow engine plane but no experience of flying it, so any RC plane enthusiasts are welcome to help out. I've now modified an RC plane to take the autopilot, but the radio reciever had to be removed. Here are some photos. The cut down is capible of running motors, so I am investigating the possibility of reattatching the origional motors, with a li-poly battery of increased voltage (7.4 or 11.1 volts) to power the plane, or fixing a brushless motor with folding prop to the front, and using a brushless speed controller with an additional servo channel from the micro. Weight is the big problem, it will end up weighing more than the origional, so I will have to increase thrust somehow. The other plan is to tow it with an rc plane and use the cut down on the front to cut it loose.
{{:projects:mihab:p1050036.jpg?700|Plane2}}
this now has a 1.1 volt, 1.2 Ah li poly battery in the nose
{{:projects:mihab:p1050035.jpg?700|Plane}}
{{:projects:mihab:IMAG0296.JPG?700|glider}}
Tape is just temporary while the epoxy was setting :-)
{{:projects:mihab:IMAG0048.JPG?700|glider2}}
==== Boat testing ====
I decided that boats are not a good idea, they move too slowly for the gps velocity to be accurate, also pond water smells and a sinkage could prove expensive, anyway here's a photo of my first boat, I tried a catamerang after this as it doasn't sink as easily.
{{:projects:mihab:boat.jpg?700|:projects:mihab:boat.jpg}}