Variable Input Voltage

Go To Last Post
19 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Everyone,

 

I am working on a project that I need to switch one of the IO Pins from a voltage range from 9V to 32V. It is for an automotive project that could be fitted to a 12V or 24V vehicle.

 

I have tried using a simple voltage divider circuit but at 9V there is only about 1V at 20mA on the input pin. If I change the resistor values to get a higher voltage at the 9V input, the current then increases at 32V beyond what I would think is acceptable.

 

Is there another way this could be achieved?

 

Any help would be much appreciated.

 

Regards,

 

Craig 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is there another way this could be achieved?

Lots of possible approaches.

Building 1 or 1000 devices?

 

One option, if the pin is available, is to use the ADC to read the voltage.

Then, although the actual voltage varies, you don't need to meet digital input Hi and Low voltage criteria, as you are simply measuring the voltage, (scaled by some factor).

 

Another easy option is to replace the lower resistor of a two resistor voltage divider with two red LEDs, stacked up in series.

Vcc to Resistor to LED#1 to LED#2 to Ground.

 

You feed the voltage at the junction of the top resistor, and the LEDs to the I/O pin.

 

If, for example, you had a red LED with a forward voltage drop of 2.1 V, the if both LEDs, in series, are conducting, the voltage drop will be 4.2 V across the two of them, for a valid logic high.

You select the resistor so that the current is within spec for the LEDs at the higher voltage, 32 V.

Say you were OK with a current of 10 mA:

R = V/I  -->  (32-4.2)/10m = 2.78 Kohms

 

At 9 Volts input one would have:

I = V/R --> (9-4.2)/2.78K = 1.7 mA

 

The LEDs will light up nicely at 32 V, and very dimly at 9V, but you don't care.

You are using them for their (relatively) fixed forward voltage drop, and wide allowable current range.

 

You might need to put a 10K resistor across the two LEDs, as a pull down for when the LEDs are not forward biased, (that will require some thought as to whether or not it is needed in a noisy vehicle environment).

 

A zener diode could also be used, but you are likely to have a couple RED LEDs in your parts bin.

 

Good luck with your project.

 

JC

 

Edit:

Since you mentioned operation on a vehicle, I'll mention that you ought to Google "Load Dump" for information on the large voltage spikes that can be seen on a vehicle's power bus.

Vehicle operations are a harsh environment, electrically, thermally, and vibration wise!

 

JC

 

Last Edited: Mon. May 15, 2017 - 12:49 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

cwilson wrote:
I need to switch one of the IO Pins from a voltage range from 9V to 32V. I

 

HUH?  Care to elaborate on that?  What PIN?  a Microcontroller?

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks very much JC, 

 

Are you talking something like this? I will probably have limited board space so looking for something not too over the top. 

Regards,

 

Craig

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes one of the IO pins on an AVR Micro. 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

cwilson wrote:
Yes one of the IO pins on an AVR Micro.

 

The circuit you have posted in #4 would work just fine as long as you do not exceed the maximum reverse current of the zener.  The AVR does not need a lot of input current so  the 2.7k is just fine.

 

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is this voltage going to be basically on or off, or will it be a high speed PWM signal?

 

If it will be a slow, turn it on or off signal, you should probably add a 0.1 uF cap across the 10K resistor, also.

This, with the 2.7K, will form a LPF.

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes it will be either ON or OFF, supplied from a switch of some sort. 

 

Thanks very much for you help, it's much appreciated. 

 

Regards,

 

Craig

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Craig,

 

With your either on or off situation I would simply use an optocoupler.

 

Cheers,

 

Ross

Ross McKenzie, Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

valusoft wrote:
With your either on or off situation I would simply use an optocoupler.

+1.  And you'll be protecting your microcontroller pin from the real-world signal.

 

1/0 logic high/low from 12/24VDC should be very practical with a single "tuning" resistor on the input.  [not so much with e.g. 24VDC and 120VAC "universal" signal]

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I guess it all boils down to costs......

 

the OP mentions that the device could go into a vehicle that runs on 12 or 24vdc.  This to me indicates possible production of more than a one time party.

 

Opto's are expensive in comparison to some resistors and a zener diode.  Maybe the OP can live with a few field failures.

 

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch wrote:
protecting your microcontroller pin from the real-world signal.

And note that "real world signals" - even on a 12V vehicle - can greatly exceed 32V!

 

surprise

 

google "load dump" ...

 

EDIT

 

eg, http://www.electronicdesign.com/...

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Mon. May 15, 2017 - 02:43 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

jgmdesign wrote:
Opto's are expensive in comparison to some resistors and a zener diode. Maybe the OP can live with a few field failures.

Perhaps, probably.  The PS2705 that we often use are about $0.50 in qty. 100; maybe 60% of that in 1000.  And I grabbed a typical circuit of ours, which has 5 resistors and 2 caps also.  Zeners might be $0.20 in 100 and half that at 1000.

 

Re field failure -- you decide.  The 'Freaks had a very thorough investigation/discussion on automotive design in the datalogger series.  (Chancy99?)  There is a lot to it.  Is your zener going to be fast enough when a load-dump happens and the nominal V is multiplied?  How much current is going through that zener?

 

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not arguing any of it.  I am just thinking back to the days of car alarms I used to install.  I opened one up and was surprised at how little protection they used, yet when installed properly how reliable they were.  Inputs were nothing more than an NPN transistor - emitter grounded and two base resistors.  Same for outputs driving heavy relays for ignition and starter interrupt.

 

Ok, nostalgia trip over.

 

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks guys for the added input. Yes will be building in excess of 100 units initially. I have read up on load dump and ran a simulation on Falstad.com with inputting up to 100V DC. 

 

Here is the readings.

 

 

I was planning on using a 0.5W resistor and Zener. The resistor is of most concern at the higher voltage spike I think. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You might want to chose your resistor carefully in order to survive an overload. Or use a number of resistors in series to spread the load.
You might want to think about reducing the input impedance so you don't sense a false state due to coupling.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks very much for your help Kartman. With reducing the input impedance you mean the pull-down resistor in parallel with the Zener?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes. Maybe add a series resistor to the capacitor to form a rc filter as well.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 with inputting up to 100V DC. 

 

Make sure your also consider the possibility of some negative voltage spikes.

 

JC