Jump to content


Photo
- - - - -

Tdm-Duino (Midnight Project)


  • Please log in to reply
99 replies to this topic

#1 JBX

JBX

    full o shoite

  • RTT manager(RTT)
  • 2,206 posts
  • Location:South France
  • TDM model: 2002

Posted 24 April 2017 - 10:24 pm

TDM-Duino project is on its way !

It all started as an Arduino project to replace the gear position display on my bike.
I also wanted to display some more data as the original Diag Mode will not work when the engine is running.
I also wanted some fuel consumption data and a trip computer.
Finally why not include a performance monitor ?

This project uses an Arduino (Uno for testing, Nano on the final setup as it has less power consumption and a much lower footprint), an LCD 16x2 display and some extra electronics for input/output/power.
There are no extra modules like rtc or sd card reader. All timing and memory is done with the Arduino.

The coding :
The first thing I did was the gear position display : it uses some custom characters on the LCD screen to display big digit as an 8 segment display, using two lines.
Then I added some extra screens to display more info and give it a more onboard computer look to display fuel consumption, trip info, performance data and disgnostic data (the Diag Mode on the bike does not work when the engine is running.

The project uses the original bike sensors.
The gear sensor uses a resistor scale to give an analog value which is read on an analog input. It could as well use a diode matrix and be read on three digital inputs, just a matter of choice.
The fuel sensor should give me some headache : I'm pretty sure it don't have a great accuracy, I still have to check it and make calibration.
Other sensors are not too difficult to read : the pressure sensors are standard models, datasheet is available. The temperature sensors needed some more important internet research to gather usable infos.
The TPS is just a potentiometer

 

arduino_ini.jpg


So far there are five different screens showing all the available infos. The gear position is always displayed.

Power-on screen

arduino_000.jpg

Screen 1 : Main
- Engine rpm
- Engine coolant temperature
- Speed
- Battery voltage

arduino_001.jpg

Screen 2 : Fuel Consumption
- Instant Fuel Consumption
- Fuel remain
- Average Fuel Consumption
- Expected mileage (up to 999km)

arduino_002.jpg

Screen 3 : Trip data
- Trip distance (up tu 9999km - xx.x bellow 99km, xxxx above)
- Trip time     (up to 99h59m - mm:ss bellow 1hour, hhHmm above)
- Average speed
- Max speed

arduino_003.jpg

Screen 4 : Diag mode
- TPS : throttle position sensor
- MAP : manifold air pressure
- IAT : intake air temperature
- BAP : barometric air pressure

arduino_004.jpg

Screen 5 : Performance
- Time : 0-100kph
- Time : 0-160kph
- Time : 0-400m
- Time : 0-1km

arduino_005.jpg

Two push buttons are used mainly to navigate between the screens but they also have a different usage on a long push :
- button 0 : screen up (short push) / lcd backlight on/off toggle (long push)
- button 1 : screen down (short push) / current screen data reset (long push)

Digital in/out :
- injector signal on int0, gives rpm data and injection timing / fuel consumption.
- speed sensor on int1, gives speed & distance data.
- button 0 input
- button 1 input
- power-off sense
- analog inputs select
The speed calculation constants may be changed according to the final gear ratio.
All displays are metric and fuel consumption given in L/100km but they are easy to change to imperial.

Analog inputs :
- Gearbox Position Sensor
- Fuel Level Sensor
- Manifold Air Pressure
- Barometric Air Pressure
- Engine Coolant Temperature / Intake Air Temperature
- Battery Voltage Sensor / Throttle Position Sensor
I use a four wires LCD display so only 6 of the 8 analog inputs are usable.
4 inputs go directly to the ATmega and 2+2 are selected by a CD4093.
All input are bufferized except the gear position sensor and the fuel level sensor.

Some data need to be stored permanently (fuel & trip data), even when the power is off.
This may be done live by using an external memory (SD card module), not really useable (big memory usage, too much transfert time), or by using the ATmega built-in eeprom but in this case it shouldn't be during working due to the limited write cycle on the ATmega eeprom but also due to the time it takes to white data into the eeprom. I finally decided to use the ATmega eeprom solution and use a power-off code and electronics which allow enough time at power-off to store all the data in eeprom. All data stored is of course recovered at power-on.

Several options may be added :
- unlock the bike (using a relay on the alarm connector) with long push (10s) on one of the buttons or with another (hidden) button or a reed switch.
- automatic headlight on when engine is running & bike moves.
- radiator fan on/off at different temperatures.
- shift light.
- ambiant air temperature with ice alarm.

This is a long project, Arduino coding is almost finished and seems to work ok on the workbench using some simulation data.
Fuel level sensor needs calibrating. This shouldn't be easy as I suspect the sensor to be very imprecise.
There is also the final casing and the lcd display location, and also the buttons location - should go on the lhs handle.

 

Project will probably change while I proceed on some sensors experiments !

Any appreciations / suggestions / cakes are welcome.

 


top_640.png

 

 


#2 fixitsan

fixitsan

    Carpe Citizen

  • Supporting Member(thanks)
  • PipPipPipPipPipPipPipPip
  • 4,668 posts
  • Location:West Lothian
  • TDM model: 2003

Posted 25 April 2017 - 07:31 am

Neat tinkering :)

