Multiplex M-Link support for OpenXVario

Development & General Chat for the superb openxvario project.

Moderator: rainer

User avatar
kalle123
Posts: 905
Joined: Sat Mar 29, 2014 10:59 am
Country: -
Location: Moenchengladbach

Re: Multiplex M-Link support for OpenXVario

Post by kalle123 »

... and I got my second parcel from China today.

(Only two still on the way)

I like those small green stickers
Unbenannt.jpg
Bless the German custom ... :D

User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Multiplex M-Link support for OpenXVario

Post by jhsa »

I also got one today and one yesterday.. no problems. I guess the other day someone was just having a bad day at the customs.. Or maybe the envelops are selected by stupid machines ;)

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
kalle123
Posts: 905
Joined: Sat Mar 29, 2014 10:59 am
Country: -
Location: Moenchengladbach

Re: Multiplex M-Link support for OpenXVario

Post by kalle123 »

João, you are keeping me from doing something serious :roll:

Back to the topic M-Link and openX.
Change the telemetry display now on those values
#define SETUP_MULTIPLEX_DATA_TO_SEND \
3 , REL_ALTIMETER , 1 , 1 , 0 , -16384 , 16383 , \
4 , VERTICAL_SPEED , 1 , 1 , 0, -500 , 500 , \
6 , CELL_TOT , 1 , 1 , 0 , -16384 , 16383 , \
7 , CELL_MIN , 1 , 1 , 0 , -16384 , 16383 , \
9 , CURRENTMA , 1 , 1 , 0 , -16384 , 16383 , \
10 , MILLIAH , 1 , 1 , 0 , -16384 , 16383

#6 and #7 look good now (Thank you Klaus ;) )

Now the current.
I am using 1.1V ref. And calculated (better say I tried...) for an ACS 712/5A with 185 mV/A.
Voltage divider 39k / 10k.
// ***** 6.6 - Current sensor calibration parameters *****
#define OFFSET_CURRENT_STEPS 512
#define MAMP_PER_STEP 5.8122

OFFSET_CURRENT_STEPS = Offset to apply for current; normal value is 1024/2 for a bidirectional sensor because 0 Amp gives VCC/2 (or 1.1 V/2 when using a divider). -> 512

and

MAMP_PER_STEP = milliAmp per step from Analog to Digital Converter; the value depend on the sensitivity of the sensor (and on an eventual voltage divider). If no divider is used, the value of MAMP_PER_STEP is normally equal to V (in mvolt) / (sensitivity in mV/Amp * 1.023) where:
* - V is Vcc (e.g. 5000) or internal 1.1 ref (e.g. 1100) depending on the reference you use
* - Sensitivity is normally given in the datasheet from your sensor.
* E.g. For a ACS758LCB-050U, sensitivity is 60 mv/Amp
* So if using 5 volt Vcc => 5000 / (60 * 1.023) = 81.5.

I calculated that as 1100 / (185 * 1.023) = 5.8122

Works so far
DSCF3699.JPG
CURRENTMA shows a value and MILLIAH counts up. 2.5V on arduino pin A3 shows 0.0A
BUT. --- 5V show 2.5A (so my calculation must be wrong) and values < 2.5V on A3 show a static 0.0A

br KH - Any help tip is appreciated ;)
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Multiplex M-Link support for OpenXVario

Post by jhsa »

kalle123 wrote:João, you are keeping me from doing something serious :roll:
I do apologize. It is not my intention keeping you from doing something serious :? I also do it from time to time.. :lol:
* E.g. For a ACS758LCB-050U, sensitivity is 60 mv/Amp
* So if using 5 volt Vcc => 5000 / (60 * 1.023) = 81.5.

Now seriously, aren't you forgetting the offset voltage at 0 Amps for the unidirectional sensor? Check the datasheet. It is 600mV
From the datasheet:

Quiescent Output Voltage5

VIOUT(QUNI)
Unidirectional variant, IP = 0 A, TA = 25°C, VIOUT(QUNI) is ratiometric to VCC – 0.6 – V
João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
kalle123
Posts: 905
Joined: Sat Mar 29, 2014 10:59 am
Country: -
Location: Moenchengladbach

Re: Multiplex M-Link support for OpenXVario

Post by kalle123 »

