Failsafe- 50% max PWM

Edit - I found a 24v pump as an alternative to the 220v pump. Discussion of 220v below can be ignored.

============================================================

I want to produce a 220V square wave at 50hz with a varying duty cycle from 0% to 50%.

I feel it would be a good idea to have a hardware failsafe in case the arduino ever loses it's way and produces a constant Ground output or any similar out of spec output. I have produced the following circuit that appears to prevent any pulse longer than about 15mS in simulation.

Logic-mosfet-drive.jpg

(PDF is a clearer picture)

I don't think the circuit looks "elegant" and I would like to know if there is a low part count and cheap
alternative that would do the job better.

Logic-mosfet-drive.jpg

Logic-mosfet-drive.pdf (41.4 KB)

I personally would like to see an opto coupler somewhere, get rid of the intermediate 12 power volt source and switch the 220volt load on the high side. What is the problem with "constant ground" output from the Arduino. Does that not fit with the 0% of the 0-50% duty cycle ? I understand not wanting to exceed 50%, though. What happens if the 5v supply in you circuit fails ? I am, however, hesitant to make more concrete suggestions for any such high voltage developments.

My concern with your circuit is you have a time constant at the base of Q1, which means it will not turn on and off quickly, which in turn means the voltage on the gate of Q2 will not change quickly, which in turn means it will not rapidly change between conducting and not conducting, which will, probably, result in it dissipating a lot of power and getting hot. The output waveform at J1 will probably not be very sharp either. Have you considered this and tested for it?

You need something that cleans up the signal after the capacitor, something with positive feedback, for example a Schmitt Trigger.

What is your experience with working with HVDC? It can be nasty…

6v6gt

I did think of pulling up the BJT from 12v but this is an automotive environment so that 12v will vary up to 14.5v while the 5v will be regulated. (also the 220v will probably be 265v because of the 14.5v source)

(edit) - Also, the 220v inverter is enabled from the arduino. If the 5v is dead, there will be no 220v.

PerryBebbington

During normal operation the capacitor has no effect. The turn on and off at the mosfet gate will be sharp. If the arduino ground output is longer than about 15mS, the mosfet gate will turn off slowly one time and stay off. I do wish the failsafe cutoff was sharper but it should not be repetitive.

If for some reason the arduino switches to a 25hz or worse output, the whole thing will probably burn down. But that should be an unlikely situation since 50hz turn off will be hard coded while the duty cycle turn on will be variable.

The 220v supply is a small 150w rectified inverter from 12v. Still dangerous but only mildly.

The 220v PWM output will only feed a short run to a vibratory pump. The entire 220v circuit from inverter to pump is inside one grounded box.

(second edit) - the failsafe is not meant to protect from some programmatically repetitive failure, it is more to protect from a locked up arduino in a ground output state. I will write several sanity checks into the program to protect from a bad PWM output.

The 220v supply is a small 150w rectified inverter from 12v. Still dangerous but only mildly.

Do you mean an inverter with a 220VAC output? After rectification and smoothing the voltage will be arround 300VDC.

As for 'mildly dangerous', that seems like an oxymoron. Maybe you will only be mildly dead if it gets you.

The inverter output is a 220v square wave at 40khz rectified to 220vdc. I have not tested it with a 14.5v input but I doubt it is regulated down to 12v before multiplying up to 220v so I will assume it will be about 265vdc in use.

Anything can be dangerous, we just have to be aware and responsible.

C1 makes the thing work. What is the purpose of D4? Herb

When the arduino is outputting 5v, the capacitor will be charged. Then when the arduino switches to ground, the capacitor will have no current limiting resistor towards the arduino. The D4 diode prevents the capacitor from accumulating a charge in that direction.

I do not know if the diode is absolutely required but it seemed to me it was needed.

I found an alternative version of the 220v pump that runs on 24v. Everything else remains the same and I still want a failsafe to prevent a locked up arduino from causing constant current through the pump. The pump is designed for ac and it will overheat if not protected.

Also while I looked over some links for schmitt triggers, I realized that I could sharpen up the turn-off transient with just an additional transistor. I came up with the following circuit which seems a little cleaner but I would still like to know if there is a cheap and low part count alternative that will do the job better.

logic-mosfet-noninverting-24v.png

(PDF is a clearer picture)

Both this non-inverting circuit and the inverting circuit above have no effect up to around 75% duty cycle and then hold at 75% output up to an input of around 85% at which point the circuit does not recover during the off phase and the output duty cycle shrinks below 50% as the input duty cycle gets larger. This is not really a problem since the input is not supposed to ever exceed 50%.

logic-mosfet-noninverting-24v.pdf (39.7 KB)

logic-mosfet-noninverting-24v.png

I am not very familiar with 555 timers but I think the following circuit might be more reliable? It's not much more complicated and although it's about twice as expensive, it's still under a dollar.

mosfet-555.png

(PDF is clearer)

Anyone want to comment on the relative merits of these circuits or suggest an alternative?

mosfet-555.pdf (44.4 KB)

mosfet-555.png

Oops, I just realized I got it backwards. The above 555 circuit will only allow a minimum 50% duty cycle because of the inverting transistor Q2.

I originally thought I would power the 555 from the arduino 5V regulator but i would like to keep any current load on the arduino to a minimum. Since I was supplying the arduino with 7v from a buck converter, I could supply the 555 from the buck converter and raise the buck voltage to 10v.

Then I could drive the mosfet gate directly from the 555 and the above circuit would be ok if R2 and Q2 are deleted.

Is that a good idea?

edit - also drop the 18v zener and the gate connection to 24v.

mosfet-555-2.png

mosfet-555-2.pdf (41.3 KB)

mosfet-555-2.png

555's need lots of decoupling, 100uF or more is good. The 7555 (CMOS version of 555) is less demanding for decoupling, 1uF will work.

It does not appear that your circuit works as intended. It does not protect against an excessive (>50%) duty cycle and, if the arduino fails and delivers 0 volts at the trigger, the output of the 555 timer is 10 volts which will effectively generate a 100% duty cycle, keeping the mosfet continuously on.

I did a quick simulation in LTspice. The green trace shows the output of the 555 timer.

edit

If you need external hardware to enforce a maximum duty cycle (because you don't fully trust the Arduino, or whatever reason) you could generate a 50% duty cycle with the 555 in astable mode then "AND" the output with that of the Arduino. You would have to ensure the pulses from the Arduino were synchronous with the 555 to ensure they fell with in the on period of the 555. I'm sure there are better way, though. It is an interesting problem that also occurs when multiplexing a display. If the driver freezes, a display element could end up being overdriven.

Is the 555 supposed to be configured as a one-shot? If so, C1 should be connected to gnd not the trigger pin.

Ok, I am not familiar with the 555 and I am also not fluent in LTspice so I was not able to simulate this circuit. I was not able to google any examples showing monostable pulses that could be turned off early.

However I thought I understood some simple tutorials enough to mix up my own circuit as follows:

1 - ground on the trigger pin switches the output pin high and turns off the discharge pin while the threshold pin waits for the capacitor to charge.

2 - if the ground on the trigger pin changes to 5v, the threshold pin causes the output pin to turn off, the discharge pin goes to ground and discharges the capacitor. (normal pass-through)

3 - if the ground remains on the trigger pin beyond 50%, the capacitor will rise above threshold and turn off the output. (failsafe)

4 - if the trigger pin goes high impedance, the threshold pin should go to 5v and turn off the output pin.

So, if the arduino freezes at 5v output or high impedance, the mosfet turns off. If the arduino freezes at ground, the mosfet turns off after 10mS. If the arduino produces a normal PWM under 50% duty cycle, the output is inverted but otherwise unchanged.

Surely there is something I do not understand but I don't see what I am missing.

Well apparently when the capacitor rises to the threshold voltage and switches the discharge pin to ground, the 555 goes into an unstable oscillation because the trigger pin gets repeatedly forced low through the capacitor.

I have been using the simulator at systemvision.com and I did not realize that they had a 555 in their simulation catalog. It shows oscillation in the failsafe mode and also that the capacitor gets negatively charged when the trigger is at 5v so that the failsafe timeout gets extended.

I will have to rethink this for a while...

I am beginning to think that the 555 timer cannot be shut off early using a single input. For as long as the trigger is held low, none of the other pins will override the output to the off position for any length of time. Either the 555 will remain on or it will oscillate at some very high frequency. Is that correct?

If I want to use the 555, it looks like I will have to supply an 'on' signal plus a separate 'off' signal.

Otherwise I could use 6v6gt's suggestion to set the 555 to output a 50hz signal with a 50% duty cycle. Then I would read the PWM as an interrupt to control a transistor that would allow the signal to pass through to the mosfet at 50% or less duty cycle. That would prevent a DC output to my pump but it could also allow a permanent 'on' AC output.

Both of those solutions would require 2 pins on the arduino.

Seems complicated but my previous non-555 circuit looks like it would be too sensitive to slight voltage variations due to it's very shallow slope at the cutoff point. However my failsafe does not need to be super accurate. As long as it allows a 50% duty cycle to pass through and blocks output somewhere before half a second or so passes, it will probably be sufficient.

Still trying to find an alternative. There should be a clean way to do this.

Ok, I added a few parts and this circuit simulates properly.

R2 and R4 give me a bias voltage low enough so that C3 will trigger the 555 on the falling edge from the arduino.

D1 prevents a negative charge on C1 so that the RC time is correct.

mosfet-555-2.png

mosfet-555-2.pdf (43.9 KB)

mosfet-555-2.png

Sorry, but I keep wondering if there is another way to solve this problem and then wondering if the new different way is better than the previous solutions.

I thought that a comparator could do the job and maybe better than the 555.

mosfet lm393b.png

I was not able to simulate this but I would welcome any comments on the relative merits of any of the proposed solutions or any suggestions of new ways to do it.

mosfet lm393b.pdf (42.7 KB)

mosfet lm393b.png

IRRC LM393 has open collector output. It will need a pull up resistor to the output and it is probably better to use something with a push-pull output. I would consider using a logic level MOSFET and a Schmitt trigger gate (i.e. 74HC1G14) to drive it.