Go Down

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

footswitch

Nov 09, 2015, 04:58 am Last Edit: Nov 18, 2015, 12:24 am by footswitch
Hi guys,

I've spent some time searching for a way to "shift" a 3.3v signal into 24v, but right now I'm overwhelmed (a.k.a. confused) with the information I found. Maybe someone can help me narrow down the solution.

Here's the situation.
Having some PIR motion sensors, Vcc (power input) is 24V, and their digital output being 3.3v,
I need to turn the output into a higher voltage, with the help of Vcc. Anything between 12~24V would do.
The current would be residual, just for signaling, but it's long distance so let's say 40mA to be on the safe side.
And without inverting the signal, this rules out an N-channel MOSFET / NPN BJT.
Power efficiency is somewhat important because this will be replicated a number of times throughout the house.
Packaging could be TO-92, SIP, or even DIP. TO-220 looks like overkill, but I'm open to suggestions.


From what I've read so far, my options are:
a )  Using a pair of FETs (n-channel + p-channel) and resistors. I couldn't figure out the adequate models, as there are so many out there... Also, can I find this solution in a single package? -- EDIT: To see the working circuit as proposed by CrossRoads, refer to post #28
b )  Maybe an optocoupler? Is is possible to NOT invert the signal with an opto?

Or maybe there are other solutions that I'm not aware of...


Thanks in advance.
Regards,
footswitch

MorganS

Yes, it's possible to make a non-inverting optocoupler circuit. It seems to be rare or non-existent in professional designs and I don't know why. All the examples I've seen invert the logic. I've built non-inverting circuits and they worked for me.

20V seems like a lot of voltage for a single optocoupler. But looking at a few datasheets, all of them go to 20V or more. So that's not a concern. Read your datasheets closely.

An optocoupler is an LED, so it needs 20mA or so to turn on fully. Can your application supply that current? An optocoupler has a "current transfer ratio" which is often a number like 200%, meaning the output current can never be more than double the input current. Your design needs to have a big margin because the CTR degrades over time (years.)

An ILD2 is a good middle-of-the-road optocoupler to start with. 70V max output voltage. They can be purchased in DIP-8 packages, so easy to test on a breadboard.
"The problem is in the code you didn't post."

footswitch

Hi @MorganS and thank you for your comment.
As I understand, in order to connect an opto without inverting the signal:
- Vcc goes directly into the collector (top);
- Place a resistor (10k?) between emitter (bottom) and ground;
- The signal can be "captured" between the emitter and the resistor.

Is it that simple?

Again, thanks for helping out.

JohnLincoln

Hi @MorganS and thank you for your comment.
As I understand, in order to connect an opto without inverting the signal:
- Vcc goes directly into the collector (top);
- Place a resistor (10k?) between emitter (bottom) and ground;
- The signal can be "captured" between the emitter and the resistor.

Is it that simple?

Again, thanks for helping out.
Yes, that is correct.

footswitch

Wow thanks @JohnLincoln.

I never thought it would be that simple.

I have a few VO617/618 optos (single opto in a DIP-4 package), so I'll read the documentation carefully and test them out.

DrAzzy

I'd be inclined to use an N-channel fet or NPN transistor to switch a P-channel mosfet. Note that you should have a resistor in series with the gate drive such that it will form a voltage divider with the gate pullup, and ensure that the voltage on the gate stays within the spec of the fet - often they're +/- 20V on gate, so you can't safely pull it all the way to ground.

If you use a fet, you need one that will work at 3.3v on gate, which is hard to find in through-hole Here's one: http://www.digikey.com/product-detail/en/5LN01SP-AC/5LN01SP-ACOSCT-ND/5213189
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

MarkT

Open-collector stage is how to do this, its the standard way to handle high voltage logic signals since
the receiving circuit can be whatever voltage you like within reason.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Koepel

I smell an XY-problem http://xyproblem.info/

footswitch, please tell us about your project.
Which PIR motions sensors are they ?
Are the PIR sensors already powered (with 24V) ?
Are you sure the output is 3.3V ? Is that a digital signal or an open collector output ?
What do you want to do with the PIR sensor outputs ?
How long are the cables ?

It seems that you need to signal a device that has as input a 12-24V signal. Then please tell us what device that is, so we can check if it needs indeed that input voltage.

Did you know that sending a signal over 1km cable is not necessary better when the voltage is increased. It depends on things like the impedance and the capacitive coupling of the cable and the terminators at the end.