jhsa wrote:
kalle123 wrote: Now seriously, aren't you forgetting the offset voltage at 0 Amps for the unidirectional sensor? Check the datasheet. It is 600mV
João.

I calculated for an ACS 712/5A.

That one is bidirectional. -5A <-> 0V, 0A <-> 2.5V, 5A <-> 5V.

OFFSET_CURRENT_STEPS = Offset to apply for current; normal value is 1024/2 for a bidirectional sensor because 0 Amp gives VCC/2 (or 1.1 V/2 when using a divider). So this one should be OK.

If no divider is used, the value of MAMP_PER_STEP is normally equal to V (in mvolt) / (sensitivity in mV/Amp * 1.023) where:
- V is Vcc (e.g. 5000) or internal 1.1 ref (e.g. 1100) depending on the reference you use
- Sensitivity is normally given in the datasheet from your sensor.
E.g. For a ACS758LCB-050U, sensitivity is 60 mv/Amp
So if using 5 volt Vcc => 5000 / (60 * 1.023) = 81.5.

But I am using a voltage divider 39k / 10k. I think, my error must be there ...

cu KH

mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Multiplex M-Link support for OpenXVario

Post by mstrens »

Here the way you should calculate.
I suppose that VCC for current sensor = 5V.
It means that at 0 Amp, it should deliver VCC/2 = 2.5 volt.
Because you are using a voltage divider, the voltage applied to analog pin of Arduino will not be 2.5 volt but will be reduced : 2.5 * 10 / (10 + 39) = 0.510204082 volt.
Knowing that if internal ref is 1.1v, it means that
- if 1.1 V is applied on Arduino, arduino will return 1023 steps
- so if 0.510204082 volt is applied on arduino pin, arduino will return : 0.510204082 / 1.1 * 1023 = 474 steps.
So in theory, offset should be 474.
In practice, it can be that this value is not 100% correct because VCC could be different fronm 5 volt, internal volt could be different from 1.1 volt and resistors are not exactly 10k and 39k. Best is to make a test and to adjust offset value in order to get 0 A when there is no current going via the current sensor.

About the milliAmp per step, the logic is the following:
a current of 1000 milli Amp generates a change of 185 mvolt at current sensor level.
Due to the divider, arduino does not get a change of 185 mvolt but only 185 * 10 / (10 + 39) = 37.75510204 mVolt
Knowing that a change of 1.1 volt generate 1023 arduino steps, 37.75510204 mVolt generates a change of 37.75510204 mv / 1100 mv * 1023 steps = 35.1122449 steps.
So if 1000 milliAmp <=> 35.1122449 steps, we can conclude that MAMP_PER_STEP = 1000 / 35.1122449 = 28.480093.

I hope this is clear.
If not let me know.
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Multiplex M-Link support for OpenXVario

Post by jhsa »

Hmmm, let's forget about the 1.1V here. For the ACS758-50U the voltage at 0 amps is 600mV, and then 60mv per Ampere, right? so, 1A is 600mV + 60mV = 660mV. 2A should be 720mV, correct?

So the voltage for the usable range is 5000mv - 600mV = 4400mV
So if using 5 volt Vcc => (5000-600) / (60 * 1.023) = 71.68??

Or am I completely south here? By the way, I'm terrible at math..

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
kalle123
Posts: 905
Joined: Sat Mar 29, 2014 10:59 am
Country: -
Location: Moenchengladbach

Re: Multiplex M-Link support for OpenXVario

Post by kalle123 »

Have to give a hand in the kitchen now. My wife needs assistance with preparing dinner ;)

@mstrens. Go through your advice later. Thank you!!!!

@João. Seems, you are on the southern hemisphere at the moment :mrgreen:

br KH
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Multiplex M-Link support for OpenXVario

Post by jhsa »

That's why I like the configurator ;) see what I mean?? The config.h file is not for normal people like me, if I can call myself normal of course :mrgreen:

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
KAL
Posts: 552
Joined: Thu Oct 10, 2013 4:36 pm
Country: Germany
Location: somewhere near Rothenburg ob der Tauber

Re: Multiplex M-Link support for OpenXVario

Post by KAL »

@João:
(I hope my english is not too south ... ;) )
The 600mV offset is independant from the gradient of the sensors
characteristic curve (the mV/step which is proportional to mA/step).
For this you have the OFFSET_CURRENT_STEPS.

Klaus
( TH9X / 9XTreme / FrSky DHT / Spektrum / Multi / RotEnc )
( 9XR PRO / erSKY9x  / FrSky DHT / Spektrum / Multi / RotEnc / P3 as Slider )
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Multiplex M-Link support for OpenXVario

Post by mstrens »

MAMP_PER_STEP is not related to the voltage at 0 volt (e.g. 600 mvolt).
Generally current sensor does not reach 100% of VCC at Amp max.
So MAMP_PER_STEP must be calculated based on sensitivity (60 mv per Amp for you ACS758-50U) and on voltage reference used by the Arduino.

We know that 1000 milliAmp generates a change of 60 mvolt.
Whe know that if voltage reference is 5 volt, it means that 5000 mvolt generates 1023 steps
So if there is no divider : 1000 milliAmp <=> 60 mvolt <=> 60 / 5000 * 1023 = 12.276 steps
So MAMP_PER_STEP = 1000 / 12.276 = 81.45975888
User avatar
kalle123
Posts: 905
Joined: Sat Mar 29, 2014 10:59 am
Country: -
Location: Moenchengladbach

Re: Multiplex M-Link support for OpenXVario

Post by kalle123 »

@mstrens. Your explanation is clear as always. So we are only using on the ACS 712 the 2.5 - 5V span. No negative current values in telemetry and no countdown of MILLIAH values. Anything else would not make sense!
Also waiting for next version of GUI.

Have a nice evening - br KH
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Multiplex M-Link support for OpenXVario

Post by jhsa »

I think I went a bit North now as soon as I removed my thinking hat from my head.. Must be broken obviously ;) :) Present form the wife for Xmas.. I think she wants me to be dumb hmmmmmm :o

Thanks for the explanation guys

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
kalle123
Posts: 905
Joined: Sat Mar 29, 2014 10:59 am
Country: -
Location: Moenchengladbach

Re: Multiplex M-Link support for OpenXVario

Post by kalle123 »

Really looks good :D

Have now those values on display
31.jpg
34.jpg
34.jpg (16.28 KiB) Viewed 14724 times
35.jpg
35.jpg (16.17 KiB) Viewed 14724 times
36.jpg
36.jpg (16.29 KiB) Viewed 14724 times
But one remark. mstrens pointed out "... internal volt could be different from 1.1 volt ..." and it surely is. A short search stated REF internal +/- 0.1V. Could see it here while adjusting current signal. So individual adjustment seems to be necessary in each case.

So br, a nice evening and thank you for the help ;) - KH
User avatar
Klausi
Posts: 6
Joined: Sun Jan 25, 2015 7:51 am
Country: Germany
Location: Achim
Contact:

Re: Multiplex M-Link support for OpenXVario

Post by Klausi »

Thank you for your great openXsensor software.

Because I ordered another pressure sensor (GY-68 BMP180) as you implemented in your solution I had to build my own solution for my pressure sensor.
BMP180
BMP180
So I took your latest version and made an integration of the Adafruit library.
I implemented the MS5611-interface (variodata, readsensor, ...) in the library for the BMP180 and created a new instance of the bmp-library named as oXs_ms5611.
This is my first Artduino project, so I also modified many functions in oXs, because my sketch didn't want to run. The modifications were not the reason.
But at the end I had success and got values on the MPX-display.
MPX openXsensor
MPX openXsensor

Klaus
Attachments
openXsensor.zip
my modifications
(79.27 KiB) Downloaded 263 times
Last edited by Klausi on Sat Jan 31, 2015 4:56 pm, edited 1 time in total.
User avatar
Klausi
Posts: 6
Joined: Sun Jan 25, 2015 7:51 am
Country: Germany
Location: Achim
Contact:

Re: Multiplex M-Link support for OpenXVario

Post by Klausi »

Made a patch for Adafruit library.
Add to library before compiling the sketch.
library add
library add
[BBvideo 320,240]https://www.youtube.com/watch?v=gzkO0dL6hn8[/BBvideo]

Klaus
Attachments
Adafruit_BMP085_Unified-master.zip
library
(8.95 KiB) Downloaded 214 times
User avatar
kalle123
Posts: 905
Joined: Sat Mar 29, 2014 10:59 am
Country: -
Location: Moenchengladbach

Re: Multiplex M-Link support for OpenXVario

Post by kalle123 »

Welcome Klaus.

I'll take your modified BMP085 library from here. So you don't have to post it in German forum rcline. ;)

br KH
User avatar
Klausi
Posts: 6
Joined: Sun Jan 25, 2015 7:51 am
Country: Germany
Location: Achim
Contact:

Re: Multiplex M-Link support for OpenXVario

Post by Klausi »

Today I finished my first openXsensor project.
It is my oXs4MPX.

I used theese sensors:
- BMP 180
- ACS712
- voltage sensor

Assembling the sensor
ard020.jpg
Finished sensor
ard021.jpg
Firmware update is possible
ard022.jpg
Klaus
User avatar
kalle123
Posts: 905
Joined: Sat Mar 29, 2014 10:59 am
Country: -
Location: Moenchengladbach

Re: Multiplex M-Link support for OpenXVario

Post by kalle123 »

The BMP180 sensors have arrived and I took the chance to have a very inexpensive oXs vario.

Arduino pro mini 2€ and BMP180 1.50€

Took the modified software from Klaus and had no issues on MPX. But I was in need for a oXs for FrSky.

Two comments:

I think, the delay value in "oXs_out_Frsky.cpp" should be generally raised.

and

my DIY "pressure chamber" helped a lot :mrgreen:
DSCF3817.JPG
For more info, have a look in German rclineforum -> http://www.rclineforum.de/forum/board49 ... ost3903148

br KH
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Multiplex M-Link support for OpenXVario

Post by mstrens »

I had just a short look at the library modified by Klausi.
I am not sure at all it is an optimised solution.

When the arduino reads the sensor using this library, it uses some delays (5 msec for the temperature and probably 26 msec for the pressure when asking for high precision). During those "delay" arduino is just waiting and do not perform any another tasks.
After the 2 wait times, it performs some calculations (e.g. altitude) and go back to the main loop.

In the original oXs program, waiting for an anwser from the sensor is not blocking.
OXS sends the command to the sensor and just go back to the main loop, reading the sensor again just do nothing as long as the delay required by MS5611 (9 ms) is not expired.

The result is that the main program loop runs less often with the BMP180 library: it runs only once every 35 msec instead of every 2 up to 5 msec.

Each time the program enters the main loop it normally reads also a voltage and a current.
The transmitted values are averages based on the number of reading performed over e.g. 500 msec.
The accuracy of those averages are better when the averages are based on a greater number of readings.
So, it is better to run the main loop as often as possible avoiding blocking "delay()".

In oXs there is also some code to avoid reading other sensors (e.g. volt and current) when there is less than 1 msec before baro sensor data would become available (what is expected 9 msec after sending a command to the sensor).
This is done in order to give priority to the baro sensor and so reading it as often as possible. This allows better filtering of the sensor data and so less noise on the calculated vertical speed.
This uses normally the variable lastCommand2Micros.
It seems that with the BMP180 this variable is not updated. It could be that some tests are not correct anymore and that some measurements (voltage/current, ...) would not be performed in all cases).
In the best cases, other measurements are performed but add some delay to the pressure/altitude reading.


Please note also that original oXs allows to read 2 baro sensor2 (each sensor having a different I2C address).
I think that this feature is not correctly implemented when the BMP180 are used.

Conclusion: in order to get the optimal performances when using a bmp180 sensor, I think it would be better to rewrite the program reading the sensor based on the principle used for MS5611 instead of using the BMP180 library.
If you want, I could try to write it but I could not test the program (having no BMP180).

Based on what I read on internet, I expect that the accuracy of the vertical speed provided by a BMP180 would be less than with a MS5611.
I read that BMP280 is better than BMP180 but I did not find on ebay a board (like the GY-63) supporting a 3.3 regulator and an I2C voltage shifter.
So, it is not so easy to connect a BMP280 to an arduino pro mini.
User avatar
kalle123
Posts: 905
Joined: Sat Mar 29, 2014 10:59 am
Country: -
Location: Moenchengladbach

Re: Multiplex M-Link support for OpenXVario

Post by kalle123 »

Hi mstrens.

I don't know, if Klaus takes a regular look here. But I will point him to your comments here.

