Tachometer-regulated LED

I have an older Harley-Davidson that I'll be doing some custom work on soon, it has a 12v square-wave tachometer signal from the aftermarket ignition setup. I am looking to take that ignition signal and convert it to a PWM signal to dim/brighten LED lighting (completely dimmed at 800RPM, complete brightness at 6,500RPM. This will be the only thing the Arduino is used for.

I have the following questions related to this project:
Which Arduino board is best for use with 12v automotive systems, and what (if any) over-voltage protection should I place on it? In addition to being capable of handling the automotive voltage, the physical size of components would preferably be as small as possible.

I will be using a maximum of five individual LED bulbs (to be embedded in a piece of engraved plexiglass), will I need to use any additional relays to power them, or will the arduino's outputs be sufficient?

As this will be acting almost as a visual tachometer, what would be the best means of programming the arduino for fastest refresh rate in counting the tachometer output pulses?

A Nano is a good choice for this kind of thing. Use the search box for tips on automotive signal protection, there were good threads on that subject recently. It will drive the LEDs no problem, just remember to use current limiting resistors. Refresh rate should not be a problem with any normal approach to this program.

Curbside:
Which Arduino board is best for use with 12v automotive systems, and what (if any) over-voltage protection should I place on it? In addition to being capable of handling the automotive voltage, the physical size of components would preferably be as small as possible.

None of the Arduino boards is suitable for direct connection to a 12v system The Arduino nano is small and should be ideal for your project but the maximum voltage must not exceed 5v.

You would need a suitable voltage regulator to provide 5v power for the Arduino - a cheap option wold be one of the automotive USB chargers.

You will also need to match the 12v pulse signal to the 5v limit of the Arduino. An opto-isolator would probably be best as it would completely isolate the Arduino from irregularities in the 'bikes 12v supply. I don't know if you can get opto-isolators that can take a 20v input and provide a 5v output. I mention 20v so that it can easily cope with the variations in the 12v supply.

...R

Just curious, are you planning on a bar graph arrangement of LEDs, perhaps the current range is variable brightness until it’s time to start on the next LED up.

Or do you mean to have all the LEDs display the same level of brightness?

I’d also like to know more about your mechanical concept. Do you have a particular LED in mind?

a7

Robin2:
None of the Arduino boards is suitable for direct connection to a 12v system The Arduino nano is small and should be ideal for your project but the maximum voltage must not exceed 5v.

You would need a suitable voltage regulator to provide 5v power for the Arduino - a cheap option wold be one of the automotive USB chargers.

You will also need to match the 12v pulse signal to the 5v limit of the Arduino. An opto-isolator would probably be best as it would completely isolate the Arduino from irregularities in the 'bikes 12v supply. I don't know if you can get opto-isolators that can take a 20v input and provide a 5v output. I mention 20v so that it can easily cope with the variations in the 12v supply.

...R
Would it be possible to use a pair of resistor-based voltage divider circuits for the voltage-in and signal-in?

Check this out, I made exactly the kind of thing you're looking for here
Can be powered by 12v, accepts a 12v sqare wave, and uses neopixel LED's

mickymik:
Check this out, I made exactly the kind of thing you're looking for here
Can be powered by 12v, accepts a 12v sqare wave, and uses neopixel LED's

That's similar, I guess...but what I had in mind was to have all of the LED lights illuminated simultaneously, with their brightness controlled by PWM, as opposed to being lit sequentially in a graph-type array.

Then just use the power and signal circuitry from that project, then just map the frequency range to a PWM output.
you could copy paste all of the code related managing the input signal, make some small tweaks, add something like:

map pwmOut (inputFrequency,100, 150, 0, 255);
analogWrite (pwmOut);

and bobs your uncle, you have a working tacho light

mickymik:
Then just use the power and signal circuitry from that project, then just map the frequency range to a PWM output.
you could copy paste all of the code related managing the input signal, make some small tweaks, add something like:

map pwmOut (inputFrequency,100, 150, 0, 255);

