How to convert logic level ? - Page 1
Forum section: electronics / projects

author: Jan Audio
author_rank: Frequent Contributor
timestamp: December 21, 2018, 04:31:04 pm
content: Hi, i have digital logic levels on : around 12 volt, off : around 6 volt.The levels are somewhat varying in level, there is a clear on and off state, anough space in between.How do i convert this into a clean 0 to 5 volt logic level ?thanks in advance

author: IDEngineer
author_rank: Super Contributor
timestamp: December 21, 2018, 05:26:49 pm
content: Having no more information about your circuit or situation than two "logic" levels, my first thought is to use an open-collector digital comparator and set the threshold midway between your two levels. Put a pullup on its OC output to whatever high output voltage you need.More info about your system might yield a better suggestion!

author: SiliconWizard
author_rank: Super Contributor
timestamp: December 21, 2018, 07:55:40 pm
content: A very simple way of avoiding the use of an high-voltage opamp with an open-drain output would be to put a resistor divider before the comparator to scale your 6V-12V signal down to 2.5V-5V. Then use any comparator fast enough for your requirements, powered at 5V, and set some hysteresis for added robustness, with the two thresholds at something like 3.25V and 4.25V for instance.We don't know about your speed requirements or if you need to discriminate a low level (~6V) from the absence of signal (<< 6V).The above approach will work fine unless you need very high speed switching (the resistor divider will act as a low-pass filter with the input capacitance). For the second point, you could always add a second comparator.

author: IDEngineer
author_rank: Super Contributor
timestamp: December 21, 2018, 09:00:43 pm
content: I didn't say opamp, opamps are a poor choice for a comparator particularly if the signals have slow slew rates (though we don't know much about the OP's environment, as I mentioned in my original response). I saidcomparator, as in (for example) the very common LM339/2901 family. Runs on single supplies from 3-36V so immediately compatible with what the OP described, open collector output so he can set whatever output high voltage is desired, available from multiple manufacturers in a variety of packages both SMT and throughhole, and costs ~20 cents even in low quantities. Given that he said:Quote...I felt the ease of adding hysteresis with a comparator such as the LM339/2901 would be a good idea.I considered a resistor divider but again, given that we don't know much about OP's low/grey/high "levels" it's hard to know that a given divider ratio would work reliably in all of the so-called "varying" conditions. A comparator avoids all of that and makes adding hysteresis easy to accommodate his "varying levels" for more reliable operation. All for under a quarter USD including the necessary discretes.

author: soldar
author_rank: Super Contributor
timestamp: December 21, 2018, 09:34:15 pm
content: You can try something like this. It should convert 6-12 V to 5-0.3 V. (It inverts the input.)

author: Jan Audio
author_rank: Frequent Contributor
timestamp: December 22, 2018, 03:03:42 pm
content: Ah nice with schematic, i will try it, thanks.Also 1 transistor is nice.I have this audio sawtooth VCO that goes into a opamp comparator to create a pulse signal, i want to have it on 5 volt so i can adjust volume with 1 transistor.