You could add an automatic brakelight, which might help due to the strength of engine braking !

 

I wish we could get speed from the serial data bus to the instruments but I cannot fathom the encryption...I can get the rpm and a temperature, but the speed signal is encoded in some unusual way.

 

Did you code your own font for the gear display ? I've had fun with that in the past (and a few headaches too !)


900 with better bits. Owes me nothing, Makes me smile


#3 TDM4ever

TDM4ever

    Carpe Addict

  • Member
  • PipPipPip
  • 302 posts
  • Location:The Funny Farm..
  • TDM model: 2010

Posted 25 April 2017 - 07:39 am

Interesting.

 

Always nice to see some pioneering  :good:



#4 JBX

JBX

    full o shoite

  • RTT manager(RTT)
  • 2,206 posts
  • Location:South France
  • TDM model: 2002

Posted 25 April 2017 - 01:22 pm

Engine braking light is a good point, thanx for the suggestion.

 

Well I'm new to Arduino, this is my second project - the first one was adding a Yamaha coding remote receiver inside a CD player from another brand.

 

I first wanted too to extract data from the serial K-line but there was some major issues : not much information is available except some experiments here or there, and mainly the fact that the line does not provide data about the injection timing - this is the same problem with the obd2 and the instant fuel consumption is not calculated very accurately with it but with many other parameters. Finally getting data straight from the sensors was an easier task.

 

About the big font, I first found some samples on the net but they were not to my taste - 3 chars wide - so I coded those.

byte seg0[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x1f};
byte seg1[8] = {0x1f, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x1f};
byte seg2[8] = {0x1f, 0x1f, 0x03, 0x03, 0x03, 0x03, 0x1f, 0x1f};
byte seg3[8] = {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x1f};
byte seg4[8] = {0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x1f, 0x1f};
byte seg5[8] = {0x1f, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x1f};
byte seg6[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x1f};
byte seg7[8] = {0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03};

Where seg0 allows to display a small "0".

 

As there is room inside the lcd display controler only for height custom chars, there is no way to display digits 0 to 9, only 1 to 6 - which is enough for the gear display.

This also means you can not have gear display and something like an analog data display - a scale, vertical or horizontal - at the same time.

You could change the custom char set on the fly but it takes much more time on an i2c line.


top_640.png

 

 


#5 fixitsan

fixitsan

    Carpe Citizen

  • Supporting Member(thanks)
  • PipPipPipPipPipPipPipPip
  • 4,668 posts
  • Location:West Lothian
  • TDM model: 2003

Posted 25 April 2017 - 01:42 pm

Writing on the fly was my next suggestion - in 8bit parallel mode it works great but yes, i2c holds you back for animations.....not that I ever tried it, 500kHz ? In theory it should work but..... never tried it

The K-Line test i have ddoe allowed me to get within 10mph of true velocity. but I don't know anyone who managed to read it accurately but there was a suggestion that the timing of the data was changing and it was the timing which was the encrypted value.....I gave up because I enjoy life too much !

Edited by fixitsan, 25 April 2017 - 02:03 pm.

900 with better bits. Owes me nothing, Makes me smile


#6 gswede