footswitch

Hi guys,
Sorry but somehow I wasn't receiving notifications on this topic's activity.

I sometimes wonder myself if my questions are "xy problems".
And I try to make it simple so it doesn't get people bored just from reading the first post. Maybe others do this too, be it consciously or not.

Okay, let's lay all my assumptions on the table.
To transmit a signal over 40 meters, 5v won't do it, let alone 3.3v, at least not easily, and not with any cable.
The most simple reasons, I *think*, leaving out losses, impedance, capacitive coupling - I really don't know the theory - are the cable not being shielded, "cross-talk" with the other communication wires, generally the noise from AC cables near it, or EMF (I mean radio noise). Maybe all this counts as capacitive coupling, I wouldn't know. I think that's what you get when you try to learn things over the internet.

And then, a device can only go so far as to drive an output, being able to sustain it over distance, and unprotected from external hazards. This stresses the device, and stress is bad for your health.

Also, I was always led to believe that a higher voltage would be okay to work around distance/interference problems. Work around as in "not having to worry about solving" those issues at all.

The facts:
- There's a pair of wires with 15V and ground respectively, to feed all or each group of PIR motion sensors. The sensors can be powered with 5-20Vdc, and I thought 15V would be a good value to minimize the overall current over the cable.
- The sensor is provided already fitted in a PCB. It has quite a few components soldered in it.
- The output is indeed 3.3v, triggered whenever motion is detected. Maybe the sensor's internals are all 3.3v, I'm not sure, but it would make sense.
- These signals need to go into inputs on an automation device, which accepts signals from 10 to 30Vdc (the inputs are officially 24V in, but this tolerance is mentioned, and below 8V they're not guaranteed to read HIGH).

So I reasoned that I needed to up the voltage, and since I'm heading there, I might as well do it right next to the output.
Is this explanation any better?


Thanks for your help so far.

1. I did like the idea of using an optocoupler, and it looks simple enough.
2. Using two FETs and resistors... I never used small FETs so I'd need further help with model numbers and resistor values to make it work. Or a source to learn from. Or a comparison table of sorts.
3. @MarkT, open-collector stage - I hope this is the N-channel FET part that you're talking about, or else I'd need further explaining / practical example.
4. When I try to explain myself, it can take forever because English isn't my native language :)


Guys... I wish I'd just know where to start learning electronics.
Usually a search engine feeds me the information I need on a day-by-day basis. It doesn't teach a man to fish.
There's so much information repeated, scattered, and without proper foundations to work the way up.

Archibald

As we don't know what current the PIR output can drive, I suggest using a voltage comparator integrated circuit (or operational amplifier).  Connect the PIR output to its non-inverting input and connect the inverting input to a voltage divider giving about 1.7 volts.  (Check the comparator can supply the input current of the "automation device" in both high and low states.)

To transmit a signal over 40 meters, 5V won't do it, let alone 3.3V, at least not easily, and not with any cable.
As you are not transmitting a high speed digital signal, there's no problem transmitting over several kilometres.

What is the make and model of your PIR?

Koepel

I have to shake up your facts a little.

As Argibald wrote, 40 meters is not a very long able.
The voltage is not that important. You could easily transmit a few millivolts. So 5V or 3.3V is perfectly fine.
A lot depends on the cable. Is it twisted pair ? Tell us what cable it is, and what the other signals are in the cable.

That sensor runs internally on 3.3V. Which makes sense, because allmost all PIR sensors run at 3.3V (the 5V modules have a internal voltage regulator for 3.3V). There is probably a voltage regulator in your PIR sensor that accepts 5-20V. The higher the voltage, the more heat is wasted by the voltage regulator. It probably will not use a lot current, so there will be only very little losses in the cable. I think about 7 or 8V would be okay.

An optocoupler would be the best solution, as long as the output of the PIR sensor is capable to drive the led of the optocoupler. But we don't know that, so again I agree with Argibald: how much current can the PIR sensor drive ? what is the make and model of your PIR sensor ?
You can use a comparator (perhaps with a optocoupler behind it), but what if the output of the PIR sensor is open collector ?

What is the make and model of the automation device ? What if the input is a 20mA current input ?

MarkT

footswitch, you make erroneous assumptions about long distance signalling, for instance ethernet is 3.3V
and happily does 100m+ at a 125MHz bit rate and is completely unshielded.

LVDS can go upto a few metres at 300mV at GHz rates. Again unshielded.

Microwave signals can sent along coax for fairly long distance at 10's of GHz...  That is shielded though.

Impedance is everything for high speed signalling, voltage is much less important.  You would normally
use twisted pair or shielding (or both) and differential signalling (like ethernet, RS485, USB, firewire, LVDS)

Reliable signalling in harsh environments at low rates over any old cable is best done by current, not
voltage, for instance the 20mA current-loop standard and MIDI.

For very low datarates who cares about noise, you just low-pass filter at the receiving end and eliminate
the noise - at the expense of a few milliseconds delay.

The one situation where you will still have problems is if you run a signal wire alongside high current
wiring like mains or motor.  Don't do that.

And finally an observation that 40m of cable may be more expensive than two wireless modules.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

footswitch

Hi...
I always had problems with keeping a low-voltage signal stable over distance.
From what I've read, it acts as an antenna, and picks up a lot of noise.
The signal fluctuates a lot on the input.

Usually to reduce this effect I place a 100nF ceramic capacitor on the input, along with the pull-up/down resistor. Sometimes lowering the resistor value as well.
That's the only thing I ever did on that matter. It doesn't work as I wish it would. A short false positive and the lights turn on, or the alarm goes off.
I have absolutely no idea how a few milivolts can be transmitted reliably.
This is what I think: it must require some other design that I just don't know, and a proper cable.

From my experience, things easily go south when using the common 2-wire cable (non-twisted, non-shielded).
UTP cable is a bit better. - this is what I want to use...
For each cable, the remaining wires would be for power and 2 more identical sensors.
And parallel to this cable are unshielded cables with high-frequency PWM (around 2 amps @ 24V).

Ok I'm very interested in keeping a low-voltage signal stable over distance.
But that's for all the other projects.

The automation device here is a Crouzet M3 XD26 (Product no. 88970161).
And I screwed up on the specs. I had a datasheet for the wrong model. But the point stands:
Input HIGH: >= 15Vdc, up to 30Vdc
Input LOW: <= 5Vdc
Input impedance: 7.4 kOhm

The PIR motion sensors are mainly HC-SR501, some of them only say SR501.

Koepel

#13
Nov 13, 2015, 06:42 pm Last Edit: Nov 13, 2015, 06:43 pm by Koepel
Your Crouzet XD26 88970161 : http://www.crouzet.com/english/catalog/millenium-3-logic-controller-millenium-3-essential-expandable-range-with-display-xd26-Part%20number-88970161.htm
It costs 270 euros at Conrad.com
I suppose you have the 24V DC version, and the inputs must be 24V as well.

The HC-SR501 is for mostly for 5V (it runs internally at 3.3V), but it can handle higher supply voltages.
The output is a normal digital 3.3V signal, but it is weak (there is a 1k resistor to limit the current).

Okay, that is all clear now.

The output of the PIR sensor is weak. You need a logic gate, or a comparator. Then you have to make 24V out of it. That is possible with a optocoupler, but there are other options.
1 ) using two transistors.
2 ) a good old comparator.
3 ) using a chip for a relay / led / mosfet driver.
4 ) using a special chip to convert the signal.
5 ) using a fancy low input current opto-coupler with logic high voltage output.

There are many opto-couplers that are made for special things. I might even have a few somewhere. But I forgot what they are called, so I can't find them on the internet right now :(
A comparator at 24V is no problem, for example the LM339, LM393.

You could make an add-on board with comparators for the Crouzet automation device, and use the same 24V DC for the comparators. However the output of the PIR sensor is weak, I don't like to put that on a 40 meter cable.
If you have 24V at the PIR sensors, you could make modules with a PIR and a comparator with 24V output.

After all these posts, you initial thoughts seems to be right ;) (convert voltage, put high voltage on the cable). We had to know the details to get there.

footswitch

Thank you for your help so far.
Please excuse my ignorance, I never actually used a comparator / opamp.

1. Why would it be a good option?
Is it because the comparator's inputs are higher impedance / less capacitance than FETs?
More reliable?
Or simply because it'll be easier to connect overall (less parts)?

2. How should I connect the comparator for this purpose?
24V to Vcc?
The comparator's output would be either 24V or 0V?
What would I compare the sensor's 3.3v digital output to? I mean where would the Vref come from?

Too many questions I know  :smiley-confuse:

Go Up