Reading Pulse From 12V

Hi.

I'm trying to make a simple tachometer for a motorcycle by using

attachinterrupt()

on pin 3

Since Ardunio working on 5v in I/O makes me impossible to read directly from a 12V source. so I'm using an optocoupler as a bridge between 12v to 5v, and also I wanted to read a clean signal.

the optocoupler I'm using is PC817

about the component: PC817 pdf, PC817 Description, PC817 Datasheet, PC817 view ::: ALLDATASHEET :::

Heres the sketch I'm working on

so my question is, is this the correct way to do it?

R1 560Ω is the minimal value. 680Ω or 820Ω is better.

R2 is optional. You can use the intern pull up.

1 Like

Thanks , i will try using your sketch, quick question.

The power source itself is not constant , more likely 12-14 volt, is it still safe using only 680 or 820 resistor on positive side ?

On 14V 560Ω gives 22,86mA (to much for the led in the optocoupler for long life). 0,29W over the resistor. Use at least an 0,5W type.

14V 680Ω gives 18,82mA and 0,24W over the resistor.

14V 820Ω gives 15,61mA and 0,2W over the resistor.

For protecting against wrong connection, you can place 1N4001 (1N4002, 1N4003, 1N4004, 1N4007) diode anti parallel with the PC817 led. The max reverse voltage for the led is 6V. The diode limits that to approx 1,1V.

Can I know what software are you using for making a sketch?

The schematic is drawing by Eagle PCB. Also part of Fusion360 from Atodesk.

Thank you!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.