Controlling an analog dash

Introduction and miscellaneous that we haven't created categories for, yet
User avatar
clanger9
Posts: 203
Joined: Mon Oct 28, 2019 7:41 am
Location: Chester, UK
Been thanked: 1 time
Contact:

Re: Controlling an analog dash

Post by clanger9 »

You can do CAN with an Uno and a suitable shield:
https://www.openinverter.org/wiki/Getti ... rduino_Uno

A Teensy 3.6 is probably the way to go. It has on-board SD card (for logging) and 2 CAN channels:
https://openinverter.org/wiki/Getting_C ... Teensy_3.6

I think Teensy 4.0 also has CAN, but it doesn't seem to be as well supported (yet). A 3.6 can be used as a CAN logger for SavvyCAN
using TeensyRET, which is awesome.

You just need to add a pair of transceivers. You can also use a Due, though they are pretty cumbersome by comparison...
Greenbeast
Posts: 115
Joined: Sat Dec 26, 2020 5:44 pm

Re: Controlling an analog dash

Post by Greenbeast »

Ah OK, I don't have a due anyway.

I'll get a teensy 3.6
Greenbeast
Posts: 115
Joined: Sat Dec 26, 2020 5:44 pm

Re: Controlling an analog dash

Post by Greenbeast »

Trying to understand the layout of devices...

So potentially i'll have charger/bms/inverter/etc... each putting data on the can bus, then behind my cluster i need a CAN transceiver, a teensy, do i also need an arduino to run the dials and lights, or does the teensy have the capability to do that?
User avatar
clanger9
Posts: 203
Joined: Mon Oct 28, 2019 7:41 am
Location: Chester, UK
Been thanked: 1 time
Contact:

Re: Controlling an analog dash

Post by clanger9 »

Good question - one I'm grappling with right now :ugeek:

As of today, I've settled on:
1x open source "VCU" (based on a Teensy) that will do the physical switches/dials/precharge/contactors etc and send any necessary enable/disable messages over CAN. It will also run the guess-o-meter code for the range estimation using CAN messages from an Isabellenhütte IVT-S. It will also (hopefully) manage a bidirectional DC:DC for 12V battery charging and precharge, though that may end up with a Teensy of its own.
1x CAN-controlled inverter. I don't know if this will be an OpenInverter design or something closed-source.
1x CAN-controlled charger. Probably an expensive closed source thing.
User avatar
clanger9
Posts: 203
Joined: Mon Oct 28, 2019 7:41 am
Location: Chester, UK
Been thanked: 1 time
Contact:

Re: Controlling an analog dash

Post by clanger9 »

This is roughly where my head is at:
Dart schematic.png
The "VCU" will also have outputs for the temperature gauge & remaining range display (not shown). The basic idea is to preserve as much as possible of the original bike "user interface" i.e. retaining the meaning and purpose of the original switchgear & indicator lights. It is likely that all the indicator lights will be handled by the VCU (via CAN), rather than coming directly from the inverter & charger (as shown in my diagram).

I am trying to get my head around using an Arduino-based finite state machine to do the logic control e.g. ignition must be off & stand down to enable charging, ignition must be on, stand up & starter pressed to enable inverter output etc.

The hope is to have all "my" vehicle-specific code in one place (the VCU), with others providing generic CAN-based hardware & software for the charger & inverter...
Greenbeast
Posts: 115
Joined: Sat Dec 26, 2020 5:44 pm

Re: Controlling an analog dash

Post by Greenbeast »

Nice diagram!

I couldn't figure out what you meant by 'stand' at first :D

I have discovered the tacho on my fourtrak is run by a signal from the fuel pump, i don't know what form that takes yet

I have 3x centre dash dial positions, currently populated by an analog time clock, an inclinometer and a 12V gauge, first and last will stay but i'll replace the inclinometer with one of those tidy little displays i see at EV West for checking more detail than my dash will show.
User avatar
clanger9
Posts: 203
Joined: Mon Oct 28, 2019 7:41 am
Location: Chester, UK
Been thanked: 1 time
Contact:

Re: Controlling an analog dash

Post by clanger9 »

Yeah, no need for a stand on a FourTrak! :lol:

PWM should work fine for the fuel & temp gauges. For your tacho, you might need to add a push-pull stage if it needs a zero-crossing waveform. Hopefully it'll just accept a variable frequency square wave.

I plan to replace the insides of my mechanical current meter with an OLED display. It will show a bargraph-style battery gauge with a digital range guess-o-meter. The tacho will get a larger (LCD?) display showing an output power gauge and (possibly) HV volts & amps. I tend to prefer the minimum amount of distraction on a dashboard. Which is why I'll be retaining the idiot lights... 8-)

