SpotPilot - Building an aircraft autopilot using a Sun Spot part 2
Posted by: Paul René Jørgensen in Airplane, Java, tags: Airplane, autopilot, hitec, rc, receiver, servo, spot, sun, sun spot
I just wanted to let you know about todays progress. The GPS module landed in the mailbox this morning, but I forced myself not to rush and wire it up to the Spot right away. I know that this GPS module is compatible with the Spot so there was no reason to rush it.
What I was more concerned with was the enable/disable switch and the rudder pass through signal. I started out wiring up the RC receiver to the spot and wrote some lines of code to get the pulse length of a signal connected to one of the Dx pins of the Spot.
private int getRCPulse() {
EDemoBoard edb = EDemoBoard.getInstance();
IInputPin pin = edb.getIOPins()[EDemoBoard.D3];
return edb.getPulse(pin, true, 30);
}
These few lines of code should give me the length of the pulse coming in on the D3 pin every 30 ms measured in microseconds. And guess what happened when I connected the battery? It worked!!
Next up was to prototype the rudder servo pass through. I added some more wires to the Spot connecting the servo signal cable to one of the Hx pins and made sure the servo was powered by the RC receiver.
Servo s = new Servo(EDemoBoard.getInstance().getOutputPins()[EDemoBoard.H1]);
while(true) {
int l = getRCPulse();
s.setValue(l);
System.out.println(l);
Utils.sleep(1);
}
This code reads the rudder RC channel and passes the value on to the connected servo. Amazing as it sounds, but it actually works!
I now have a spot decoding the RC receiver signal and later outputting it to a connected servo, passing it through the spot as if it was not there! This is what is supposed to happen when the autopilot is disabled. When I hit the gear switch on my transmitter the autopilot logics should kick in. But that is another story..



Entries (RSS)