analog input greater than 5V

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

User avatar
achillis1
Posts: 347
Joined: Thu Oct 09, 2008 9:19 am
Has thanked: 92 times
Been thanked: 8 times
Contact:

analog input greater than 5V

Postby achillis1 » Tue Nov 24, 2015 4:35 pm

Hello,

I need to sample analog inputs greater than 5v probably up to 25V.

I can think 2 ways doing that:

1. Drive a transistor with 25v and the transistor's output will be connected with 5v rail and after to the PIC analog input.

If the transistor's input varies ( sine wave ) WILL it have an appropriate affect on the transistor output Collector - Emitter ? Will the output be binary ( 0v - 5v ) or will follow the sine wave variation and be ( 0.1 , 0,5 1v.....- 0.1v , -1v etc )?


2. Use an AC transformer 5:1 scale so it will scale down 25v to 5v

Can you tell me what would be the best method?

Thank you,

Best Regards,

Andreas Achilleos

kersing
Valued Contributor
Valued Contributor
Posts: 1873
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 530 times
Been thanked: 1040 times
Contact:

Re: analog input greater than 5V

Postby kersing » Tue Nov 24, 2015 7:11 pm

Have you considered using a resistor divider? Connect your input to 400K resistor (R1). Connect other side of R1 to analog input of PIC and to 100K resistor (R2). Connect second side of R2 to ground. Connect ground of input with ground of circuit.

The voltage at the analog input should be Vin * 100K / (100K + 400K) = Vin * 1/5 = Vin / 5. So for input 25V the output voltage would be 5V.

Make sure to use high quality metal film resistors with 1% tolerance for these kind of circuits. Total cost should be < 1 euro.
These users thanked the author kersing for the post:
achillis1 (Tue Nov 24, 2015 9:41 pm)
Rating: 5.26%
 
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

EtsDriver
Valued Contributor
Valued Contributor
Posts: 413
Joined: Tue Apr 15, 2014 4:19 pm
Location: Kajaani, Finland
Has thanked: 328 times
Been thanked: 211 times
Contact:

Re: analog input greater than 5V

Postby EtsDriver » Tue Nov 24, 2015 7:59 pm

kersing wrote:Have you considered using a resistor divider? Connect your input to 400K resistor (R1). Connect other side of R1 to analog input of PIC and to 100K resistor (R2). Connect second side of R2 to ground. Connect ground of input with ground of circuit.

The voltage at the analog input should be Vin * 100K / (100K + 400K) = Vin * 1/5 = Vin / 5. So for input 25V the output voltage would be 5V.

Make sure to use high quality metal film resistors with 1% tolerance for these kind of circuits. Total cost should be < 1 euro.


If using that, i would add 6Volt zener to the input signal to protect the PIC, or use a optocoupler circuitry to be safe side.

stevenvh@electronics.stackexchange.com wrote:Best is to use an optocoupler to detect zero-crossings. Put the mains voltage via high resistance resistors (R1, R2) to the input of the optocoupler. Vishay's SFH6206 has two LEDs in anti-parallel, so it works over the full cycle of the mains voltage.

Image

If the input voltage is high enough the output transistor is switched on, and the collector is at a low level. Around the zero crossing, however, the input voltage is too low to activate the output transistor and its collector will be pulled high. So you get a positive pulse at every zero crossing. The pulse width depends on the LEDs' current. Never mind if it's more than 10% duty cycle (1ms at 50Hz). It will be symmetrical about the actual zero-crossing, so the exact point is in the middle of the pulse.

To detect power outages you (re)start a timer on every zero-crossing, with a timeout at 2.5 half cycles. Best practice is to let the pulse generate an interrupt. As long as the power is present the timer will be restarted every half cycle and never time out. Upon a power outage however, it will timeout after a bit longer than a cycle, and you can take the appropriate action. (The timeout value is longer than 2 half cycles, so that a spike on 1 zero-crossing causing a missed pulse won't give you a false warning.)
If you create a software timer it won't cost you anything, but you can also use a retriggerable monostable multivibrator (MMV), for instance with an LM555.


Source
These users thanked the author EtsDriver for the post:
achillis1 (Tue Nov 24, 2015 9:41 pm)
Rating: 5.26%
 
Ill just keep the good work up!

kersing
Valued Contributor
Valued Contributor
Posts: 1873
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 530 times
Been thanked: 1040 times
Contact:

Re: analog input greater than 5V

Postby kersing » Tue Nov 24, 2015 8:25 pm

Opto coupler only works to detect a voltage, not the level of it. Adding the zener is sensible for AC. So the question is, is the input 0-25V or an AC signal which means signal levels -25V - 25V??
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3450 times
Contact:

Re: analog input greater than 5V

Postby medelec35 » Tue Nov 24, 2015 10:47 pm

I would personally go down the path kersing has suggested.
Since ADC takes little current, if values are high enough then that would be protection alone.
I'm assuming the mention of zener is to clamp the peak voltage present at ADC?
The values of resistors mentioned will negate zener requirement (espically if using 400K for R1)
The input can be 50V + and still not cause any issues so long as input protection diode current is not exceeded.

Martin
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
achillis1
Posts: 347
Joined: Thu Oct 09, 2008 9:19 am
Has thanked: 92 times
Been thanked: 8 times
Contact:

Re: analog input greater than 5V

Postby achillis1 » Fri Nov 27, 2015 8:02 pm

Hello,

Thank you for replying!

@Kersing

Supposedly, the input will be up to 25V maybe sine wave but this t is the case:

An inductor will be operating at 100kHz pulses of DC ( as I have read about )*see schematic concerning the DC pulses or AC, then a second receiver inductor will pick up the electromagnetic waves from transmitter and then will send it to PIC at analog input.

*If the pulses are derived from DC voltage; then the back EMF created when the DC power switches off will be negative? SO the receiving signal will be -x to +x volts? -

Thank you!
Attachments
loop.gif
loop.gif (21.48 KiB) Viewed 7365 times

mossine
Posts: 35
Joined: Mon Jun 17, 2013 2:09 am
Has thanked: 12 times
Been thanked: 5 times
Contact:

Re: analog input greater than 5V

Postby mossine » Wed May 11, 2016 1:55 am

hi everyone
î hope this example show you who to use the divider resistor its the best solution .
i use as diveder : R1= 14Kohm .. R2=10Kohm ; you can use other suitable
use : Vbat =15V . Vin = analoginput = 5Vmax .
Vin=R2(Vbat)/(R1+R2)
and for the millivolt or microvolt use the amplificateur operationnel
Attachments
analog input 12volt .rar
(29.41 KiB) Downloaded 217 times
These users thanked the author mossine for the post:
achillis1 (Mon Feb 20, 2017 4:27 pm)
Rating: 5.26%
 

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1086
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 440 times
Been thanked: 492 times
Contact:

Re: analog input greater than 5V

Postby Steve001 » Wed May 11, 2016 12:47 pm

These users thanked the author Steve001 for the post:
LeighM (Wed May 11, 2016 1:11 pm)
Rating: 5.26%
 
Success always occurs in private and failure in full view.