analogWrite (pwmOut);




and bobs your uncle, you have a working tacho light

Awesome, many thanks!

I think something like this will do the trick.

To calculate frequency you need to know the number of high/lows per engine rotation, mutilply by RPM

as for code, i thing something like this should do nicely:

const byte tachPin = 2;
const byte LEDpin = 6;
int LEDbrightness;
int LEDbegin = ? ;    //replace "?" with tacho signal frequency for when LEDs should start illuminating here
int LEDend = ? ;      //replace "?" with tacho signal frequency for when LEDs should be full brightness here
unsigned long inputfreq;


void setup() {
}

void loop() {

  float ighigh, iglow;
  unsigned long igcal1, igcal2;

  //measure period of tach signal
  ighigh = pulseIn(tachPin, HIGH);
  iglow = pulseIn(tachPin, LOW);

  igcal1 = 1000 / ((ighigh / 1000) + (iglow / 1000));

  //do it again
  ighigh = pulseIn(tachPin, HIGH);
  iglow = pulseIn(tachPin, LOW);

  igcal2 = 1000 / ((ighigh / 1000) + (iglow / 1000));

  //to filter out some noise, we only consider our measurement valid if they are similar in value, we accept the average.
  if ((igcal1 - igcal2) < 8) {
    inputfreq = (igcal1 + igcal2) / 2;

map LEDbrighness (inputfreq,LEDbegin,LEDend,0,255);
analogWrite LEDpin (LEDbrightness);


  }

Just out of interest do you know the frequency of the RPM signal? Sounds like a nice possible future project.

It varies depending on no. of cylinders, and where your'e getting the signal from (e.g if you are taking the signal from coil negative on a 4 cylinder engine with destributor then you will have 2 pulses per revolution). Or if you take the same signal from the same kind of set up on a V8 engine you will have 4 pulses per revolution.
If you then multilply the rpm by this number, then divide by 60, you will have the pulse frequency in Hz (pulses per second)

If you have a 4 cylinder with coil-over-plug-style ingnition coils, and you take the signal from one of the coils it will be 0.5 pulses per rotation (the coil fires once per every 2 roations)

It all depends on your engine/ignition system and where you pick up the signal.
Most older cars have on output from the ECU that goes to the dash with a nice square wave signal, newer cars take the signal over CAN, in this case you either have to pick up the signal froma coil, or design a new project with CAN module and so on.

I was referring to the OPs Harley

Doesnt matter if its a harley or a mack truck, the rpm signal frequency would still be calculated in the way described.

mickymik:
Most older cars have on output from the ECU that goes to the dash with a nice square wave signal, newer cars take the signal over CAN, in this case you either have to pick up the signal froma coil, or design a new project with CAN module and so on.

Exactly, what is "your" calculation for the "nice squarewave signal" from the ECU? This will be different per vehicle, brand and model.

Hi,
I presume this project is just for show/display/bling, it has no accurate driver information in its brightness display.
Except when the engine is lest than 800RPM when the LEDs are out.
Reading your RPM via LED brightness is not practical as just ambient light will change the appearance of the LEDS.

Tom... :slight_smile:

Will be a standard tacho signal, dependant on no. of cylinders. The reason why every aftermarket tacho ever has a switch on the back to select no. of cylinders.

Its a standard that is dependant on engine type.

The example I gave above is if you use coil negative, which varies dependant on ignition system and engine type.

The standard for a tacho signal from the ecu is revolutions per second multiplied by ignition events per rotation. (also explained above)

I assume you have a V twin, which is, as the name implies, 2 cylinders.

This is a 4 stroke engine.

That means one cylinder will fire once per every 2 crankshaft roataions

multiplied by no. of cylinders

is equal to........

1 ignition event per crankshaft roataion

This means you take rpm, divide by 60 to get revolutions per second

multiply by no. of ignition events per revolution

and you have signal frequency.

example:
(3000RPM/60s)*1
=50Hz