12v input on a 3.3v microcontoler a few questions

hey

so i goth a amplifier witch has a 12v (max 50ma) trigger output witch i need to connect to a 3.3v logic microcontoler i'v figured 2 ways to do this

a 12v relay from ebay like this one relay the advantages with this is i don't have to fittel around with breadbords,solder and connectors.

option 2.
a voltage devider consisting off a 10k ohm and a 15k ohm resistor not a 100% sure on how much current this will draw but i made som calculations if some one can confirm them it wut be realy nice image

with option is preferable ? also considering how easy it is to hook up

Do not connect 4.8V to a 3.3V input pin!
Your divider should be 10k on top & 3.3k on the bottom, with 12V on top, center will be about 2.98V, current will be about 0.9mA. Also you will need a ground wire from amp to Arduino, make sure there is no MAINS VOLTAGE involved.

BTW, your circuit would put 7.2V on your input pin.
VOUT = R2 / (R1 + R2) * VIN

Why don't you just use a voltage regulator. Use a LD1117V33, add a heat sink, follow the pinout and make the necessary connections. You will get a proper 3.3 V output.

Remember, it is wiser to use a resistor (220 O) to connect the regulator's output to the load to ensure safety of your load.

For 12V to 3.3V use a 33k/10k divider, divides 12V by 4.3 down to 2.8V which will be fine.

Using a regulator is not the way to do this, this is a trigger signal, not a power supply.

You could put 2 resistors on a piece of perfboard 1 hole wide by 3 holes long, like this:
Image-0003.png

Oops...! Didn't see the signal. I thought it was a power supply.

Use a voltage divider with a 2k resistance at the signal and a 680 O resistance at GND. You will get a 3V output (peak) which is safer as the resistances may vary (due to tolerance).

Add a 150 O resistor between the pin and divider to limit current.

With 50mA max, you can't operate a relay. An optocoupler would also be a good way to hook this up but the resistor idea will work best if your Arduino can share a ground with the amplifier.

MorganS:
With 50mA max, you can't operate a relay. An optocoupler would also be a good way to hook this up but the resistor idea will work best if your Arduino can share a ground with the amplifier.

Of course the low current is not sufficient to operate a relay, but it is better to use a greater resistance for an Arduino

Thanks for the responses it seems the way to go is the voltage divider

A few question has risen from the above posts

How to find a commend ground with the amplifier

Can you pleas confirm this ?

So when I am connecting a jack to the amplifier I can measure 12v on the other end of the cable witch must mean that a there is a ground in the cable right? That can be used for the commend ground

A voltage divider consisting off a 10k on top and a 3.3k on the bottom with a current limiting resistor on v_out at 150 ohm achieve a safe goal for both the amplifier (12v max, 50 ma ) and the Arduino at 3.3v input

So this is a bit off a learning process as well for me can some pleas look thru my calculations again
image

After making the calculations I made a falstad circuit simulation witch made me think that no current will flow thru the v_out ?? but way have a current limiting resistor then?

falstad

  1. The common ground problem is related to the power supply. How are you powering both of these units? If the Arduino is fed from a 12V power output from the amplifier, then they are definitely common. If the Arduino is battery powered and not connected to anything else, then its ground is floating and may be safely connected to the amplifier. But if you then try to attach something like a battery charger to the Arduino, its ground will conflict with the amplifier.

  2. I would not use the current limiting resistor. The top resistor in the divider will perform this function.

Here is an idea for your simulation: What happens if the bottom resistor is broken and disconnected from ground? Assume that 1mA flows into the Arduino input in this fault condition. What is the voltage on the Arduino, measured at V_out? If that voltage is less than your Arduino's maximum voltage then you have a very safe circuit. If higher, then add a current limiting resistor.

You don't show the simulation, but what did you connect to v_out? Nothing? Then no current flows. Under normal operation, this is a good assumption. The current into the Arduino analog input is micro-Amps or pico-Amps. So you can use zero as a very good approximation. But under fault conditions, the current is much higher. If V_out goes below zero or above 3.3V then significant current will flow. The Arduino datasheet isn't very helpful in letting you know what this current will be, but you can assume that anything over 5mA will cause problems, possibly destroying that input pin.

Don't forget to test in simulation with the input hooked up backwards. What happens when you put -12V on that input? Does the output voltage stay within the limits?

the arduino is power truh usb from a reguler usb phone charger. (note it's actully a nodemcu esp8266 esp-12e)

how is it recomended to solve this ground problem ?

safty for my amplifier is super importen so my question is how wut you solve this situation?

You don't show the simulation, but what did you connect to v_out? Nothing? Then no current flows. Under normal operation, this is a good assumption. The current into the Arduino analog input is micro-Amps or pico-Amps. So you can use zero as a very good approximation. But under fault conditions, the current is much higher. If V_out goes below zero or above 3.3V then significant current will flow. The Arduino datasheet isn't very helpful in letting you know what this current will be, but you can assume that anything over 5mA will cause problems, possibly destroying that input pin.

so way not use an current limiting resistor to limit the current to like 5 ma will?

also i been looking around ebay traying to find a pcb able to do this task wut something like this be able to do the task??
http://www.ebay.com/itm/Standard-Voltage-Sensor-Module-for-Arduino-DC0-25V-with-Code-Spannungssensor-/271668148813?hash=item3f40aefa4d:g:Lf0AAOSwmtJXTolB

Would you mind mentioning the name of your Microcontroller..??

it's a nodemcu esp8266 ebay

while thinking about this i forth about fuses way not just put a 12v 25 ma fuse before the voltage devider ?

so i been looking around and the only type off fuse i can find with that low current rating i can find is a pptc like this on i went as low as 20ma is to have a saft margien but incase off an error do you think the fuse is fast enuf?

simondid:
the arduino is power truh usb from a reguler usb phone charger. (note it's actully a nodemcu esp8266 esp-12e)

how is it recomended to solve this ground problem ?

Personally, I would use an optocoupler, because I have had some time to play with them and understand how they work.

Google for an optocoupler tutorial. One thing I found confusing is the optocouplers have a 'current ratio' which is not explained very well. Basically the output current is a multiple of the input. Usually that mutiple is quite small, in the range 50% to 200%. But the Arduino needs nano-amps input current so any current ratio will work for you.

You will need an optocoupler and one resistor to control the current through the input side of the optocoupler. On the output side, you can use a resistor or the INPUT_PULLUP pin mode.

simondid:
saf[e]ty for my amplifier is super importan[t] so my question is how wut[ould] you solve this situation?

The amplifier probably has pretty good protection on that output. Shorting it to ground or even -12V will probably not damage it. The Arduino (or ESP8266) has no built-in protection and must have protection added by you.

simondid:
so way not use an current limiting resistor to limit the current to like 5 ma will?
[/quote]
Because the top resistor of the voltage divider is a very good current limiting resistor. You don't need to add any more.

so i been working with opto couplers before but it a few years ago here is what i came up with for a pc816 opto coupler

image

my only concern is that the Resister R_1 is dropping i^2 * R = 0.02^2 * 590 = 0.236 w ? witch means i need to get a resister that can handle more then 1/4 watt as they usaly can from ebay?

Or use two 1200 ohm, 1/4W rated parts in parallel.

ya that shut be a option after looking at the pc817 data sheet i found that it can take a max off 50 ma at 1.2v but cut i drop it to around 30ma ?? just to get a bit fathere away to from 0.25w