I'm trying to build a level shifter from 5V to 24V. An Atmega 328 MCU digital output is to switch on a 24V signal that will be connected to an external component's digital input that uses industrial standard 24V.
When a digital output on the MCU goes High, I want the 24V signal to be high as well.
I've tried to make a circuit for this in proteus. See attachment. Is this an OK solution? I noticed that when the button (to the left in attached image) is open, the MOSFET to the right lets current flow through. The MCU will be on batteries so I want it to be energy efficient, so having current flow through at all time is not wanted.
The digital output will probably only be high for maybe 10-15 minutes per day.
If the second FET is a p-channel high-side switch, current only need flow when the output is high. The first
FET level shifts, the second acts as high side switch.
When a digital output on the MCU goes High, I want the 24V signal to be high as well.
No need, that is what software is for.
What are you trying to power with this? On your circuit all the current on the output must be drawn through a 1K resistor so you will get 1V drop for every mA you draw. That is why the others are suggesting top switching with a p-channel FET.
Grumpy_Mike:
No need, that is what software is for.
What are you trying to power with this? On your circuit all the current on the output must be drawn through a 1K resistor so you will get 1V drop for every mA you draw. That is why the others are suggesting top switching with a p-channel FET.
Hi,
The 24V signal is going to a frequency drive's digital input that is driving a 230V AC motor. For safety reasons I don't want the signal to be inverted in the case of failure of the MCU, or loss of power to MCU. Then the signal goes low out of the MCU, and it will then then send a 24V signal to start the motor.
It looks like a solution like mentioned above would work for my design. I'll have a look at this soon.
Regarding the P-Mosfet; My guess is the 24V current needed to start your motor is not very high. I would look for a P Mosfet that is easy to get and if hand soldering has leads. Likely at TO-220 case. The P Mosfet in a TO-220 case is probably overkill but is likely to be the most common.
REVISED With R4 in its previous location one could loose ~9% of the gate voltage, with low voltage processors this would not be the optimum case.
For safety reasons I don't want the signal to be inverted in the case of failure of the MCU, or loss of power to MCU. Then the signal goes low out of the MCU, and it will then then send a 24V signal to start the motor.
I did reliability and systems failure for a job. While you might think that a low output is the most likely failure mode it is not the case. An output can as easily fail high as fail low. If you are serious about the safety aspect I would recommend powering everything from one power source. That reduces the chances of one part of the system being powered while the other is not.
You should know the predominant failure mode for a MosFet is shorted. However current MosFets are pretty tough.
I'm assuming your goal for the failure mode is "good design practice" and not a real safety hazard. If this is not the case the output section needs to be revised so the output goes off is the mcu stops working.
Regarding the P-Mosfet; My guess is the 24V current needed to start your motor is not very high. I would look for a P Mosfet that is easy to get and if hand soldering has leads. Likely at TO-220 case. The P Mosfet in a TO-220 case is probably overkill but is likely to be the most common.
REVISED With R4 in its previous location one could loose ~9% of the gate voltage, with low voltage processors this would not be the optimum case.
Looks good! I've seen other circuits that uses a zener diode to drop the voltage from 24V to the desired voltage to the gate of the PFET. Do you know if theres a reason for this, rather than using a common voltage devider, as you have in your circuit?
Also, if the PFET fails short, do anyone have a clever way of making the output go to 0V?
EDIT: I can think of one way. Use one digital input of the atmega to monitor the voltage after the PFET. If it is high, when it should not, shut down the 24V supply with another FET near the 24V supply.
The goal is to keep the gate of the MosFet gate at a voltage where it will be turned on fully but not exceed say 80% of the max gate voltage. A typical MosFEt is on full if the gate is at 10 V and the maximum gate voltage is usually around 20V.
So you could use a 12V zener from the MosFet Source to Gate, but still need R1 to make sure theFET1 goes off. Or you could just select resistors that result in 12V on the gate.
Failure Mode:
It could help to know how important failing with the control line low, is. Also, do you know how much current the control line requires?
It could help to know how important failing with the control line low, is. Also, do you know how much current the control line requires?
The frequency drive draws no more than 10 mA on its digital input. Probably less. I've sent an e-mail to the suppliers to get a better answer.
If something fails, it would not be good if the motor started and kept running until power was disconnected manually. Sometimes the motor could be kept in small containers with little air circulation, which I will discourage btw. Worst case then is fire. In the end, I will not be the user of this, so where it is placed is not my decision.
Controlling failure modes has to be done carefully else you make things worse.
In my experience MosFets are not the weak point in a system.
I would rank failures in the following order: (I'm sure there will be other opinions but this is my experience).
Connections
Software "glitch"
Any component that is near or over it's limit
Corrosion
Any component that is cycled hot / cold because of load. i.e. a MosFet or Transistor that heats up in use that repeatedly is heated and allowed to cool (thermal stress).
ESD related failures either spurious or permanent
Components within their normal rating.
I would consider your suggestion to allow the processor to disable the 24V if it senses the output is "stuck" on for any reason.
I would also consider AC coupling the output stage from the processor. So if the processor stops running the output stage would turn off. A watch dog timer could help here as well.