LibrePilot Forum

Development => Hardware => Topic started by: jdl on November 20, 2018, 10:24:42 am

Title: Using full range of MPXV7002 analog airspeed sensor
Post by: jdl on November 20, 2018, 10:24:42 am
I'd like to share my hardware solution for the problem with the limited usable range of analog airspeed sensor (MPXV7002) connected to ADC port of Revo FC.

The problem root is that MPXV7002 Full Scale Output can go as high as 4.75V while the ADC port can measure up to 3.3V. While the analog input is safe and doesn't burn, because the MPXV7002 Output Source Current at Full Scale Output is only 0.1mA, Revo FC cannot measure airspeeds higher than 112-125km/h (depending on zero point). This may compromise the usefulness of Airspeed PID Scaling at higher speeds. It can be observed during high-speed dives in stabilized modes, let say 170+km/h. Not that I often fly this way... but why not the things to be made right.

The simplest solution is to put a voltage divider with two resistors on the output of MPXV7002 and use a respectively corrected value for "gain" in the airspeed settings in Revo FC. I found that iNav uses this approach. I do not like it, it inevitably causes a loss of precision. The correct airspeed value is vital for autopilot flight. And I often rely on it even when flying in manual to keep a safe margin over the stall speed of the plane.

So I've built a simple and cheap "voltage shifter" module. It subtracts a fixed value of approx. 1.68V (with the nominals of resistors I've used) from the MPXV7002 output, preserving its linearity and gain while keeping it well below 3.3V, even at Full Scale Output.

Now the max measurable airspeed is approx. 200km/h. On bench tests I've seen a max value of 202km/h :)

With the module attached, the value in GCS | Settings | AirspeedSettings | ZeroPoint is somewhere around 1250, instead of, let's say, 3380 when MPXV7002 is directly connected to Revo.

I've built the module on a prototype board with full-size components. Together with the heat-shrink tubing, cables and plugs it weights 9gr. I guess if it is built with SMD components on a tiny PCB the weight could be reduced to 3-4gr max.

The TL082 IC is two OpAmps in a common package. TC7660 IC is a charge pump voltage converter. I use it to obtain the negative power supply (-5V) for the OpAmps. Use of low ESR caps (10uF ones) is suggested.

The prototype module is mounted on one of my planes (Mini Talon) and has already passed hours of in-flight tests without issues.

I've also recently did a fully automated 40+km flight with 20 waypoints and the airspeed readings were perfectly plausible during the whole flight.

Here is the schematic of the module and how my prototype looks like:
Title: Re: Using full range of MPXV7002 analog airspeed sensor
Post by: TheOtherCliff on November 20, 2018, 01:02:37 pm
I smiled when I read bench tests.  :)

So how far have you flown with this setup?  Waypoint or FPV?
Title: Re: Using full range of MPXV7002 analog airspeed sensor
Post by: jdl on November 20, 2018, 01:47:17 pm
Bench tests were not to test accuracy but max values ;)
Plane sitting on the bench while powerfull source of positive pressure (me, blowing into the pitot tube  ;D) introduced to the front inlet of pitot tube. Of course, I was overcautious to do no harm to the sensor. Inflating/blowing into the pitot tube / MPXV7002 by mouth is generally a BAD idea.

That waypoint flight I mentioned was 41km on odometer, max distance from home little more than 7km. 20 waypoints. It was FPV flight also, I was watching it in the goggles with RC transmitter in hands, ready to take control if something goes wrong.

Hopefully I'll find time to post a topic about it in the next few days, I had some interesting observations/issues with LP GCS and Revo firmware concerning waypoint flights that deserve attention.
Title: Re: Using full range of MPXV7002 analog airspeed sensor
Post by: TheOtherCliff on November 20, 2018, 06:48:23 pm
The main issue I found was that there are several airspeed limit settings and generally if these limits are exceeded, then by default it will return to waypoint #1.  Mine seemed to be flying well, so I disabled all this by setting each waypoint "error destination" to -1.  After a lot more local waypoint testing I felt confident to fly farther with waypoints.

Part of my problem was self caused.  The velocity PID oscillated from full off to full on with a period of perhaps 15 seconds and rather than tune it properly, I set MinThrust=Neutral=Max=0.6 and set MinAirspeed=Max=12m/s which work well on this aircraft.