Author Topic: HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?  (Read 6281 times)

0 Members and 1 Guest are viewing this topic.

Offline wabhavkumarTopic starter

  • Contributor
  • Posts: 12
  • Country: in
HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?
« on: July 02, 2018, 11:33:15 am »
I WANT TO USE 12V OPERATING NO NC SENSOR WITH MICROCONTROLLER. PLEASE SHARE METHODS OF DOING THIS
 

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 6572
  • Country: nl
Re: HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?
« Reply #1 on: July 02, 2018, 11:38:37 am »
Your caps lock is stuck  ;)
 
The following users thanked this post: Naguissa

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 6572
  • Country: nl
Re: HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?
« Reply #2 on: July 02, 2018, 11:41:58 am »
But to answer your question many possibilities, I use mainly:

1) voltage divider (two resistors) https://en.wikipedia.org/wiki/Voltage_divider
2) opto coupler

The first one I use with local (on pcb) voltages that are referenced to the same ground.
The second I use mainly with off pcb voltages from different devices.
 

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 6572
  • Country: nl
Re: HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?
« Reply #3 on: July 02, 2018, 12:28:29 pm »
Quote
I WANT TO USE 12V OPERATING NO NC SENSOR WITH MICROCONTROLLER
*** Parse error.
Hahaha the topic text was more clear but rereading this it really does not compute  :-//
 

Offline wabhavkumarTopic starter

  • Contributor
  • Posts: 12
  • Country: in
Re: HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?
« Reply #4 on: July 02, 2018, 12:33:31 pm »
thank you for the valuable reply. Please suggest optocoupler circuit.
 

Offline DTJ

  • Super Contributor
  • ***
  • Posts: 1006
  • Country: au
Re: HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?
« Reply #5 on: July 02, 2018, 12:45:40 pm »
thank you for the valuable reply. Please suggest optocoupler circuit.


Have a read of these links. They will get you started.

http://www.onsemi.cn/PowerSolutions/document/AN-3001.pdf.pdf

http://www.nutsvolts.com/magazine/article/optocoupler-circuits
 

Offline wabhavkumarTopic starter

  • Contributor
  • Posts: 12
  • Country: in
Re: HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?
« Reply #6 on: July 02, 2018, 01:03:52 pm »
Can we use 12v input at Pin no 1 of optocoupler?
 

Offline wabhavkumarTopic starter

  • Contributor
  • Posts: 12
  • Country: in
Re: HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?
« Reply #7 on: July 02, 2018, 01:26:01 pm »
is using 12volt input at pin no 1 of optocoupler pc817 correct? kindly  check the circuit image
 

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 6572
  • Country: nl
Re: HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?
« Reply #8 on: July 02, 2018, 01:37:42 pm »
Check the led current for that opto, usually about 10-15mA. So for 10mA and a 1,3V Vfw of the led your 12V needs aprox a 1kOhm resistor not a 10k ;)
But what is the REED_SW ?
 

Offline wabhavkumarTopic starter

  • Contributor
  • Posts: 12
  • Country: in
Re: HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?
« Reply #9 on: July 03, 2018, 05:39:36 am »
hello sir,
REED_SW is a type of NO NC sensor which is connected at pin no 1 and pin no 2 of the optocoupler.
 

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 6572
  • Country: nl
Re: HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?
« Reply #10 on: July 03, 2018, 06:56:08 am »
You mean like a proximity sensor?
These are in different versions which need different schematic:

1) NPN NO  this is a so called open collector output which will put the output hard to ground when active and floating (or 100k pullup or something like this) when passive. This needs to be in the - cathode side of the led, pulling the opto-led to ground when active and the + anode of the led needs to be connected with 1k to 12V.

2) NPN NC this is the inverse of above and the only difference is that the software should inverse the logic.

Then you have
3) PNP NO: it gives 12V on the output when active, 0V when passive. This one you can use as drawn but you can forget about the pullup to 12V not needed.
4) PNP NC: it gives 0V when active and 12V when passive. Again same as 3) but the software should inverse the logic.

 

Offline wabhavkumarTopic starter

  • Contributor
  • Posts: 12
  • Country: in
Re: HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?
« Reply #11 on: July 03, 2018, 07:07:37 am »
Sir, instead of the optocoupler, can I use a transistor to sense high and low of the NO NC sensor.
 

Offline wabhavkumarTopic starter

  • Contributor
  • Posts: 12
  • Country: in
Re: HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?
« Reply #12 on: July 03, 2018, 07:13:41 am »
Sir,
Please verify the attached circuit can replace optocoupler circuit?
 

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 6572
  • Country: nl
Re: HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?
« Reply #13 on: July 03, 2018, 08:34:19 am »
NPN needs a pulldown on the base not a pullup AFAIK.
 

Offline Raj

  • Frequent Contributor
  • **
  • Posts: 701
  • Country: in
  • Self taught, experimenter, noob(ish)
Re: HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?
« Reply #14 on: July 03, 2018, 09:02:22 am »
let mistery part be microcontroller

