Added true airspeed measurement
Added true airspeed measurement
Hi guys,
I implemented reading true airspeed (differential pressure) using the MPXV7002 sensor, which is part of e.g. the DIY drones airspeed kit.
I partially orientated on the ardupilot code (averaging, zeroing).
The measured airspeed is transferred in cm/s via debug[3] and MSP_MISC (2nd entry) currentyl. Any GUI/app then can recalculate in m/s, ft/s, km/h, mph etc.
I think this is a nice feature especially for airplane user. In future it maybe can be used for auto-throttle, landing etc...
Just see it as a first shot...
You can find it in my branch: http://code.google.com/p/multiwii/sourc ... hes%2FKaiK
I implemented reading true airspeed (differential pressure) using the MPXV7002 sensor, which is part of e.g. the DIY drones airspeed kit.
I partially orientated on the ardupilot code (averaging, zeroing).
The measured airspeed is transferred in cm/s via debug[3] and MSP_MISC (2nd entry) currentyl. Any GUI/app then can recalculate in m/s, ft/s, km/h, mph etc.
I think this is a nice feature especially for airplane user. In future it maybe can be used for auto-throttle, landing etc...
Just see it as a first shot...
You can find it in my branch: http://code.google.com/p/multiwii/sourc ... hes%2FKaiK
Re: Added true airspeed measurement
good.
Problem with branches is, they are outdated so fast. From past experience this means you will not get many testers/users, unless you keep that branched version updated over long time. Not desirable, imho.
Can you provide
- the version which you started with and modified
- a diff file
It would then be easier to grasp the changes/additions, estimate possible side effects (if any) and merge into the _shared branch. (Of course, you might do the merge yourself.)
Did you modify the GUI already to take advantage of the new data?
Problem with branches is, they are outdated so fast. From past experience this means you will not get many testers/users, unless you keep that branched version updated over long time. Not desirable, imho.
Can you provide
- the version which you started with and modified
- a diff file
It would then be easier to grasp the changes/additions, estimate possible side effects (if any) and merge into the _shared branch. (Of course, you might do the merge yourself.)
Did you modify the GUI already to take advantage of the new data?
Re: Added true airspeed measurement
Thank you for your comments, Hamburger!
I started with Revision 1113, as stated in folder naming. Please see the differences below. Any feedback, especially regarding speed (improvement) and type cast (int -> float -> int) are welcome.
I will add this to shared if some of you give a ok...
I didnt modify the gui, but will do this after adding to shared...
I started with Revision 1113, as stated in folder naming. Please see the differences below. Any feedback, especially regarding speed (improvement) and type cast (int -> float -> int) are welcome.
I will add this to shared if some of you give a ok...
I didnt modify the gui, but will do this after adding to shared...
Code: Select all
config.h
849a852,872
> /********************************************************************/
> /**** airspeed sensor ****/
> /********************************************************************/
>
> /* Airspeed sensor will initialize in one second on bootup of controler. Take care not letting the wind blow into pitot tube! */
>
> #define AIRSPEED // uncomment this line to activate the airspeed code
> #define AIRSPEED_PIN A4 // Analog PIN 4
> #define AIRSPEED_FACTOR 11.96 // Calculation see bottom annotations
>
> /* Background for calculation of AIRSPEED_FACTOR
> v [m/s]= sqrt(2 * roh * delta-pressure[Pa])
>
> 1 increment (Analog read) = VCC/1024 = 5V/1024 = 0.0048828125 = 0.00488V = 4.88mV
> Datasheet of MPXV7002: 1 = 1kPa -> 1mV = 1Pa
> roh(@15 �C, 1bar air pressure) = 1,225 kg/m�
>
> -> 1 increment = 4.88mV = 4.88Pa
> -> v [m/s] = sqrt(2 * roh * delta-pressure[Pa]) = sqrt(2 * roh * 4.88 * AnalogReadIncrements)
> AIRSPEED_FACTOR = 2 * roh * 4.88
> */
850a874
>
993c1017
< /*************************************************************************************************/
---
> /*************************************************************************************************/
MultiWii.ino
170a171,176
> #if defined(AIRSPEED)
> static float airpressureRaw = 0;
> static uint16_t airpressureOffset = 0;
> #endif
> static uint16_t airspeedSpeed = 0; //needs to be set anyway, as it is called in serial communication and therefore needs to be defined.
>
600a607,609
> #if defined(AIRSPEED)
> Airspeed_init();
> #endif
979c988
< switch (taskOrder++ % 5) {
---
> switch (taskOrder++ % 6) {
1006a1016,1021
> break;
> case 5:
> #if defined(AIRSPEED)
> Airspeed_update();
> debug[3] = airspeedSpeed;
> #endif
Sensors.ino
1556a1557,1583
> #if defined(AIRSPEED)
> /* Inspired by ArduPilot code. Thanks guys! */
>
> void Airspeed_update() {
> airpressureRaw = ((float)analogRead(AIRSPEED_PIN) * .10) + (airpressureRaw * .90); //Think about smoothing
>
> if(airpressureRaw - airpressureOffset<0) {
> airspeedSpeed = 0;
> }
> else {
> airspeedSpeed = sqrt((airpressureRaw - airpressureOffset) * AIRSPEED_FACTOR)*100; // m/s * 100 = cm/s
> }
> }
>
> void Airspeed_init() {
> /* Reading airspeedRaw for some cycles/1s and storing as zero value */
>
> airpressureRaw = (float)analogRead(AIRSPEED_PIN);
>
> for(int airspeedI=0; airspeedI < 50; airspeedI++){
> delay(20);
> airpressureRaw = ((float)analogRead(AIRSPEED_PIN) * .10) + (airpressureRaw * .90); //Think about smoothing
> }
> airpressureOffset = airpressureRaw;
> }
>
> #endif
Serial.ino
46c46
< #define MSP_MISC 114 //out message powermeter trig + 8 free for future use
---
> #define MSP_MISC 114 //out message powermeter trig + Airspeed + 7 free for future use
375a376
> serialize16(airspeedSpeed);
Re: Added true airspeed measurement
unified diff is much easier to read and apply manually
Re: Added true airspeed measurement
KaiK wrote:I started with Revision 1113, as stated in folder naming.
my bad
Not to say I know how to code well, but for the MWii project Alex has stated some guidelines like
- avoid float if possible
Also the loop with delay() for initialization, cannot this happen automagically when power attached and not yet armed?
Soem possible changes
Code: Select all
config.h
// no float
> #define AIRSPEED_FACTOR 1196 // Calculation see bottom annotations
// no float
> airpressureRaw = (analogRead(AIRSPEED_PIN) * 10) + (airpressureRaw * 90) / 100; //Think about smoothing
// no float, the other *10 is in the sqrt(constant*100)
> airspeedSpeed = sqrt((airpressureRaw - airpressureOffset) * AIRSPEED_FACTOR)*10; // m/s * 100 = cm/s
-
- Posts: 1630
- Joined: Wed Jan 19, 2011 9:07 pm
Re: Added true airspeed measurement
Hi,
Adding a new sensor type might be a good thing.
But the purpose of this sensor needs to be clearly explain before adding code.
I see no interest for a multi rotor.
I suppose it could be useful for fix wing configs and navigation purpose.
To my mind, a code prototype of the final purpose should exist before merging it in _shared.
Adding a new sensor type might be a good thing.
But the purpose of this sensor needs to be clearly explain before adding code.
I see no interest for a multi rotor.
I suppose it could be useful for fix wing configs and navigation purpose.
To my mind, a code prototype of the final purpose should exist before merging it in _shared.
Re: Added true airspeed measurement
It would be perfect for airplanes!
To replace the TPA function with a Speed PA function.
Decreas PID's with speed instead of throttle!
To replace the TPA function with a Speed PA function.
Decreas PID's with speed instead of throttle!
Re: Added true airspeed measurement
I think having your speedgun onboard is cool for multicopters too.
Re: Added true airspeed measurement
uhmm... speed in cm/sec. Does this mean one can create in conjunction with other sensors (zero speed) non drifting multicopter? That would be great
-
- Posts: 2261
- Joined: Sat Feb 19, 2011 8:30 pm
Re: Added true airspeed measurement
Well, the copters can move sideways and backwards, don't believe forward speed will help in these situations.
Re: Added true airspeed measurement
You just need four of those sensors
Re: Added true airspeed measurement
I hope Multiwii will be more popular for using with planes in the future and will developed in this direction, too, to get a full "Airdrone suite"
So I think its a interesting sensor, espacially for autothrottle and landing...
So I think its a interesting sensor, espacially for autothrottle and landing...
Re: Added true airspeed measurement
6 of them and you get 1 cm drift and 1cm altitude hold. I can live with that
The question is: who can make such a sensor...
The question is: who can make such a sensor...
Re: Added true airspeed measurement
Quadraf wrote:6 of them and you get 1 cm drift and 1cm altitude hold. I can live with that
The question is: who can make such a sensor...
You realize that this would only work with no wind?
Re: Added true airspeed measurement
Sebbi wrote:Quadraf wrote:6 of them and you get 1 cm drift and 1cm altitude hold. I can live with that
The question is: who can make such a sensor...
You realize that this would only work with no wind?
Nope... In that case incapsulate it with foam.
-
- Posts: 2261
- Joined: Sat Feb 19, 2011 8:30 pm
Re: Added true airspeed measurement
Sebbi wrote:Quadraf wrote:6 of them and you get 1 cm drift and 1cm altitude hold. I can live with that
The question is: who can make such a sensor...
You realize that this would only work with no wind?
GPS reports ground speed. Hmmm.
-
- Posts: 2261
- Joined: Sat Feb 19, 2011 8:30 pm
Re: Added true airspeed measurement
Sebbi wrote:You just need four of those sensors
Might be able to get away with using two, flying backwards would report a negative number if using a differential pressure sensor. And for the Roll axis, positive right and negative for left. That is, if they can be shielded from the prop wash.
Re: Added true airspeed measurement
Airspeed sensor would be of great use on fixed wing platforms, so that the plane could "hold" a true airspeed against the wind and not stall... Its quite an essential sensor used in many other projects, now with the recent advances in PatrikE's fixed wing branch I would think it would be cool to have this sensor support.
-
- Posts: 506
- Joined: Thu May 05, 2011 8:13 am
- Location: Slovenia
Re: Added true airspeed measurement
msev wrote:Airspeed sensor would be of great use on fixed wing platforms, so that the plane could "hold" a true airspeed against the wind and not stall... Its quite an essential sensor used in many other projects, now with the recent advances in PatrikE's fixed wing branch I would think it would be cool to have this sensor support.
+1
Mentioned, discussed, wanted many times in Airplane RTH thread...
Regards
Andrej
Re: Added true airspeed measurement
Agreed ... needs official support. I bought one to try it out