Adafruit Industries, Essential service and business: NYC – Executive Order 202.6 - Read more. Accepting essential orders - here's how.
0

How to get 0V to 3.3V from -12V to 12V square wave
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

How to get 0V to 3.3V from -12V to 12V square wave

by thephilbot on Sat Nov 20, 2010 8:29 pm

Hi guys,

I am working on a project for senior design and I'm trying to figure out a circuit. Here's the description:

There is a square wave that goes from -12V to 12V. I get this from a comparator (LM339). I need to feed this signal into the inputs of a Parallax Propeller, and I want a signal that is 0V to 3.3V. As far as the positive peak, I can just use a simple voltage divider. Is there an equally easy way to get that -12V up to 0V?

So far I've tried using a second comparator, but I found that if the comparator has a negative voltage input below its low rail, it'll burn out the comparator so that won't work. I also have to worry about timing so using an op amp without feedback isn't going to work either.

If anyone has some clever ideas I am all ears and greatly appreciative. If I haven't been clear in my description, please let me know and I will provide any add'l info that'll help.

Thanks guys!


--Phil
thephilbot
 
Posts: 24
Joined: Sat Jan 13, 2007 8:42 pm

Re: How to get 0V to 3.3V from -12V to 12V square wave

by thephilbot on Sat Nov 20, 2010 9:23 pm

I just had a thought...would a simple half wave rectifier after the voltage divider do it? I'm thinking a 1N914.
thephilbot
 
Posts: 24
Joined: Sat Jan 13, 2007 8:42 pm

Re: How to get 0V to 3.3V from -12V to 12V square wave

by zener on Sat Nov 20, 2010 10:29 pm

Just to clarify, you have a square wave going from -12 to +12V and you want to convert it to a square wave that goes from 0 to 3.3V. Yes? So essentially a level shifter.

If so, something like this should work:

http://www.onsemi.com/pub_link/Collater ... 504B-D.PDF

You just need a reverse biased diode to ground on the input to keep from going below ground. And maybe a small series resistor if the output impedance of the source signal is very low.

zener
 
Posts: 4567
Joined: Sat Feb 21, 2009 2:38 am

Re: How to get 0V to 3.3V from -12V to 12V square wave

by thephilbot on Sat Nov 20, 2010 11:32 pm

Zener wrote:Just to clarify, you have a square wave going from -12 to +12V and you want to convert it to a square wave that goes from 0 to 3.3V.


Yes, exactly what you described.

I'll check out the level shifter you linked to.
thephilbot
 
Posts: 24
Joined: Sat Jan 13, 2007 8:42 pm

Re: How to get 0V to 3.3V from -12V to 12V square wave

by stinkbutt on Sun Nov 21, 2010 1:53 am

Zener wrote:Just to clarify, you have a square wave going from -12 to +12V and you want to convert it to a square wave that goes from 0 to 3.3V. Yes? So essentially a level shifter.

If so, something like this should work:

http://www.onsemi.com/pub_link/Collater ... 504B-D.PDF

You just need a reverse biased diode to ground on the input to keep from going below ground. And maybe a small series resistor if the output impedance of the source signal is very low.


It looks as if the level shifter's already got a pair of reverse biased bypass diodes built in.
Red M&M, Blue M&M: They all wind up the same color

stinkbutt
 
Posts: 593
Joined: Wed Feb 17, 2010 2:40 am

Re: How to get 0V to 3.3V from -12V to 12V square wave

by jcarroll on Sun Nov 21, 2010 6:17 pm

You haven't really told us much about the application. Does the phase have to be maintained?Is there a common ground or other reference between the +- 12 and the microcontroller? Either way, particularly if there is just one channel, use a four pin opto isolator. Protect the input with another diode to prevent excessive reverse voltage to the input and be done with it.

jc
jcarroll
 
Posts: 11
Joined: Tue Oct 12, 2010 10:02 pm

Re: How to get 0V to 3.3V from -12V to 12V square wave

