12v vs 5v input conditioning question

Hi all,

I'm designing a pcb right now and I have a question relating to two of the inputs. They are connected to two square wave inputs which will give me speed and rpm, but I cannot confirm whether the input signal will be 12v or 5v. I'm using a pc817 optocoupler to protect the arduino, but I'm not sure what size resistor to use on the input to the opto coupler. Can I size it to work over a range of potential inputs eg 1v to 15v, or would I need something like a zener to bleed off voltage above a certain level?

Thanks,

Nick

Have I understood this correctly:

Your input might be 5V or it might be 12V, but either way it is going to drive the input to an opto-isolator? Is that correct? If not, please clarify.

I suggest you find out:

  • From the data sheet the maximum input current for the opto-isolator
  • From experiment the minimum current into the opto-isolator that gives reliable operation.

Calculate the resistor value needed to give the minimum current +50% from 5V. Calculate the current that will result from using this resistor value if 12V is supplied. If this is within about 75% of the maximum for the isolator use this value. If not then reconsider.

Optocouplers have a wide operating range. Maximum current about 60mA. I would suggest that you set it for 12V at say 20mA and you should be able to accommodate 5V if required. However, it would be easier to measure it and select the resistor to suit.

Set the opto coupler series resistor for 20mA at 12V input, ie 560 ohms. Then assume on the receive-side
that you'll only get 1mA or so, ie use a 5k6 pull-up. That ought to have fairly robust range. Note the PC817
comes in a range of gain classes, the most generic are poorly specified for gain (aka CTR - current transfer ratio).

BTW what frequencies are involved? Standard opto-couplers with photo-transistor output are slowish, the PC817
has 18µs response time worst-case.

MarkT:
Set the opto coupler series resistor for 20mA at 12V input, ie 560 ohms. Then assume on the receive-side
that you'll only get 1mA or so, ie use a 5k6 pull-up. That ought to have fairly robust range. Note the PC817
comes in a range of gain classes, the most generic are poorly specified for gain (aka CTR - current transfer ratio).

BTW what frequencies are involved? Standard opto-couplers with photo-transistor output are slowish, the PC817
has 18µs response time worst-case.

Thanks Mark,

I'll draw this out later on, but you recommend a 560 ohm resistor on the input then a 5k6 pullup on the arduino side? Presently I am using the Arduino in input_pullup mode so the opto-coupler simply grounds the arduino pin.

Frequencies will be from around 0.5 to 3khz depending on the input, though mainly in the 0.5-1.5 range most of the time. It seems to work when testing on my bench... Would you advise a different approach?

Ok I've found out that I have the X1 version, so that is the 4-8 mA version I think. I'm struggling to see exactly how it works - should I go for the X5 as this seems to have a wider range; if I'm reading it correctly then a 1k resistor would allow both a 12 and a 5v signal to work within the range?

So here's what I have using PC817XNNSZ1B. I think if I use a 560ohm resistor then 5v = 8.9mA, 15v = 26mA - both within range. This should do the job then??

pc817.JPG

pc817.JPG

This should do the job then??

I imagine so! Give it a try.

450nick:
Hi all,

I'm designing a pcb right now and I have a question relating to two of the inputs. They are connected to two square wave inputs which will give me speed and rpm, but I cannot confirm whether the input signal will be 12v or 5v. I'm using a pc817 optocoupler to protect the arduino, but I'm not sure what size resistor to use on the input to the opto coupler. Can I size it to work over a range of potential inputs eg 1v to 15v, or would I need something like a zener to bleed off voltage above a certain level?

Thanks,

Nick

If you don't know the signal voltage then don't fit the resistor until you do know.
For test purposes take a stab in the dark, say 5V and use a suitable resistor, later when you find out what the voltage is, then change the resistor if necessary.
OR
Fit needed values with a jumper to select the appropriate resistor.
No brainer.. Tom. :slight_smile:

TomGeorge:
If you don't know the signal voltage then don't fit the resistor until you do know.
For test purposes take a stab in the dark, say 5V and use a suitable resistor, later when you find out what the voltage is, then change the resistor if necessary.
OR
Fit needed values with a jumper to select the appropriate resistor.
No brainer.. Tom. :slight_smile:

Well I've thought about this and reasonably I could change the sensor in the future and it could give a different voltage so I think I need the ability to read both, but it would be good not to have to dismantle the dash to change a jumper if I do this.

If I've understood the attached table correctly then use of this opto-isolater should allow me to use either input voltage and be within the operating limits of the component. I just wanted to check I have understood it correctly before proceeding though...

Nick,
Try it. You are not going to break anything if it's wrong. You could debate this all day long and not find out, or you could experiment and know.

You should be able to find some application notes on this subject, from the manufacturers.

Can the signal source supply 20mA?