built my own indicator controller

About two years ago, I replaced the incandescent lamps in the indicators of my trusty 1991 Honda Transalp with LEDs, only to find that, after that, of course, the 25 year old indicator relais didn’t work too well anymore. The LEDs would draw too little current, the system would assume that at least one lamp was broken and thus blink in a quick rhythm to idicate the problem.
Since it was the weekend, I couldn’t just go out and buy a new relais but I had a few ATTiny85s lying around, and so I set off.
V1 was a bit crude, using a simple voltage divider across the indicator LEDs to try and guess if they were switched on or not - by always passing a little current through them and measuring the voltage over them.
Turned out that wasn’t overly reliable, depending on the voltage in the overal system, the indicators would sometimes not work at all and sometimes, that ATTiny would just lock up and the indicators would light up constantly. (of course, the electrical system only connects the controller to the indicator lights once the indicator switch is moved to one side - but then the indicator lights on that side lit up constantly).
So this winter, it was time to come up with something better.
The scematic is attached.
Here’s the basic mode of operation:
Q1, a P-Channel MSOFET is by default on, switching a voltage to the indicator switch.
If that switch is engaged, current flows from +12V through Q1, the shunt resistor R1, the indicator switch, the indicator lights (all are paralleled up) and back to ground.
Because the system has a common ground and a switched positive output, I could not use low-side current measurement which made it necessary to use the differential ADC of the ATTiny. There is not a whole lot of information to be found about it, so I ended up coding this by looking at the Tiny datasheet.
R1 is at the high side of the lights, so somewhere between 12 and 15V with rerference to ground, the Tiny’s inputs would clamp everything >5V through their input diodes, therefore I had to build voltage dividers with the resistors R2/R7 and R3/R5 that bring the voltage down to about 1.8V
The two analog input pins ADC2/ADC3 form the differential input. I have measured a voltage of about 60-100mV over R1, so I use the internal 20x multiplier before going into the acutal ADC and then use the 2.56Vref so I get a nice wide measurement band.

One of the issues was to determine if one of the LED clusters was not working and then switch to blinking quickly.
In essence, it’s as easy as defining a current value above which everything is ok and below which, obviously one of the paralleled up lams is missing. It’s not that easy, though, as the voltage might vary depending on speed and battery state. As a solution, I also measure the absolute voltage on one of the sense pins and use a factor to determine the switchover point. basically, if both lamps are working, you get one line for I over U, if only one is working, you get a lower line. The switchover line should be in between the two.

Configuring this switchover required measuring the voltage and current at different system voltages (I used 9 to 15V) and setting the appropriate values.

Since I didn’t want to have to re-program the ATTiny for every change, I came up with a very simpel serial interface that allows me to set

  • the normal blinking interval
  • the fast blinking interval
  • a wait time, just to make the loop not too tight when not indicating (currently normally 100ms)
  • the switchover factor (in multiplicant and divisor)
  • the minimum current measurement to activate the indicator

So I think I now have the most overengineered indicator controller in the world, certainly the only one that is field programmable with just a serial terminal.

Maybe someone has some use for it, at least the differential ADC is something that I have found to be badly documented.

The code is here GitHub - pljakobs/tinyBlinker

kind regards

pj

You could also use a shunt resistor of 1 or 2 ohms and measure the voltage drop over it. Then you can extrapolate the current.

That's just what I did.
The challenge was, that I don't see the return current to ground but have to measure the current on the +12V side (which really is somewhere between 13.4V and 11V depending on a number of factors). Hence the use of the diff ADC.

If that switch is engaged, current flows from +12V through Q1, the shunt resistor R1, the indicator switch, the indicator lights (all are paralleled up) and back to ground.

pj