Go Down

Topic: [SOLVED] How to build level shifter 3.3v to 24v (Read 18001 times) previous topic - next topic

Koepel

#15
Nov 14, 2015, 12:11 am Last Edit: Nov 14, 2015, 12:14 am by Koepel
A comparator is not an OpAmp.

I think it is simple because there are less parts.
You need to power it with 24V to VCC and the output will be 24V or 0V (or some less than 24V and some above 0V).
You have to make the reference voltage with two resistors from a fixed voltage (the 24V or 5V). You might even use a zener diode or three normal diodes (3 * 0.6V forward voltage = 1.8V) as reference.

Hmm, the LM339 / LM393 are open collector output. I can't find comparators with normal output that are common.
The sink current is 16mA, and minimal 6mA. That is not a lot.
Assuming 10mA, then the lowest resistor with 24V is 2k4. We make that 2k2 for a maximum current of 11mA.
The 2k2 to 24V to the input of the XD26 results into a voltage divider with the input impedance of 7.4k.
2k2 and 7.2k makes 18.5V. That will work, but it is not nice.

Here are pictures : https://blog.adafruit.com/2012/06/11/ask-an-educator-how-can-i-convert-an-analog-value-to-a-digital-one/
Note that VDD is the 24V.

If you send the 3.3V signal via the cable, then you could use the circuit with feedback for a Schmitt-Trigger effect.
For example with R3=75k, R1=1k8, R2=22k, then the output turns low when the voltage is below 1.2V, and high when the voltage is above 2.3V. That will filter out noise of 1Vtt.
The pullup resistor R4 is 2k2 as I calculated above.

I think the ULN2803 can also be used. It is 8 open collector relay drivers in a chip. You need to add an inverter chip.
The TLP250 is a isolated gate driver or optodriver chip. That is such a fancy chip that I might have somewhere in a box. The TLP250 needs 10mA at the input, but there are chips that need only 1mA.

jack wp

#16
Nov 14, 2015, 12:41 am Last Edit: Nov 14, 2015, 12:52 am by jack wp
Is your 3v3 input a floating voltage, or is it off at less than 0.5v, and on at over 3v ?
Is it a digital signal (on / off), or an analog signal ?

Is this just a level shifter, or is it a driver? What is it feeding into, an IC, or a load ?



footswitch

#17
Nov 14, 2015, 01:29 am Last Edit: Nov 14, 2015, 01:31 am by footswitch
Is your 3v3 input a floating voltage, or is it off at less than 0.5v, and on at over 3v ?
Is it a digital signal (on / off), or an analog signal ?
The motion sensor outputs a digital signal, either 0V or 3.3V.
I want to take that low-voltage digital signal into some circuitry, and with the help of a 24V line, have an output of 24V when the original signal is HIGH, and 0V when the signal is low.
Is this just a level shifter, or is it a driver? What is it feeding into, an IC, or a load ?
It sounds like what I want is a level shifter. It will go into a 24V input with ~7k impedance.

runaway_pancake

Should be able to work the Philips recommended I2C level converter circuit this way.
"Who is like unto the beast? who is able to make war with him?"
When all else fails, check your wiring!

CrossRoads

Simple 0/24V buffers:
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

footswitch

@Runaway Pancake, I think you meant "Should be able to work. Philips recommended...", but I find this comparison a bit confusing.


I think this topic needs some sort of closure. Or else I would have settled with my initial "investigation" :)

We concluded that the sensor can output up to about 3.x mA (because of the 1k resistor on its 3.3v output).
I think everyone agrees that this leaves the most common optocouplers out of the question, since they would require about 10~20mA to function reliably.

Moving forward.
As I gather, an open collector output can either be open (high impedance) or closed (tied to the emitter which would be GND). Is this correct?
So it stands to reason that any open collector needs to be provided with an arbitrary V+ through a resistor/load, just like a NPN BJT or N-channel FET does. Right?

Ok, so using a NPN transistor in this case, it would invert the logic, and thus require a PNP transistor to restore the logic.

Now, in the case of a comparator, if its output is also open collector, then it requires a pullup, and it would invert the logic; so the trick here (to NOT invert the logic) is connecting the 3.3v signal to the inverting input, and the voltage reference (1.7V) to the non-inverting input.
Just to be complete and aware of the implications, the circuit would draw about 10mA continuously while the output is LOW (which is most of the time).


The amount of searching and reading required to reach this reasoning...
Please tell me I'm right. But only if I am :)


If all is well, let's try to provide the forum with some answers:
- One solution is using a comparator. A good choice for this purpose would be the LM393-N, plus two or three parts (resistor pair/diode(s) for the voltage reference, and the pullup resistor on the output). Concern: 20 circuits like this would draw about 5W.
- If more output current is required (>15mA), and lower "idle current", the N-channel+P-channel FET pair would be best. Along with some resistors as well. In that case, the N-channel FET BS170 looks good for the job, however I can't find the adequate P-channel partner for it.

I'd like to verify these allegations with you guys if possible.
Both solutions are desirable to pursue, for verification and energy efficiency comparison.