by zener on Sun Nov 21, 2010 6:34 pm

Optocoupler is a good idea. Another angle is that the LM339 is open collector, so there could be an opportunity to pull up to 3V instead of 12V. Depends if anything else in the circuit needs the +12V.

zener
 
Posts: 4567
Joined: Sat Feb 21, 2009 2:38 am

Re: How to get 0V to 3.3V from -12V to 12V square wave

by oPossum on Sun Nov 21, 2010 6:43 pm

Remove the pull-up resistor to 12V that you currently have, and do this...

Image
I am the Possum, and I approve of this message. Sent from MacBook Wheel Sorry for my bad German.
oPossum
 
Posts: 636
Joined: Fri Oct 26, 2007 12:42 am
Location: Michigan, USA

Re: How to get 0V to 3.3V from -12V to 12V square wave

by adafruit on Tue Nov 23, 2010 4:14 pm

you can also use a single ~3.6V zener diode and 4.7K resistor

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

Re: How to get 0V to 3.3V from -12V to 12V square wave

by zener on Tue Nov 23, 2010 8:25 pm

adafruit wrote:you can also use a single ~3.6V zener diode and 4.7K resistor

How would that be hooked up?

zener
 
Posts: 4567
Joined: Sat Feb 21, 2009 2:38 am

Re: How to get 0V to 3.3V from -12V to 12V square wave

by roberts on Tue Nov 23, 2010 8:40 pm

Zener wrote:
adafruit wrote:you can also use a single ~3.6V zener diode and 4.7K resistor

How would that be hooked up?


This might help you:
http://upload.wikimedia.org/wikipedia/c ... or.svg.png

roberts
 
Posts: 4
Joined: Tue Nov 23, 2010 7:37 pm

Re: How to get 0V to 3.3V from -12V to 12V square wave

by adafruit on Tue Nov 23, 2010 10:03 pm

thats a nice svg :)

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

Re: How to get 0V to 3.3V from -12V to 12V square wave

by stinkbutt on Wed Nov 24, 2010 12:43 am

Are you looking at his SVG? Stop looking at his SVG! SVG Looker! Cheeky Monkey!

The Zener-resistor divider has the advantage of not requiring a 3V supply already established, as for converting the -12V to 0, you could use a shunt diode to -

Wait... I just realized, the Zener divider would do that as well. The negative voltage gets shunted from ground, just reverse the arrows on this:

Image

Shit, that IS a good answer. A DAMN good answer.
Red M&M, Blue M&M: They all wind up the same color

stinkbutt
 
Posts: 593
Joined: Wed Feb 17, 2010 2:40 am

Re: How to get 0V to 3.3V from -12V to 12V square wave

by zener on Wed Nov 24, 2010 3:14 am

Not bad...

But the tolerances on zeners aren't too good, and you will also be a diode drop below ground on the output, so I would put some series resistance between the cathode and the output of that circuit, in the upper right area of the drawring there...

zener
 
Posts: 4567
Joined: Sat Feb 21, 2009 2:38 am

Re: How to get 0V to 3.3V from -12V to 12V square wave

by oPossum on Wed Nov 24, 2010 10:11 am

Consider the cost of a Zener.
Consider the availability of a Zener.
Consider the specs of the micro. It is quite common for 3.3V part the require inputs to be +/- 300mV from supply, not +/- 700 like 5V parts.
Consider the speed of the circuit. A Zener has significant capacitance. This combined with a resistor will case slow edges.
Consider the power off, power up, power down and brownout characteristics. A Zener will not clamp to the rails.

Overall, a Zener is a rather poor choice. Use two Schottky diodes to the rails if you really want a clamp on the input.
I am the Possum, and I approve of this message. Sent from MacBook Wheel Sorry for my bad German.
oPossum
 
Posts: 636
Joined: Fri Oct 26, 2007 12:42 am
Location: Michigan, USA

Please be positive and constructive with your questions and comments.