br KH
User avatar
kalle123
Posts: 905
Joined: Sat Mar 29, 2014 10:59 am
Country: -
Location: Moenchengladbach

Re: Multiplex M-Link support for OpenXVario

Post by kalle123 »

mstrens wrote: I read that BMP280 is better than BMP180 but I did not find on ebay a board (like the GY-63) supporting a 3.3 regulator and an I2C voltage shifter.
So, it is not so easy to connect a BMP280 to an arduino pro mini.
Did you see this one here? The shield is a little big from size ....

http://www.watterott.com/de/BMP280-Breakout
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Multiplex M-Link support for OpenXVario

Post by mstrens »

I did not saw this shield.
It could probably be used but price is higher than a gy-63 on ebay.
So, I think it is still better to use gy-63.
User avatar
Klausi
Posts: 6
Joined: Sun Jan 25, 2015 7:51 am
Country: Germany
Location: Achim
Contact:

Re: Multiplex M-Link support for OpenXVario

Post by Klausi »

Hi mstrens,

thank you for your feedback.
You are right. My version of the BMP180 implementation is not optimized.
The library for the measurements is from adafruit and they made the waiting delays.

I agree that it is better to have much data for building average values but for me it was suitable to use the library "as is".
I think that this feature is not correctly implemented when the BMP180 are used.
This feature was not in my focus. So it is possible that this feature is not supported in my code.

If you are interestet in a clean implementation of the BMP180 I need much time to understand your code and rewrite code that satisfies your requirements.

Kalle, I subscribed this thread and will get an email on changes.

Klaus
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Multiplex M-Link support for OpenXVario

Post by mstrens »

@Klausi,

If you think it could be useful, I could write the code for oXs in order to support the BMP180.
Up to know, it was not done because I expect that the precision would be less than with a MS5611 sensor.
Just let me know if you want that a I write it. I would then need your help to test it.

I also noticed that your version calculates vertical speed based on the difference between 2 altitudes and does not applies some filtering on the result. I expect that vertical speed will be quite "noisy". If you want to keep your version and still increase vertical speed accuracy, I recommend to apply a smoothing formula.

Michel
User avatar
Klausi
Posts: 6
Joined: Sun Jan 25, 2015 7:51 am
Country: Germany
Location: Achim
Contact:

Re: Multiplex M-Link support for OpenXVario

Post by Klausi »

@Michel,

I think it is much better if you write the code for the BMP180 because you know the oXs-code much better than me.
Thank you for your efforts.

My second sensor (vario & voltage) is reserved for testing your code.
oXs_04.jpg
mstrens wrote: I recommend to apply a smoothing formula.
It is a good idea to apply a smoothing formula.

Klaus
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Multiplex M-Link support for OpenXVario

Post by mstrens »

@Klausi,

I tried today to write the code for the BMP180 sensor (see attachment).
I could not test it because I have no BMP180 sensor.

If you want, you could test it and give me feed back.
BMP180 sensor is activated using line "#define SENSOR_IS_BMP180" in config.h file.

This version does not allow to use 2 BMP180 sensors because the sensor has only 1 I2C address (on the opposite to the MS5611 which has 2).

This version still allow to use a BMP180 as first vario and a MS5611 as second vario. If you use 2 sensors on one oXs, you could easily compare the precision of each sensor.
Attachments
openXsensor_for bmp180.rar
(113.68 KiB) Downloaded 220 times
User avatar
kalle123
Posts: 905
Joined: Sat Mar 29, 2014 10:59 am
Country: -
Location: Moenchengladbach

Re: Multiplex M-Link support for OpenXVario

Post by kalle123 »

I'll give it a try and report ...

If I understand the discussion right, there is potential in BMP180 and it is always good to have a second source for sensors. And the upcoming BMP280 seems to have same accuracy as the MS5611 ...

br KH
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Multiplex M-Link support for OpenXVario

Post by jhsa »

is it cheaper?

joão
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
kalle123
Posts: 905
Joined: Sat Mar 29, 2014 10:59 am
Country: -
Location: Moenchengladbach

Re: Multiplex M-Link support for OpenXVario

Post by kalle123 »

jhsa wrote:is it cheaper?

joão
Ordered two BMP180 sensors on ebay for 1,50 € each. ;)

KH

Post Reply

Return to “OpenXVario - an open source vario supported by the open source firmwares!!”