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

Post Reply
User avatar
achillis1
Posts: 347
Joined: Thu Oct 09, 2008 9:19 am
Contact:

analog input greater than 5V

Post by achillis1 »

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: 1936
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Contact:

Re: analog input greater than 5V

Post by kersing »

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.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

EtsDriver
Valued Contributor
Valued Contributor
Posts: 438
Joined: Tue Apr 15, 2014 4:19 pm
Location: Kajaani, Finland
Contact:

Re: analog input greater than 5V

Post by EtsDriver »

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
Ill just keep the good work up!

kersing
Valued Contributor
Valued Contributor
Posts: 1936
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Contact:

Re: analog input greater than 5V

Post by kersing »

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: 8873
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: analog input greater than 5V

Post by medelec35 »

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
Contact:

Re: analog input greater than 5V

Post by achillis1 »

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 7857 times

mossine
Posts: 35
Joined: Mon Jun 17, 2013 2:09 am
Contact:

Re: analog input greater than 5V

Post by mossine »

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 237 times

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1142
Joined: Wed Dec 31, 2008 3:37 pm
Contact:

Re: analog input greater than 5V

Post by Steve001 »

Success always occurs in private and failure in full view.

Post Reply