gswede

    discovering Carpe

  • Member
  • 19 posts
  • Location:Stockholm Sweden
  • TDM model: 2010

Posted 25 April 2017 - 01:52 pm

As you read the temperature you could also give a different value to the ECU and thus simulate a Boosterplug.



#7 dmmsta

dmmsta

    supporter of the "Anti-Dazzle" Club

  • Supporting Member(thanks)
  • PipPipPipPipPipPipPipPip
  • 3,627 posts
  • Location:Marden, Kent, UK.
  • TDM model: 2006

Posted 25 April 2017 - 06:40 pm

I like this a lot!!!

My coding is about as good as my ability to give birth to humans, but I love to see what people can do with it!

 

I'm very interested in the RPM element.  My dash unit had a fit a while back and I now have no RPM or temp dials working, but all other functions (LCD, lights etc) are fine.

 

Would be interested to know if there is a simple solution to getting an adhoc plug in RPM meter??


MY06 TDM 900 Blue over Silver 354906_45.png
-----
Fuel Pipes
Givi Top Box
Renthal 758's
Grip Puppies
MRA Bubble
Dip & Hi HIDs

To-Do:
LED DRLs
Loobman
Powercoat Wheels
Hand Guards

-----
MY04 TDM 900 Blue over Silver Parts Bin
MY02 TDM 900 Yellow over Black RIP
post-1-1150550733.gif...post-1-1150559830.gif...copilot_zpsgezqc0xz.jpg...hids.jpg...

#8 JBX

JBX

    full o shoite

  • RTT manager(RTT)
  • 2,206 posts
  • Location:South France
  • TDM model: 2002

Posted 25 April 2017 - 10:13 pm

I made a first test using the classic 4 bits interface with another lcd, it's much much faster than the I2C but it uses 6 GPIO, while the I2C only uses 2 pins, unfortunately it uses SDA & SCL which take two analog input away !

With this project the display refresh rate varies with the screen number & the data : gear position has a 100ms refresh rate - same as button reading (this way no need to worry about button rebound) - main, fuel & trip screens only require a 500ms refresh rate but diag & performance screen require 100ms to give proper display data. At these refresh speeds, a fast lcd interface does not seem to be a big deal, but it may well change in the future.

The display refresh rate is one thing, availability of the data is another thing : speed & rpm (+injection timing) are both read using interrupts so they give a much higher data rate.

 

gswede : there is no communication between the Arduino and the ECU, so there is no mean to "lower" the value of the IAT. One thing you should know is that while the IAT gives higher temperature figure when the throttle has a reduced opening, it lowers immediately when you open the throttle, giving the "right" value. This has also the advantage to lower the fuel consumption at low charge as it gives the engine a leaner mixture.

That said, any device that claim to "release the power" of a bike has much chances to be a scam.

 

dmmsta : this project is not very difficult to achieve and it is not very expensive, but as usual with embedded electronics, you must be vary careful with the mechanical part of it : casing, connectors, power, etc.

You may as well display only two analog scales : rpm and engine coolant temperature - and maybe the gear position (with the issue about the custom chars).


Edited by JBX, 25 April 2017 - 10:14 pm.

top_640.png

 

 


#9 Interceptor

Interceptor

    arrived on last train

  • Member
  • 9 posts
  • TDM model: 2009

Posted 25 April 2017 - 10:18 pm

This stuff is over my head but is very impressive, fair play



#10 gswede

gswede

    discovering Carpe

  • Member
  • 19 posts
  • Location:Stockholm Sweden
  • TDM model: 2010

Posted 28 April 2017 - 04:55 pm

Hi JBX
This is my idea how you could change the temperature the ECU reads.
As I understand it you read the temperature sensor directly and if
you have four digital outputs it is possible to supply a small current
in parallel to the sensor resulting in a voltage increase and
the ECU will then think the weather is getting colder.
See the picture.
The program flow would be something like this:
1. Read the sensor voltage when all digital outputs are off.
   This is done when bike starts and at regular intervals.
2. The voltage is converted to temperature.
3. The first least significant digital output is activated and
   the voltage is read and converted to temperature.
4. If the new temperature now is what we wanted then stop, otherwise
   activate the next output and test again and so on until the desired
   temperature is reached.

