Go Down

Topic: Failsafe- 50% max PWM (Read 1 time) previous topic - next topic

edmcguirk

Feb 11, 2020, 11:31 pm Last Edit: Feb 18, 2020, 09:26 pm by edmcguirk
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.



(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.

6v6gt

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.

PerryBebbington

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....

edmcguirk

#3
Feb 12, 2020, 06:59 pm Last Edit: Feb 12, 2020, 07:44 pm by edmcguirk
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.

PerryBebbington

Quote
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.

edmcguirk

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.

herbschwarz

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

edmcguirk

#7
Feb 14, 2020, 01:46 am Last Edit: Feb 14, 2020, 01:48 am by edmcguirk
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.

edmcguirk

#8
Feb 17, 2020, 02:47 am Last Edit: Feb 17, 2020, 02:49 am by edmcguirk
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.



(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%.

edmcguirk

#9
Feb 18, 2020, 09:22 pm Last Edit: Feb 18, 2020, 09:23 pm by edmcguirk
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.



(PDF is clearer)

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

edmcguirk

#10
Feb 18, 2020, 09:49 pm Last Edit: Feb 18, 2020, 10:05 pm by edmcguirk Reason: add picture
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.


MarkT

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.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

6v6gt

#12
Feb 19, 2020, 12:59 pm Last Edit: Feb 19, 2020, 01:24 pm by 6v6gt
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.

herbschwarz

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

edmcguirk

#14
Feb 19, 2020, 08:54 pm Last Edit: Feb 19, 2020, 09:09 pm by edmcguirk
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.

Go Up