Building TWI(I2C)-sensors for openXsensor with ADS1115

Development & General Chat for the superb openxvario project.

Moderator: rainer

Post Reply
User avatar
Tempo
Posts: 70
Joined: Tue Feb 04, 2014 4:04 pm
Country: -

Building TWI(I2C)-sensors for openXsensor with ADS1115

Post by Tempo » Sun Oct 25, 2015 10:29 pm

You have several options to connect sensors on SmartPort:
1. use one openXsensor with one microcontroller and some sensors
2. use up to 28 openXsensor-microcontrollers with different SENSOR_ID viewtopic.php?f=86&t=7729
3. use one openXsensor with one microcontroller and up to 128 TWI-sensors

I will implement 3. option:
My motivation was to use several sensors in DLG-glider with sparce space.
Therefore i build sensors with little dimensions which you can use for longer distances from microcontroller.
I use original ADS1115 from manufacturer Texas Instruments http://www.ti.com/product/ads1115 on small selfmade breakoutboard,
which gives 16Bit-analog to digital conversion (arduino Atmega328 has only 10 Bit) and has a programmable gain amplifyer !
TWIsensor_Tempo.JPG
You get ADS1115-breakoutboards cheaply e.g. on ebay.

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

Re: Building TWI(I2C)-sensors for openXsensor with ADS1115

Post by mstrens » Mon Oct 26, 2015 9:17 am

Indeed , all solutions should work.
Just 3 commenst:
- I do not know what is the max length of the wiring on I2C bus. I am afraid that if it becomes too long, there could be errors on the bus. Perhaps good to test.
- current sensor is ratiometric. In order to get good accuracy, it is important providing a good (stable) Vcc
-in order to reduce noise, it would probably be good to add capacitors between the reduced voltages and ground (best near the ADS1115)

User avatar
Tempo
Posts: 70
Joined: Tue Feb 04, 2014 4:04 pm
Country: -

Re: Building TWI(I2C)-sensors for openXsensor with ADS1115

Post by Tempo » Mon Oct 26, 2015 11:11 am

mstrens wrote:Indeed , all solutions should work.
Just 3 commenst:
- I do not know what is the max length of the wiring on I2C bus. I am afraid that if it becomes too long, there could be errors on the bus. Perhaps good to test. Length about 1 to 2 meter are working good.
- current sensor is ratiometric. In order to get good accuracy, it is important providing a good (stable) Vcc
It will work also with no stable VCC of e.g. 4xNiMH in range of 4.5V to 5.5V. Ratiometric analog output of currentsensor is a benefit, because sensitivity in millivolt per ampere is proportional to VCC. Additional measurement of VCC with accurate ADS1115 makes it possible to calculate accurate current value.
-in order to reduce noise, it would probably be good to add capacitors between the reduced voltages and ground (best near the ADS1115)
Yes. And there another benefit of concept "ADC-input nearest to analog output": wires are very short. Sending digital signals with long wires to microcontroller with TWI is better solution.
mstrens, cooperating with you makes great fun and is effective. 8-)
Therefore I will test hardware and supply softwaremodules for ADS1115, which i would like to implement in oXs-software.

User avatar
Tempo
Posts: 70
Joined: Tue Feb 04, 2014 4:04 pm
Country: -

Re: Building TWI(I2C)-sensors for openXsensor with ADS1115

Post by Tempo » Mon Oct 26, 2015 6:07 pm

Have a look how to modify cheap chinese ACS712-module and add ADS1115, which is a 16-Bit-ADC with Two-Wire-Interface (I2C):
oXs_TWIcurrent_Tempo.JPG
oXs_TWIcurrent_Tempo
What´s going on ?

First ADS1115 gives 16-bit-value for (VIOUT-VCC/2) on differential input AIN0+ and AIN1-.
Using differential value enables to use 16-Bit analog to digital converting on fullscale with integrated programmable gain amplifier.

Second ADS1115 gives VCC/2 to calculate sensitivity of ratiometric ACS712. Sensitivity in mV per Ampere is proportional to VCC.

Third oXs-microcontroller calculates value of current independent of VCC.

User avatar
Tempo
Posts: 70
Joined: Tue Feb 04, 2014 4:04 pm
Country: -

Re: Building TWI(I2C)-sensors for openXsensor with ADS1115

Post by Tempo » Mon Oct 26, 2015 6:10 pm

Hardware is finished. Let´s play ;) !
oXs_TWIsensors_Tempo.JPG
oXs_TWIsensors_Tempo


User avatar
Tempo
Posts: 70
Joined: Tue Feb 04, 2014 4:04 pm
Country: -

Re: Building TWI(I2C)-sensors for openXsensor with ADS1115

Post by Tempo » Tue Oct 27, 2015 7:24 pm

If you use device ASC712ELTR-05B-T with Atmega328 on oXS-arduino-board you have current-resolution of 26.4mA/step and current-value and sensitivity depends on VCC, because ACS712 is a ratiometric sensor.
For measurements of currents down to mA it´s inadequate, e.g. current consumption of servos in flying small DLG-gliders.