Attached File  tdm2.jpg   68.62KB   0 downloads



#11 fixitsan

fixitsan

    Carpe Citizen

  • Supporting Member(thanks)
  • PipPipPipPipPipPipPipPip
  • 4,668 posts
  • Location:West Lothian
  • TDM model: 2003

Posted 28 April 2017 - 08:52 pm

Hi JBX
This is my idea how you could change the temperature the ECU reads.
As I understand it you read the temperature sensor directly and if
you have four digital outputs it is possible to supply a small current
in parallel to the sensor resulting in a voltage increase and
the ECU will then think the weather is getting colder.
See the picture.
The program flow would be something like this:
1. Read the sensor voltage when all digital outputs are off.
   This is done when bike starts and at regular intervals.
2. The voltage is converted to temperature.
3. The first least significant digital output is activated and
   the voltage is read and converted to temperature.
4. If the new temperature now is what we wanted then stop, otherwise
   activate the next output and test again and so on until the desired
   temperature is reached.

attachicon.giftdm2.jpg

 

 

I like the idea, but the thermistor has a current across it provided by the ECU, either from a voltage divider or a  current source (not sure which, I haven't ever opened one up). I suppose it is worth a try, but there is the possibility of unwanted interaction between the two systems.

 

I settled for adding a 300Ohm resistor in series with the thermistor, to get about 4% more fueling in the 10 - 30 celsius range


900 with better bits. Owes me nothing, Makes me smile


#12 gswede

gswede

    discovering Carpe

  • Member
  • 19 posts
  • Location:Stockholm Sweden
  • TDM model: 2010

Posted 28 April 2017 - 10:03 pm

 

 

I like the idea, but the thermistor has a current across it provided by the ECU, either from a voltage divider or a  current source (not sure which, I haven't ever opened one up). I suppose it is worth a try, but there is the possibility of unwanted interaction between the two systems.

 

I settled for adding a 300Ohm resistor in series with the thermistor, to get about 4% more fueling in the 10 - 30 celsius range

 

Yes, the risk of interaction is there of course but JBX is already reading the temperature directly from the sensor so the systems are already interconnected. They must of course have the same signal ground and power supply. Your idea with a fixed resistor seems simpler and I may try it. Where did you place it?



#13 chrisr

chrisr

    has been here 4ever

  • Supporting Member(thanks)
  • PipPipPipPipPipPipPipPip
  • 1,745 posts
  • Location:Surbiton, Surrey
  • TDM model: 2010

Posted 28 April 2017 - 10:42 pm

Eh?

The Blue One : 2004 model owned 2010-2018 much loved, much missed and now living with a man in Scotland
The Black One : 2010 Model Registered 2013 owned 2018 - present.Beowulf Cans. Renthal 755s Grip Puppies,15w fork oil,DL650 handguards,givi engine bars,led spotlights,gipro gear indicator,shortened dogbones,LeeHenty CSM kit and stainless bits,Topsellerie seat,MRA Xcreen,grip puppies.PC III (dynoed). K&N airfilter,Fenda extenda.


#14 fixitsan

fixitsan

    Carpe Citizen

  • Supporting Member(thanks)
  • PipPipPipPipPipPipPipPip
  • 4,668 posts
  • Location:West Lothian
  • TDM model: 2003

Posted 28 April 2017 - 11:00 pm

Yes, the risk of interaction is there of course but JBX is already reading the temperature directly from the sensor so the systems are already interconnected. They must of course have the same signal ground and power supply. Your idea with a fixed resistor seems simpler and I may try it. Where did you place it?


The resistor is wired in series with the IAT, virtually on the back of it's plug

900 with better bits. Owes me nothing, Makes me smile


#15 JBX

JBX

    full o shoite

  • RTT manager(RTT)
  • 2,206 posts
  • Location:South France
  • TDM model: 2002

Posted 28 April 2017 - 11:12 pm

This is how things look like inside the ECU for the temperature sensors :

 

iat.jpg

 

Injection technology on bikes is very close to what is found on cars.

The sensor are all fed with regulated +5V to avoid reading errors when starting the engine with a weak battery.

 

Your idea is interesting but there are some points which will make it hard to work properly :

- if you intend to make a simple D/A converter, just don't use diodes because of the forward voltage drop (around 0.8V) will make it non-linear. Use a low-pass with an op-amp. This will make the circuit more complicated for just a little ECU trick !

- when changing from digital output off to on (and reverse), the ECU may well decide the sensor failed and it will then enter fail-safe condition.

 

If it's just to trick the ECU with the temperature, Fixitsan's solution is the more simple but it will change the resulting non-linearity of the NTC to be a different one that the ECU will not compute correctly for the whole range. That may lead to other problems.

 

I don't think the IAT should be so much focused. One reason is the one I already wrote above (I actually monitored an IAT with OBD, that's why I will not spend much time trying to trick the ECU with that). Another reason is that on all cars & bikes, engineers put the IAT inside the airbox, I don't think they are that stupid to do that for no reason or just to annoy amateur tuners like us.

 

The IAT job is to give the ECU the temperature of the intake air, this is what it does, and it does it pretty well.

Many people think a temperature sensor has a very slow response time by looking at domestic digital thermometers, but the latter are slow because they take samples with long time interval simply to spare the battery. Car & bike temperature sensors just don't work this way.


Edited by JBX, 28 April 2017 - 11:15 pm.

top_640.png

 

 


#16 JBX

JBX

    full o shoite

  • RTT manager(RTT)
  • 2,206 posts
  • Location:South France
  • TDM model: 2002

Posted 12 May 2017 - 04:12 pm

i just realized that the injector signal is not good to also give the rpm info : during engine breaking, the ECU cuts the injectors, until the rpm is just above idle speed.

 

It means that using a standard Arduino Uno is not ok as it only has two external interrupt inputs.

I'll have to use at least the Arduino Mega which have much more GPIO and six external interrupt inputs.

 

I also added an "analog diag" page to check sensor data using an analog scale, requiring to change the custom chars on the fly :

 

arduino_006.jpg


top_640.png

 

 


#17 fixitsan

fixitsan

    Carpe Citizen

  • Supporting Member(thanks)
  • PipPipPipPipPipPipPipPip
  • 4,668 posts
  • Location:West Lothian
  • TDM model: 2003

Posted 12 May 2017 - 04:23 pm

You could ask if the rpm is of any importance when slowing down ?

'RPM cut' is maybe a feature ?

While the fuel is cut just simulate a slowly reducing rpm gauge, and switch to live feed once again when the throttle is reintroduced


900 with better bits. Owes me nothing, Makes me smile


#18 JBX

JBX

    full o shoite

  • RTT manager(RTT)
  • 2,206 posts
  • Location:South France
  • TDM model: 2002

Posted 12 May 2017 - 04:42 pm

Agree, could be a feature - and I'm not working for Microsoft - and rpm is not really required as there is already the dash to show it.

That said, rpm could also be calculated from the speed and the gear position...


top_640.png

 

 


#19 fixitsan

fixitsan

    Carpe Citizen

  • Supporting Member(thanks)
  • PipPipPipPipPipPipPipPip
  • 4,668 posts
  • Location:West Lothian
  • TDM model: 2003

Posted 12 May 2017 - 05:01 pm

Agree, could be a feature - and I'm not working for Microsoft - and rpm is not really required as there is already the dash to show it.

That said, rpm could also be calculated from the speed and the gear position...

 

 

Yes ! good idea, you can infer the rpm that way.

You could read the crank position sensor

You could also just read the K-Line data from the ECU, for rpm and temperature , but the k-line speed data remains a mystery because it is encoded in an unusual manner

 

in this example the speed is in the third byte, a single digit http://www.iwasz.pl/...h-arduino-mega/


900 with better bits. Owes me nothing, Makes me smile


#20 JBX

JBX

    full o shoite

  • RTT manager(RTT)
  • 2,206 posts
  • Location:South France
  • TDM model: 2002

Posted 12 May 2017 - 06:59 pm

I saw this site some time ago, very interesting stuff.

 

In that case, once you get the data pattern coming from the ECU, one thing to do is to use the Arduino (in this case) to inject some wisely forged datagrams into the dash and see how it understand it.

 

I bet there is data across bytes limits.

I've seen some proprietary protocols using weird things like 4 or 6 bits bytes !


top_640.png

 

 



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users