Thanks.

CrossRoads

Can use two N-channel MOSFETs for next to 0mA current flow in the control section.
Add P-channel MOSFET and pulldown resistor for off condition.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

footswitch

@CrossRoads, your schematics are enlightening.
But it raises some questions.
I don't see how it's possible to have +24V on the gate.
Also the "low-current non-inverting buffer" has two N-channel MOSFETs? Couldn't I just do that "resistor to ground" with just one N-channel MOSFET then?
And what's wrong with the off condition, since the output is already pulled down?

It's very late here. I should revisit this tomorrow morning, with a fresh set of eyes.

Thanks

Archibald

Should be able to work the Philips recommended I2C level converter circuit this way.
The maximum value of pull-up resistor to 24V would be 4.3kΩ.  That's to ensure at least 15V in the high state with the input resistance of 7.4kΩ (to ground).  In the low state, the current through that resistor would be 5.6mA. With the 'Philips' level shifter circuit, the PIR circuit output is not capable of sinking that current via the MOSFET (according to data I have found on the PIR).  I therefore don't think such a level converter will work unless there are more components.

As shown by Koepel, a comparator would work, so too would a two-transistor non-inverting buffer.

For a transistor buffer, I would use NPN followed by PNP so the PNP transistor can give near rail-to-rail swing when connected to the 7.4kΩ input of the automation device.

I don't see much point using an optocoupler unless it is configured to give total isolation between the PIR and the automation device . . . . . which could be well worthwhile.


CrossRoads

Quote
It's very late here. I should revisit this tomorrow morning, with a fresh set of eyes.
Indeed, then you would see the difference between N-channel and P-channel, and recognize the pullup on the open-drain of the N-channel MOSFET.


Circuit as-is relies on 24V tolerant parts for Vgsf, which may or may not be available. I haven't looked.

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

CrossRoads

#25
Nov 14, 2015, 07:04 am Last Edit: Nov 14, 2015, 07:16 am by CrossRoads
I suppose a voltage divider to let the P-channel gate swing between 24V and 12V when the N-channel MOSFET was on would suffice.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

footswitch

Hi again,
I'm starting to get it. @CrossRoads, please forgive my confusion.
Had to read on the subject, and it took me a while... The secret was the little triangle next to the Gate, I didn't know before that's how you differ one from another... :)
How embarassing.

Let me tell you, I ran into some issues:
- First of all, the N-channel MOSFET is the BS170 which I think is just fine for this purpose. I have tested and confirmed that two N-channel FETs can do the trick (non-inverting output), but there's the disadvantage of energy (in)efficiency - the second MOSFET is on most of the time, sinking current.
- Couldn't find a P-channel MOSFET with TO-92 package or similar. So for now I'm stuck with BC557 PNP transistors. What worries me the most is something in the Datasheet: Emitter-Base Voltage --> Max. -5V.
- I wired a couple of test circuits, and things worked as expected, but I did this with every voltage source being 3.3v. I didn't risk connecting 24V just yet.
- Didn't know transistors were current driven, instead of voltage driven like MOSFETs. Somehow in this process I must have gotten lucky because there was no apparent overheating and no magic smoke :o

I suppose a voltage divider to let the P-channel gate swing between 24V and 12V when the N-channel MOSFET was on would suffice.
I'm afraid to blow up something because of that Emitter-Base Voltage limit on the PNP transistor, which I still don't quite understand...

What changes for a N-ch FET + PNP transistor combination, if I may ask?

Again... thanks.

CrossRoads

P-channel MOSFET, TO-92 and other thru hole packages:
http://www.digikey.com/product-search/en?pv69=80&FV=fff40015%2Cfff8007d&k=p-channel+mosfet&mnonly=0&newproducts=0&ColumnSort=0&page=1&stock=1&quantity=0&ptm=0&fid=0&pageSize=25
With PNP, you need to pull current from the base to turn it on, so the N-channel MOSFET is used to pull the base low to turn the PNP on.  IF Vbe is -5V Max, and you are driving 24V, then Vbase can't go below 19V to avoid damaging it.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

footswitch

Hi guys,
Just here to thank @CrossRoads and all the other participants, and report on my success :)

The PNP transistor didn't really suit the purpose. Not ideally anyway.
I finally found a local supplier for the BS250 P-channel MOSFET, and its specs are just what I need.

Attached is a photo with the working circuit.

Description:

Level Shifter using BS170+BS250
Features:
- Low-Current idle state
- Non-isolating (features don't always have to be good)
- Input voltage: 2-20Vdc (recommended 3-15V) limited by the BS170 MOSFET's Gate
- Output voltage: up to 45Vdc (recommended < 36V) limited by the BS250 MOSFET
- Output current: up to 180mA continuous @ 25 ºC (pulsed: 400mA, limited by temperature)

Again, thanks for your patience ;)

runaway_pancake

@Runaway Pancake, I think you meant "Should be able to work. Philips recommended...", but I find this comparison a bit confusing.

What I have written I have written.

"Who is like unto the beast? who is able to make war with him?"
When all else fails, check your wiring!

Go Up