Here's my VCU diagram re-drawn. Looking a bit clearer now. Next step is to prototype this on a Teensy...
Dart VCU schematic.png
Greenbeast
Posts: 115
Joined: Sat Dec 26, 2020 5:44 pm

Re: Controlling an analog dash

Post by Greenbeast »

clanger9 wrote: Sun Jan 03, 2021 7:36 pm For your tacho, you might need to add a push-pull stage if it needs a zero-crossing waveform. Hopefully it'll just accept a variable frequency square wave.
I have yet to find how these bloody things work (and i actually can't find the pins that take the input yet) but i guess if i look at generating a variable frequency square wave and then play with that when i've actually got a motor running then i should be able to figure it out

edit to add: took the cluster apart and found the pins in question
User avatar
celeron55
Posts: 776
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 28 times
Been thanked: 110 times
Contact:

Re: Controlling an analog dash

Post by celeron55 »

For my 1992 Toyota tacho I had to create a voltage doubler circuit in order to get high enough voltage in addition to having to do zero crossings. Was a bit of a pain but with those it works nicely.
Greenbeast
Posts: 115
Joined: Sat Dec 26, 2020 5:44 pm

Re: Controlling an analog dash

Post by Greenbeast »

Which Toyota specifically?
Toyota and Daihatsu have a share lineage, so might be of use to me
User avatar
clanger9
Posts: 203
Joined: Mon Oct 28, 2019 7:41 am
Location: Chester, UK
Been thanked: 1 time
Contact:

Re: Controlling an analog dash

Post by clanger9 »

Is your RPM sensor on the diesel fuel pump?

If it's something like this, then I think it just outputs a sine wave of a few volts:
https://www.ebay.co.uk/itm/ME203180-For ... 3707163331

Should be easy enough to generate a suitable waveform from an Arduino?
Greenbeast
Posts: 115
Joined: Sat Dec 26, 2020 5:44 pm

Re: Controlling an analog dash

Post by Greenbeast »

clanger9 wrote: Mon Jan 04, 2021 7:13 pm Is your RPM sensor on the diesel fuel pump?
yes i believe so, cheers i will look now
Greenbeast
Posts: 115
Joined: Sat Dec 26, 2020 5:44 pm

Re: Controlling an analog dash

Post by Greenbeast »

clanger9 wrote: Sun Jan 03, 2021 10:06 am This might be a more useful test setup (on a roll now...)
This is what I used to characterise the gauge. It adds a potentiometer so you can set the gauge to any value. The value is shown on the serial monitor.
Got transistors in and now i find the smallest resistor i have is 1.5k, doh!
Actually i have 1.2k, i'll try that
User avatar
clanger9
Posts: 203
Joined: Mon Oct 28, 2019 7:41 am
Location: Chester, UK
Been thanked: 1 time
Contact:

Re: Controlling an analog dash

Post by clanger9 »

Anything 1-2k will be just fine.
Greenbeast
Posts: 115
Joined: Sat Dec 26, 2020 5:44 pm

Re: Controlling an analog dash

Post by Greenbeast »

I could do with some baby walking through this if you wouldn't mind.
I've hooked up the circuit as you show and uploaded the sketch you provided, when i apply 12v and it hits the first step above 0 (75), the dial goes to max and stays there.

Playing with the numbers in the sketch reveals that 25 will max out the dial if i give the delays long enough (15s), so i had each boundary roughly 5 apart and up to 20 it barely moves.
User avatar
clanger9
Posts: 203
Joined: Mon Oct 28, 2019 7:41 am
Location: Chester, UK
Been thanked: 1 time
Contact:

Re: Controlling an analog dash

Post by clanger9 »

Is this the fuel gauge or rev counter?

You shouldn't need to fiddle with the delays in the source code (unless the gauge is really heavily damped) - those are just 10 second pauses at each level. If the gauge is very slow, try 30 second intervals instead.

You can change the numbers in this section to get different readings:

Code: Select all

const int min_blue = 0;
const int low_blue = 75;
const int middle_blue = 150;
const int high_blue = 175; 
const int red_start = 200;
const int red_max = 255;
Watch the Arduino serial monitor to see which value corresponds to which reading. If it's reading too high, try 0, 5, 10, 15, 20, 25 and see what happens...

Or is that what you already tried? It'd be strange if it barely moves at 20, but maxes out at 25...
Greenbeast
Posts: 115
Joined: Sat Dec 26, 2020 5:44 pm

Re: Controlling an analog dash

Post by Greenbeast »

clanger9 wrote: Thu Jan 07, 2021 10:41 pm Is this the fuel gauge or rev counter?

You shouldn't need to fiddle with the delays in the source code (unless the gauge is really heavily damped) - those are just 10 second pauses at each level. If the gauge is very slow, try 30 second intervals instead.

You can change the numbers in this section to get different readings:

Code: Select all

const int min_blue = 0;
const int low_blue = 75;
const int middle_blue = 150;
const int high_blue = 175; 
const int red_start = 200;
const int red_max = 255;
Watch the Arduino serial monitor to see which value corresponds to which reading. If it's reading too high, try 0, 5, 10, 15, 20, 25 and see what happens...

Or is that what you already tried? It'd be strange if it barely moves at 20, but maxes out at 25...

Temp gauge, yes sorry I miscommunicated, I turned all the output numbers down and then realized the needle wasn't getting enough time to react so turned up the delay interval.
I was indeed watching serial to see what corresponded to what.
I assume it should be linear?
I will play with it some more later today
User avatar
clanger9
Posts: 203
Joined: Mon Oct 28, 2019 7:41 am
Location: Chester, UK
Been thanked: 1 time
Contact:

Re: Controlling an analog dash

Post by clanger9 »

If it's too sensitive (i.e. you get max scale around 25), then it needs a current limiting resistor in the gauge input. Try 100 ohms or something.

These gauges aren't very linear, but they should be linear-ish. The beauty of Arduino-controlled PWM is you can set it to point at whatever you want for each given condition...
Greenbeast
Posts: 115
Joined: Sat Dec 26, 2020 5:44 pm

Re: Controlling an analog dash

Post by Greenbeast »

clanger9 wrote: Fri Jan 08, 2021 10:21 am If it's too sensitive (i.e. you get max scale around 25), then it needs a current limiting resistor in the gauge input. Try 100 ohms or something.


OK I'll give that a go later

These gauges aren't very linear, but they should be linear-ish. The beauty of Arduino-controlled PWM is you can set it to point at whatever you want for each given condition...
OK, I reality how does that work with temp and battery SoC given how 'analog' they are, does it involve arrays (to link X degrees C with Y pwm output across the whole range?
User avatar
clanger9
Posts: 203
Joined: Mon Oct 28, 2019 7:41 am
Location: Chester, UK
Been thanked: 1 time
Contact:

Re: Controlling an analog dash

Post by clanger9 »

Yes, pretty much. In reality, you'd set up a handful of thresholds for the meter position (say, 10) in an array and map those onto whatever values you want to indicate. Analogue gauges are only approximate, so you wouldn't need a huge number of "steps".

One of the nicest ways to implement this on Arduino that I've come across is with a comparator "finite state machine". I'm still trying to get my head around the concept, but the code looks incredibly simple. Here's an LED fuel gauge:
https://github.com/tinkerspy/Automaton/ ... _gauge.ino
https://github.com/tinkerspy/Automaton/wiki
Greenbeast
Posts: 115
Joined: Sat Dec 26, 2020 5:44 pm

Re: Controlling an analog dash

Post by Greenbeast »

Ok 60 now maxes it out, it moves slower, but i suppose in a real-world, non-testing environment i should not expect actual rapid swings in temperature over the sub-30s timeframe.
Same with Battery SoC.
Greenbeast
Posts: 115
Joined: Sat Dec 26, 2020 5:44 pm

Re: Controlling an analog dash

Post by Greenbeast »

I'm now testing fuel gauge, 255 maxes it (need to test lower figure), but my problem with testing now is that the fuel gauge doesn't return to 0, it stays at the last high point, even changing the pwm number doesn't drop. Any ideas?
Greenbeast
Posts: 115
Joined: Sat Dec 26, 2020 5:44 pm

Re: Controlling an analog dash

Post by Greenbeast »

Clanger, might you help this poor lost soul?
User avatar
clanger9
Posts: 203
Joined: Mon Oct 28, 2019 7:41 am
Location: Chester, UK
Been thanked: 1 time
Contact:

Re: Controlling an analog dash

Post by clanger9 »

Hi Greenbeast, sorry - missed your post on Friday!

That's odd. Does the fuel gauge drop when you disconnect the power?
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 233 times
Contact:

Re: Controlling an analog dash

Post by arber333 »

Greenbeast wrote: Fri Jan 08, 2021 5:51 pm I'm now testing fuel gauge, 255 maxes it (need to test lower figure), but my problem with testing now is that the fuel gauge doesn't return to 0, it stays at the last high point, even changing the pwm number doesn't drop. Any ideas?
I have the same problem. Pull-up resistor is causing dial to show middle position. This has to do with selecting correct resistor.
Also using darlington NPN will not turn down pwm fully so you will get some drain even at full off.
I think we have to use NMOS.
I will get back to you...
Post Reply