Pin 3 can do analogue measurement of input  also ground needs to be common for both microcontroller and input

Note: for given values of resistor,the reading microcontroller does will be 4/12th part of input


pin 1 can do digital measurement of input 2 and ground can be isolated

« Last Edit: July 03, 2018, 09:08:13 am by Raj »
 

Offline wabhavkumarTopic starter

  • Contributor
  • Posts: 12
  • Country: in
Re: HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?
« Reply #15 on: July 03, 2018, 10:03:46 am »
At input 2, mentioned in the above circuit, can we use 12volt?
 

Offline Raj

  • Frequent Contributor
  • **
  • Posts: 701
  • Country: in
  • Self taught, experimenter, noob(ish)
Re: HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?
« Reply #16 on: July 03, 2018, 10:13:31 am »
yes,
Ouch.I forgot to revaluate the r4, it should be 1k ohm for 12v
 

Offline luiHS

  • Frequent Contributor
  • **
  • Posts: 604
  • Country: es
Re: HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?
« Reply #17 on: July 03, 2018, 10:36:29 am »

I convert any logical signal to 3.3v levels with a CD4050 or HEF4050 chip. For example, to read TTL 5v signals on a Kinetis microcontroller (there are no 5v tolerant ports available), or to check the status of switches that switch 12v voltages. This is for digital signals (high-low logical levels), not for analog signals.

HEF4050 include 6 buffers, so if you only need read one signal better work with a transistor or optocoupler, though HEF4050 is very cheap and do not need any additional component.

The voltage of the output signals in the HEF4050, will be the power supply voltage of the chip, between 3v and 15v, and the maximum voltage at the input is 15v.

If you want invert the input signal, then can use the HEF4049 or CD4049.
 

Offline Raj

  • Frequent Contributor
  • **
  • Posts: 701
  • Country: in
  • Self taught, experimenter, noob(ish)
Re: HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?
« Reply #18 on: July 03, 2018, 01:21:26 pm »
A resistor divider with at most a zener diode is best...all the rest is overkill and expensive to be honest
 

Offline wabhavkumarTopic starter

  • Contributor
  • Posts: 12
  • Country: in
Re: HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?
« Reply #19 on: July 05, 2018, 04:04:13 pm »
Please suggest Zener diode circuit to sense 12 V or 24V circuit instead of the optocoupler.
 

Offline Raj

  • Frequent Contributor
  • **
  • Posts: 701
  • Country: in
  • Self taught, experimenter, noob(ish)
Re: HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?
« Reply #20 on: July 06, 2018, 08:21:35 am »
Here's one for 12v...Don't use it for 24 volt input (the zener will prevent anything from getting damaged but still don't...it's unideal)
« Last Edit: July 06, 2018, 08:25:50 am by Raj »
 

Offline Raj

  • Frequent Contributor
  • **
  • Posts: 701
  • Country: in
  • Self taught, experimenter, noob(ish)
Re: HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?
« Reply #21 on: July 06, 2018, 08:24:38 am »
Here's one for upto 24 volt reading,but you can't use it for 12 volts unless you use analogue to digital converter though it won't get damaged from 12 volts,it's the safest choice for you.

I think implementing anything that can be done in software is better than hardware implementation.

What microcontroller are you using?
« Last Edit: July 06, 2018, 08:30:05 am by Raj »
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 7549
  • Country: 00
  • +++ ATH1
Re: HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?
« Reply #22 on: July 06, 2018, 08:37:18 am »
Raj n Kumar, why Indians love to use eyes blinding text all the time ? Not only you two, but I have seen too many at various forums as well.

Is it a cultural thing ? As common netiquette, its like shouting out loud when talking, everytime.  :-//
« Last Edit: July 06, 2018, 08:38:49 am by BravoV »
 

Offline Sudo_apt-get_install_yum

  • Regular Contributor
  • *
  • Posts: 165
  • Country: se
Re: HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?
« Reply #23 on: July 06, 2018, 09:20:04 am »
You could use a voltage divider to get the correct voltage out for the microcontroller.
You could also use a comparator to see if the voltage threshold exceeds 12V.

Probable the easier of the two is the voltage divider.

Not sure if you’re just exited but your caps lock is on ;)
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19938
  • Country: gb
  • 0999
Re: HOW TO SENSE 12 VOLT DC VOLTAGE USING MICROCONTROLLER?
« Reply #24 on: July 06, 2018, 09:27:45 am »
Raj n Kumar, why Indians love to use eyes blinding text all the time ? Not only you two, but I have seen too many at various forums as well.

Is it a cultural thing ? As common netiquette, its like shouting out loud when talking, everytime.  :-//
Perhaps their love of eye burning text is linked to their taste for mouth burning spicy food?

Anyway, I recently posted this schematic in another thread. It converts a voltage ranging from 10V to 15V to 0V to 5V, which can be read from an MCU ADC pin.

https://www.eevblog.com/forum/projects/mesuring-a-12v-lead-acid-battery/msg1644677/#msg1644677
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf