In car multigauge

What are you developing?
Post Reply
User avatar
BennehBoy
Posts: 420
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

In car multigauge

Post by BennehBoy » Sun Jan 29, 2017 9:34 am

Thought I'd open up a project thread so I can share my ramblings and idiocy.

I'm an IT bod with over 20 years experience in various industries, I'm an average coder who has mainly been cutting scripts and not touching any low level languages. I've not touched electronics or C (never mind c++) since Uni, so I'm having to rapidly assimilate a lot of information - fortunately I still remember most of the grounding I learned.

I'm building a system that can read automotive analogue sensors and display the output on OLED screens.

It's using OLED screens because they are easy to read in bright light, darkness, and when not directly facing them.

This started life as a set of gauges for my Land Rover which I take off road, but it's just as applicable to any vehicle

So far I've included code for:
* Bosch temperature sensors NTC M12 0 280 130 026 (coolant, oil, gearbox temp)
* Generic 4 bar pressure sensors (boost pressure)
* Simple normally closed alarm switches (coolant level etc)
* K-Type thermocouple - using a MAX31856 IC (Exhaust gas temp)
* Generic oil/air pressure sensors (0-100psi, suitable for oil pressure)
* Roll and Pitch (using ADXL345 accelerometer)
* Compass heading (using HMC5883)

I'm looking to bundle OBD2 data into the mix by means of a chinese ELM327 dongle (it has an HC06 bluetooth module in the box), coupled with an HC05. There's a fairly sizable amount of pre-written code available for Arduino to grab the data via that pairing, given that the hc05 is uart driven I figure it ought to work on STM32. Fingers crossed.

I need to expand user interaction so that warning values can be configured, and so that the ordering of the sensors can be set. This is probably going to mean I need some form of storage, be that eeprom, eeprom emulation, or an SD card. SD card would be the preference because then I can include a data logging option).

Life started on an Arduino Nano clone, but this was rapidly outgrown from a GPIO, flash, & sram perspective. Not wanting the footprint of an Arduino Mega I looked about and found this forum.

Originally I had an off the shelf system in the car, it was quite expensive, and not easily read (LCD screen) - I contacted the vendor to see about changing the display for an OLED and he wanted £250. After opening the box and finding an Arduino in it, I decided I could make my own for quite a lot less money.

Pic of the original:
Image

Pic of my original Nano driven replacement just prior to install - it's a bit Heath Robinson:
Image

Nano system in the car (prior to sensors being wired in)
Image

Data capture has proved pretty simple, most time has been spent on how to get the data to the user.

Video of the STM32 system with inclinometer
[youtube]https://www.youtube.com/watch?v=KDIy4PNw3LQ[/youtube]

Project github here -> https://github.com/BennehBoy/LRDuino
-------------------------------------
https://github.com/BennehBoy

User avatar
BennehBoy
Posts: 420
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: In car multigauge

Post by BennehBoy » Sun Jan 29, 2017 12:55 pm

So I spent an entire day getting an HMC5883L hacked into the project.

I used this repo as the base code since I like the gfx work done -> https://github.com/G6EJD/ESP8266_micro_ ... C5883_OLED

Spent a lot of time refactoring my code, not directly related to this device, but to allow for multiple graph styles and pairing sensors together for display purposes.

Only to realise that these devices are probably garbage for the intended applications:

* they require the device to be parallel to the ground for the reading to not be influenced byt eh Z axis - not going to happen in a vehicle.
* they are strongly influenced by nearby ferrous material - kind of hard to get away from this in a vehicle.

I've seen sniffs of code out there where input from an accelerometer can be used to factor in Z axis changes - but I need to find some code, and this will also be affected by vehicle acceleration.

So, it looks pretty, and I got some overall system improvements from the refactor.

Image

But.. best to avoid.
-------------------------------------
https://github.com/BennehBoy

User avatar
RogerClark
Posts: 7422
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: In car multigauge

Post by RogerClark » Sun Jan 29, 2017 7:46 pm

For what its worth, I looked at using the magnetometer in the Intellisense MPU9150, and I think it has the same sort of issues

I'm not sure about the ferros metal issue, but I had to calibrate by rotating the device through 360 deg in all 3 axis multiple times, and making sure I had data for all quadrants.

I ended up using code called RT IMU, on github, but I think he stopped supporting Arduino some time ago, and moved to RPi,

https://github.com/RTIMULib/RTIMULib-Arduino