For that I fabricated a very accurate current sensor in combination of hall-sensor ACS712 and ADS1115 for current range +-5 Ampere.
Current-resolution is better than 1mA/step and absolute current-value is independent of VCC.
In addition you have the ability to measure voltages with resolution of +-1mV.
Hardware and software works fine, how a copy of serial monitor shows:


+-5A current sensor ACS712 with ADS1115 :

Config Register current 11010000011 measured current : -121 mA -717
Config Register VCC/2 101001010000011 measured VCC/2 : 2502 mV 20021
result of truecurrent = 3378.3784 * (_CURRENT5Araw / _HALFVCCraw) : -120 mA

Config Register current 11010000011 measured current : 9 mA 57
Config Register VCC/2 101001010000011 measured VCC/2 : 2502 mV 20018
result of truecurrent = 3378.3784 * (_CURRENT5Araw / _HALFVCCraw) : 9 mA

Config Register current 11010000011 measured current : -3175 mA -18803
Config Register VCC/2 101001010000011 measured VCC/2 : 2503 mV 20027
result of truecurrent = 3378.3784 * (_CURRENT5Araw / _HALFVCCraw) : -3171 mA

Config Register current 11010000011 measured current : 5534 mA 32767
Config Register VCC/2 101001010000011 measured VCC/2 : 2503 mV 20024
result of truecurrent = 3378.3784 * (_CURRENT5Araw / _HALFVCCraw) : 5528 mA

Config Register current 11010000011 measured current : 5534 mA 32767
Config Register VCC/2 101001010000011 measured VCC/2 : 2502 mV 20016
result of truecurrent = 3378.3784 * (_CURRENT5Araw / _HALFVCCraw) : 5530 mA

frater
Posts: 77
Joined: Sat Aug 30, 2014 11:04 pm
Country: -

Re: Building TWI(I2C)-sensors for openXsensor with ADS1115

Post by frater » Thu Mar 24, 2016 6:11 am

I just ordered 4 of these ADS1115
I still have to build my 1st openXsensor, but want to have all parts before I heat up the soldering iron.
I bought those ACS712 a few months ago, but never did anything with it because I didn't expect to get any decent info out of it (wanted to use the analog input). This approach seems much more solid.
I think I'm going to combine it with a barometer/compass/imu/gps

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

Re: Building TWI(I2C)-sensors for openXsensor with ADS1115

Post by kalle123 » Thu Mar 24, 2016 9:09 am

frater wrote:I just ordered 4 of these ADS1115
I still have to build my 1st openXsensor, but want to have all parts before I heat up the soldering iron.
Take a breadboard for starting. Soldering the parts together can wait.
frater wrote:I just ordered 4 of these ADS1115
II bought those ACS712 a few months ago, but never did anything with it because I didn't expect to get any decent info out of it (wanted to use the analog input).
Do some test with those ACS712s and get yourself some experience. Not getting decent info is pure speculation ....
frater wrote:I just ordered 4 of these ADS1115
I still have to build my 1st openXsensor ... I think I'm going to combine it with a barometer/compass/imu/gps
Get on with it and then come back ;)

Baro supported MS5611 and BMP180
Compass ??? and what for ???
IMU GY-86
GPS -> UBLOX GPS

br KH

frater
Posts: 77
Joined: Sat Aug 30, 2014 11:04 pm
Country: -

Re: Building TWI(I2C)-sensors for openXsensor with ADS1115

Post by frater » Tue Apr 05, 2016 10:39 am

Based on your ideas I'm now planning to use a 100A unidirectional current sensor together with 2 ADS1115's and modify an ESC (no extra connectors).
I already have the 5V there from the ESC (but maybe I use the one coming from the openXsensor which gets it from the SPORT-connector)

I could make my own "standard" for the 4-pin wiring that comes of it. Or is there already some kind of standard for i2c for these purposes?
I already have a lot of micro 1.25mm JST-connectors and was thinking of using these.

This would give me both current and pack voltage.
I'm correct in thinking that I can just patch these 2 i2c-signals together?

Keep in mind that I still need to make my first openXsensor and barely know what I'm doing with regard to Arduino's.
I learn best when I have something working and can work from there...

I already assembled a GPS-openXsensor, but it's not finished yet.
Is it enough to just add a JST-connector to those 2 pins (SDA & SCL) and lead that to the current sensor?

Is there some standard using these i2c addresses....
While writing this... Is the number in GY-85, GY-86 and so on its i2c address???
If not... is there a standard or some consensus...

Carbo
Posts: 336
Joined: Fri Aug 02, 2013 6:55 pm
Country: Germany
Location: Freinsheim RP

Re: Building TWI(I2C)-sensors for openXsensor with ADS1115

Post by Carbo » Tue Apr 05, 2016 11:15 am

