As some of you may know, I've been building a UAV based on an Arduino Diecimila and a Multiplex EasyStar. The autopilot is pretty much done (though I'm sure it'll need to be tweaked once I do flight tests), but now I'm having a little bit of trouble with my manual override system. My plan is to hook up the Hitec receiver that came with the EasyStar to the Arduino, and just route any signals received on the three control outputs to the servos and motor through the Arduino.However, I'm not quite sure how to do this. Software-wise, I'm planning on using the PulseIn() function to measure the length of control pulses, but I don't know what to do hardware-wise. I ruled out polling early on, because it seems like that would give a delayed reaction time. This leaves interrupts. However, there are only two interrupt pins on the Diecimila, and one of them doesn't even appear to support PWM. I'm considering two main options right now:1. Attach the three control lines to three different PWM pins on the Arduino, but then also have them routed through an OR gate or something to the single interrupt pin. That way, when the interrupt is triggered, it looks for signals on the three different pins. One possible problem I thought there might be with this, though, would be that the processing time between when the signal hits the interrupt pin and when the program begins measuring pulse length on a different pin might make at least the first pulse appear shorter than it really is.2. Use an outside chip to somehow combine all three control signals into one signal, then route that to the Arduino as a serial signal, perhaps even as numbers instead of just raw pulses. The main problem with this is that I have no idea what outside chip I would use.However, I don't know if there are better options than these, and if one of them is the best option, I would not know how to implement it. Could you guys help me out?
You need to be a member of diydrones to add comments!
Went with manual control on the main computer because it opened more possibilities linearizing control surfaces with a neural network & the mechanical rate damping was removed. Software is required full time to control the angular rates. However the software needs to be bulletproof & you'll spend a lot of time writing auto reboot routines, failsafe routines, testing, testing & testing like a full time worker.
Had 1 crash due to software. It was software for file uploads that had a buffer overrun. A buffer offset in a corrupted radio packet could point beyond the end of the memory. Every other crash has been power bus lines failing, power connectors glitching, drive belts breaking, & servos burning out.
The multiplexer looks like a good option for me. My only concern with that would be how to determine whether the plane should be on manual control or not; the solution I came up with was to put a small fm receiver on the plane, and send an fm signal from the base station that tells whether to use automatic or manual control.
I had actually toyed with the idea of a second Arduino for a little while...after all, I would also like having another one around to play with : ) However, weight and current draw are big concerns for me right now, especially since I don't think I'm going to be able to get a brushless motor and lithium batteries right away.
Chris, that commercial RxMux product looks interesting, but do you know of any important features that it has beyond, say, the multiplexer chip that Achal recommended? I looked over the description, and it looks more or less like a breakout board for a mux chip, but for $80 there must be more.
I agree with Wayne. When you're under RC control, I don't think you really want to route all your signals through the Arduino. Instead you should use a hardware MUX, like Jordi's one.
With our blimp, which does not require high-speed real-time control, we do route two channels through the Arduino using Pulsein (code here), but it takes approx 30% of CPU time per channel, so there is a real performance cost to this method, and I think three channels would bring your Arduino to its knees.
Quix-fz has posted on how to do the same thing more efficiently with interrupts, but I agree that you have hardware limitations for more than two channels.
So back to the main point: I can't think of any good reason to route RC through the autopilot when you're under manual control. I suggest you go for a hardware mulitplexer, either a DIY one like Jordi's above, or a pre-made commercial one.
I think the best option would be to use a multiplexer chip like 74LS157. Reading the pulse first and generating it again does not seems to be a good option. The multiplexer can be controlled with only one output pin.
Replies
Had 1 crash due to software. It was software for file uploads that had a buffer overrun. A buffer offset in a corrupted radio packet could point beyond the end of the memory. Every other crash has been power bus lines failing, power connectors glitching, drive belts breaking, & servos burning out.
The multiplexer looks like a good option for me. My only concern with that would be how to determine whether the plane should be on manual control or not; the solution I came up with was to put a small fm receiver on the plane, and send an fm signal from the base station that tells whether to use automatic or manual control.
I had actually toyed with the idea of a second Arduino for a little while...after all, I would also like having another one around to play with : ) However, weight and current draw are big concerns for me right now, especially since I don't think I'm going to be able to get a brushless motor and lithium batteries right away.
Chris, that commercial RxMux product looks interesting, but do you know of any important features that it has beyond, say, the multiplexer chip that Achal recommended? I looked over the description, and it looks more or less like a breakout board for a mux chip, but for $80 there must be more.
With our blimp, which does not require high-speed real-time control, we do route two channels through the Arduino using Pulsein (code here), but it takes approx 30% of CPU time per channel, so there is a real performance cost to this method, and I think three channels would bring your Arduino to its knees.
Quix-fz has posted on how to do the same thing more efficiently with interrupts, but I agree that you have hardware limitations for more than two channels.
So back to the main point: I can't think of any good reason to route RC through the autopilot when you're under manual control. I suggest you go for a hardware mulitplexer, either a DIY one like Jordi's above, or a pre-made commercial one.