But if you are keen to investigate motion sensing and magnetometers etc, its probably one of the best code libraries, albeit quite complicated

User avatar
BennehBoy
Posts: 420
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: In car multigauge

Post by BennehBoy » Sun Jan 29, 2017 9:51 pm

Thanks Roger I'll have a look at that.
-------------------------------------
https://github.com/BennehBoy

User avatar
BennehBoy
Posts: 420
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: In car multigauge

Post by BennehBoy » Sun Jan 29, 2017 10:00 pm

Looks like it might be good...

Some useful info on using quaternions to correct for roll/pitch of the horizontal plane, bottom section of this -> https://github.com/RTIMULib/IMUStuff
-------------------------------------
https://github.com/BennehBoy

User avatar
RogerClark
Posts: 7422
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: In car multigauge

Post by RogerClark » Mon Jan 30, 2017 6:06 am

Yes.

The code does a lot of clever stuff ;-)

I used it for a while to try to do indoor navigation based on one of the 9 axis sensors, but found there was too much integration error to make it usable.

But I'm sure some of the features in the code could be useful if you had a 9 axis sensor, as you'd get tilt in 3D as well as compass etc, as well as acceleration and rotation speeds etc.

If you do offroad, it could be interesting to record things, and play them back later.

User avatar
Squonk42
Posts: 184
Joined: Thu Dec 29, 2016 9:25 am
Location: Bordeaux, France

Re: In car multigauge

Post by Squonk42 » Mon Jan 30, 2017 7:30 am

I explored the subject of IMUs not a long time ago, and here are the results (beware, lot of links below, but very useful!).

Yes, RTIMULib is no longer maintained on the Arduino.

I recommend using Sparkfun's MPU9250 Arduino library from Github instead:
https://github.com/sparkfun/SparkFun_MP ... no_Library

It is a derivative of Kris Winer's library here:
https://github.com/kriswiner/MPU-9250

Very good information from its Wiki:
https://github.com/kriswiner/MPU-6050/wiki

... But it is itself a derivative from original Sebastian Madgwick's algorithm:
http://x-io.co.uk/open-source-imu-and-ahrs-algorithms/

Please note that unlike Kris Winer's implementation this one uses an optimized Fast inverse square root:
https://en.wikipedia.org/wiki/Fast_inverse_square_root

... But Sebastian Madgwick's algorithm is itself based on Robert Mahony's algorithm:
https://hal-univ-tlse3.archives-ouverte ... 6/document

The main idea behind Mahony's algorithm is to use complementary filters (high/low pass) on each sensor based on its capabilities and Madgwick's idea brings in the fusion of sensor data together using a spherical gradient (think it as interpolation on a sphere), rather than the using full Extended Kalman filters used by RTIMULib, which are computationally more expensive:
http://www.unitedthc.com/DSP/Kalman1960.pdf
http://www.pages.drexel.edu/~hgk22/cour ... cy1961.pdf

Here are also some good resources on magnetometer calibration using a 3D ellipsoid approximation, much better than standard xmin/xmax/ymin/umax methods used everywhere:
https://edwardmallon.wordpress.com/2015 ... r-arduino/
http://sailboatinstruments.blogspot.fr/ ... -part.html
https://sites.google.com/site/sailboatinstruments1/home
http://forum.arduino.cc/index.php?topic=265541.0

User avatar
BennehBoy
Posts: 420
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: In car multigauge

Post by BennehBoy » Mon Jan 30, 2017 8:11 am

RogerClark wrote:Yes.
If you do offroad, it could be interesting to record things, and play them back later.
I really like the idea of this, couple with GPS data it would be even more interesting...

Hmmm, sub project methinks.
-------------------------------------
https://github.com/BennehBoy

User avatar
BennehBoy
Posts: 420
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: In car multigauge

Post by BennehBoy » Mon Jan 30, 2017 8:13 am

Squonk42 wrote:I explored the subject of IMUs not a long time ago, and here are the results (beware, lot of links below, but very useful!).
Thanks Squonk42, that's such a comprehensive post!

Looks like I have some reading to do :D
-------------------------------------
https://github.com/BennehBoy

User avatar
BennehBoy
Posts: 420
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: In car multigauge

Post by BennehBoy » Mon Jan 30, 2017 9:17 am

9250 ordered :D
-------------------------------------
https://github.com/BennehBoy

Post Reply