frater wrote:Keep in mind that I still need to make my first openXsensor and barely know what I'm doing with regard to Arduino's.
I learn best when I have something working and can work from there...
So why not start connecting the current sensor to an analog input of the Arduino, you will get a 0.1 A resolution. Everything in oXs is ready to use it this way. Using ADS1115 requires a lot of work in the code. From there you can develop further, if necessary. On the other side i know, that mstrens started to work with ADS1115 routines. If you need 16 bit resolution..........

frater
Posts: 77
Joined: Sat Aug 30, 2014 11:04 pm
Country: -

Re: Building TWI(I2C)-sensors for openXsensor with ADS1115

Post by frater » Tue Apr 05, 2016 1:53 pm

Carbo wrote: So why not start connecting the current sensor to an analog input of the Arduino, you will get a 0.1 A resolution. Everything in oXs is ready to use it this way.
You are right... I will probably do it that way.
I might as well just use such an Orange sensor which has this analog out.
It only needs a connector on my openXsensor and I can conform to their wiring.

The resolution is enough. I'm only a bit worried about its precision.

BTW.... I'm still interested in answers to my other questions

frater
Posts: 77
Joined: Sat Aug 30, 2014 11:04 pm
Country: -

Re: Building TWI(I2C)-sensors for openXsensor with ADS1115

Post by frater » Sun Apr 24, 2016 6:18 am

I would like to start implementing your idea of using the i2c-bus externally.
On the openXsensor I want to put a mini JST connector so I have some standardization.

Shouldn't I also add a 3.3V voltage regulator on the openXsensor to feed these i2c-sensors?


I was thinking about using a 1mm 4pin JST-connector and following the pinout of the UARTS on flight controllers...

Or should I use 3.3V to supply the whole Arduino mini to avoid getting into problems with the signal levels?

I wanted to start with modifying an ESC so it will give me the current and the pack voltage.
In that case I could use the onboard BEC.

But isn't it better anyhow to run the openXsensor on stabilized 3.3V for interfacing with different sensors?

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

Re: Building TWI(I2C)-sensors for openXsensor with ADS1115

Post by mstrens » Mon Apr 25, 2016 8:11 am

If you plan to add several sensors (e.g. GPS, IMU6050, MS5611,...) to the same oXS device, it is better to use a 5V pro mini instead of a 3.3 v because it will run faster (at 16 Mhz instead of 8 Mhz) and so can perform more calculations per second.

If you use standard modules (cheap and easily available on ebay) most of them have their own 3.3 V voltage regulator and I2C level converter.
So it is not an issue running Arduino at 5 volt.
If you use an arduino 5 volt and want to connect it to a single lipo cell, I think it will just work fine because it can run at 16 mhz with a voltage as low as 3.8 volt (and probably even lower even if out of the specifications from the datasheet).

frater
Posts: 77
Joined: Sat Aug 30, 2014 11:04 pm
Country: -

Re: Building TWI(I2C)-sensors for openXsensor with ADS1115

Post by frater » Mon Apr 25, 2016 8:41 am

Yes...

I've heard about the 16 MHz versions having no problems with lower voltage

But what about the signal levels?
I assume I need run the i2c levels on the same voltage as the Arduino does.

When I was young I stopped electronics because it became more and more digital... I'm now doing catch-up.

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

Re: Building TWI(I2C)-sensors for openXsensor with ADS1115

Post by mstrens » Mon Apr 25, 2016 12:00 pm

Some sensors does not accept more than 3.3 volt but modules like GY63 (baro sensor MS5611) and GY86 (baro sensor MS5611 + IMU6050) have their own voltage regulator and I2C level converters added on the PCB.
It means that it is then safe to connect them directly to an Arduino running at 5 volt.
The level converters will take care that the voltage levels on I2C pin from e.g. MS5611 does not exceed 3.3 volt even if the I2C pin on arduino side is 5 volt.

User avatar
rainer
Posts: 391
Joined: Tue Jan 01, 2013 9:20 pm
Country: Germany
Location: near Düsseldorf

Re: Building TWI(I2C)-sensors for openXsensor with ADS1115

Post by rainer » Fri Sep 02, 2016 5:28 pm

I like the idea of building it modular as well. i did something similar for one of my oXs builds some time ago. Ii chose to make the current sensor exchangable. So i added a small 4pin mini JST connector to the oXs. This offers the possibility to measure the current and the battery voltage.
oXsModular.JPG
Worked quite nice. And i had the possibility to re-use the oXs in various models each with a matching curent sensor installed..
build your own vario ==> https://github.com/openXsensor/openXsensor/wiki (Formerly https://code.google.com/p/openxsensor/ and https://code.google.com/p/openxvario/)

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

Re: Building TWI(I2C)-sensors for openXsensor with ADS1115

Post by kalle123 » Fri Sep 02, 2016 6:25 pm

Did that with the additional GPS to oXs vario.
Like the modular idea also ...

Post Reply

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