12V sensors to Arduino

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
moscardo
 
Posts: 41
Joined: Sun Nov 06, 2016 6:12 am

12V sensors to Arduino

Post by moscardo »

Hi guys,

for an upcoming project I will need to translate 12V digital output signals from a series of industrial retro-reflectice IR sensors (like this one) in order to be read from an Arduino board.

What kind of "converter board" can I use?

I have read that several strategies can be considered:
  • using relays (but I don't consider it the preferred route);
  • using transistors like the 2N2222 and a few electrical components on the side;
  • using optocouplers (which seems to me to be the preferable way).
About the optocouplers solution:
  1. are there any disadvantages that I should evaluate?
  2. Are there breakout boards in your catalog that already mount one or more optocouplers for the purpose?
  3. Are there other strategies that I haven't considered?
Thank you so much for your help

User avatar
adafruit_support_bill
 
Posts: 88039
Joined: Sat Feb 07, 2009 10:11 am

Re: 12V sensors to Arduino

Post by adafruit_support_bill »

If you use one with NPN open-collector output, you just need a pullup to your processor board voltage (3.3v or 5v - depending on what board you are using).

But an opto-isolator will give your Arduino better protection against any noise or transients that might get picked up by your signal wire. About the only down-side of the opto-isolator would be some additional latency in the signal. But unless you are dealing with microsecond-level timing, that should not be an issue.

We do not stock an opto-isolator board. But Sparkfun has one: https://www.sparkfun.com/products/9118

User avatar
moscardo
 
Posts: 41
Joined: Sun Nov 06, 2016 6:12 am

Re: 12V sensors to Arduino

Post by moscardo »

Hi Bill
thank you for your reply.

I will dig deeper inside the sensors datasheet to check if they have that kind of output.

For more robustness to noise I could certainly opt for the opto-isolator (we have no latency constraints in my case).

I was just now examining the schematic for the board you recommend, and I would like to expound on a perplexity.
sparkfun_opto_isolator.png
sparkfun_opto_isolator.png (53.14 KiB) Viewed 114 times
From the diagram it seems to me that this isolator is designed to work in the "reverse direction" of what I need: the 5V side is the one on the left, and the digital signal from this section would go to drive the "noisy circuit" on the right side.

In my case I would instead need the 12V output of the sensor to be connected with the input of the opto-isolator. And the output of the latter to be connected to the Arduino.

Am I missing something?
Thank you!

User avatar
adafruit_support_bill
 
Posts: 88039
Joined: Sat Feb 07, 2009 10:11 am

Re: 12V sensors to Arduino

Post by adafruit_support_bill »

Your understanding of the circuit is correct. To handle 12v signals on the left side, you would need to increase the resistance in series with the LED.

To handle 5v on the right side, you should be able to just connect HV to 5v.

User avatar
moscardo
 
Posts: 41
Joined: Sun Nov 06, 2016 6:12 am

Re: 12V sensors to Arduino

Post by moscardo »

thank you very much Bill for your support,
from the datasheet of the optoisolator I read that the forward voltage of the LED is typically 1.2V (calculated with If of 10mA).
sparkfun_opto_isolator_datasheet.png
sparkfun_opto_isolator_datasheet.png (13.17 KiB) Viewed 100 times
Considering that I have to handle a 12V input I would then only need to insert an additional 1 KOhm resistor (technically the calculation returns me an 858 Ohm which however is no commercially available value).

Would that work?

User avatar
adafruit_support_bill
 
Posts: 88039
Joined: Sat Feb 07, 2009 10:11 am

Re: 12V sensors to Arduino

Post by adafruit_support_bill »

You can get closer to the 'theoretical' ideal by going to a 1% resistor or playing with combinations of resistors. But the exact value is not that critical. 1K will probably work fine.

User avatar
moscardo
 
Posts: 41
Joined: Sun Nov 06, 2016 6:12 am

Re: 12V sensors to Arduino

Post by moscardo »

Thank you so much Bill.

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”