Go Down

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


Feb 19, 2020, 09:55 pm Last Edit: Feb 19, 2020, 10:06 pm by edmcguirk
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.


Feb 21, 2020, 03:52 pm Last Edit: Feb 21, 2020, 03:52 pm by edmcguirk
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.


Feb 29, 2020, 12:39 am Last Edit: Feb 29, 2020, 12:39 am by edmcguirk
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.

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.


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.
How to insert images: https://forum.arduino.cc/index.php?topic=519037.0


Feb 29, 2020, 05:53 pm Last Edit: Feb 29, 2020, 05:54 pm by 6v6gt
You could also do it like this.
Run an Astable 555 at 50Hz with 50% duty cycle. Sense the pulses with the Arduino and, on detecting a pulse, send a pulse between 0 and 10mS long (corresponding to a 0 to 50% duty cycle) on the pin marked Arduino_pulse. Since the output of the 555 is "ANDed" with the output of the Arduino, the duty cycle can never be higher than 50 %.  You could save some components by using a P channel mosfet instead on an N channel.


Mar 01, 2020, 03:04 am Last Edit: Mar 01, 2020, 03:39 am by edmcguirk
I don't know what I was reading. I must have been looking at the wrong datasheet when I thought I read 20mA output. The datasheet says 16mA typical low sink current so that means I could use a 680 ohm pull up resistor to 10V? Would that work?

The arduino could use low output for the "on" signal and the 555 could drive the mosfet directly if I use the 10V supply.

Like this?

Also the vibratory pump needs an average of 2A at 24V but peak amperage should be about 8A. I guess that's not particularly large for mosfet switching. So, an IRF3205 is kind of overkill (although it is cheap enough). I suppose a capable P channel mosfet would not be difficult to find. Is a logic level N channel mosfet cheap and easy to find at that power level? Would a FQP30N06L or a IRLZ44N be acceptable?


Mar 01, 2020, 09:35 am Last Edit: Mar 01, 2020, 10:19 am by 6v6gt Reason: Added pictures
Maybe we have different ideas of "failsafe". You want to add hardware protection because you fear that the Arduino "might lose its way" (from your OP). However, you have produced a number of design where, if the Arduino fails, your hardware failsafe mechanism runs away on its own. Normally, it is expected if there is a failure, the application doesn't run.

Anyway, to your post #19
1. You've stripped out all of the overvoltage protection on the sense circuit, resulting in 10 volts appearing on an Arduino pin. At a minimum, you need a voltage divider consisting of 2 resistors.

2. You are now using negative logic on the arduino pulse circuit meaning that if the Arduino does not hold the pin low (the wire to it breaks etc.) the device attached to the mosfet will be on at the maximum 50% duty cycle.

What I mean about using a P-Channel mosfet was this taken 1:1 from https://www.gammon.com.au/motors and not simulated. I've left the "AND" gate solution in place but maybe there is a better solution.

Driving the mosfet like this is OK with low frequencies. With higher frequencies, the switching times become important and then a push/pull circuit is better to avoid the mosfet being in a non fully conductive state for extended periods. For 50Hz, this is not an issue.


Back in post #16 I recognized that running the 555 as a 50% PWM source opens the door to runaway pump drive if the arduino fails in a mode that allows permanent pass through of the 555 PWM signal. The 10K pull up resistor on Q1 would cause a default 'off' condition but if the arduino should freeze in a ground state, the pump would runaway. I would have to add in another circuit that would limit the arduino trigger to <10mS... (wait, that sounds like the original problem)  ;)

Yes, I did drop out the protection circuit for the arduino sense port. I was more interested in the other portion of the circuit. I had seen another method of protecting arduino pins from overvoltage. Just running the signal through a resistor that would reduce the overvoltage current to less than 1mA (in this case something >10K ohms). It's obviously not 'best practice' to depend on the arduino's internal protection but is it really that bad?

I am interested in thinking about alternative circuits but I don't really prefer the 555 50% PWM source method. So far, it does not save on part count, it uses an additional arduino pin, and it allows a possible runaway condition.

If any of the other circuits allow runaway or constant DC output, I was not aware of that fact. Please feel free to tear into any flaws in any of these proposed circuits.

At his point I kind of like the non-inverting BJT circuit in post #8 for its simplicity after changing the supply from automotive 12v-14.5v to regulated 10v and dropping the zener diode (but this circuit has bad cutoff sensitivity/accuracy) or I like the comparator circuit in post #18 if it can drive the mosfet with a pull up resistor added (and that useless diode removed).

The 555 circuit in post #17 is a close 3rd place but would be 1st place if the problems with the other two are worse than I currently understand. (it is, at least, a push-pull output)

Converting to logic level mosfet is also interesting but I am not sure it would be a noticeable improvement.


Well, if you want to use a comparator, you could also do so in conjunction with an RC network. The RC network converts a duty cycle to a voltage and the comparator will trigger at a predefined voltage.

What constraints are you under for this exercise, incidentally? You've already mentioned 1 dollar for the components and appear to have some limit on the component count even for very cheap components such as resistors.


I am not under any specific constraints. I just prefer to use fewer components taking up less space on the circuit board and I would like to limit the design as close as possible to generic parts cheaply available. My guestimate is that if the part is commonly available on ebay, then it could be considered a generic part.

The difference between 8 resistors/capacitors/etc and 16 one cent parts is obviously not a monetary problem but I would like to fit the arduino nano, circuit board, flow meter, 2 pumps, 24v power supply, a relay, etc all in one small box, so I don't want to waste board space. I might be shooting for a 2 inch by 3 inch board for the arduino, mosfet drives, etc (all through-hole parts) plus another 2x3 for the physically big parts like the flow meter and relay and then empty space for the two pumps and the 24v supply. Probably in a 3x5x7 box. (a lot of that thought came from the sizes needed for the 220v design - 24v may be different)

The pump needs to run on a 50% or less duty cycle. My program should have various sanity checks that will prevent any duty cycle more than 50% but the pump will overheat if the arduino freezes and supplies a DC output. Additionally the pump is only rated for two minutes on with one minute off but again the program will have to handle that along with a thermal switch embedded in the pump (although the pumps don't always come with the thermal switch and I have seen thermal test graphs that run 15 minutes).

So, this failsafe is really only a protection from freeze up / DC output. Even a cutoff at one second or one half second would probably be acceptable but it seems that a cutoff around 75% duty cycle is easily attainable. I see your suggestion of a RC network monitoring pump drive signal for too much power over a slightly longer time period could be an interesting alternative. I'll have to think about that. I welcome circuit suggestions.

I am building this for myself but if it works well, there may be a few people who might copy my project. So far the project comes in about $150 but I have spent close to $450 on supplies and tools (I bought 200 grommets for $5 because I needed 3). Trying to save an extra dollar or two is probably foolish but that's how I feel.

Also I am curious to learn any different methods I have not thought of yet. Along with technical reasons one method might be preferable to another.


It is 50Hz only! I did not notice before. I think reliable timing for such long times will be difficult using passive components. I would use an additional MCU working as a supervisor circuit with as simple code as possible. Something like ATTiny13A (cheapest AVR from eBay) with BOD and WDTON enabled forwarding the signal from Arduino to the pump. If it takes too long active (i.e. 150ms) reset Arduino and turn off the pump.
How to insert images: https://forum.arduino.cc/index.php?topic=519037.0


Mar 02, 2020, 06:27 pm Last Edit: Mar 02, 2020, 06:42 pm by edmcguirk
Millisecond accuracy is not critical. I just need to prevent the PWM signal from freezing at a DC output.

I've been thinking about your suggestion and I realize I have been going about this wrong. My previously proposed circuits pass through or create a PWM signal that cannot exceed 50% or even reduce a train of long pulses down to a proper signal.

It would be better to detect a long pulse and ground the mosfet gate. As a matter of fact, if the arduino produces a pulse longer than 10mS, something has gone horribly wrong and output could be permanently shut down either at the mosfet or by cutting power to the arduino. (cycling power to the box should reset)

At this point I think a logic level mosfet driven directly from the arduino would be a noticeable improvement. Would a FQP30N06L or a IRLZ44N be acceptable? I am not confident in my power dissipation calculations. The mosfet will drive a 48W pump at 50hz with 24v and average 2A over 20mS that should peak at around 8A through the inductive load.

I am not sure if I prefer a circuit that would hold the mosfet gate to ground until a power reset or a circuit that would shut down power to the arduino until a power reset. But I think I am looking for a circuit that will throw a switch if a pulse longer than 15mS is detected.

Since my project will be running 2 vibratory pumps alternating pulses to reduce instantaneous current loads on the 24v supply, maybe shutting down the arduino is better.

I am going to step back and rethink this a bit.


Mar 02, 2020, 11:33 pm Last Edit: Mar 02, 2020, 11:37 pm by 6v6gt
Both mosfets look OK to me if your calculations consider start/stall current of the motor. Important for a mosfet is the RDS(on) parameter. This should be very low and quoted at the voltage at which you drive its gate. The IRLZ44N specifies this resistance as 0.025 ohms at 5.0volts. The heating effect is I^2 * R so , even at 8A, that is only 1.6 watts to dissipate but which would benefit from a small heat sink. If you underdrive the gate, then the mosfets could get very hot which maybe is something else you have to guard against for a fully fail safe application. This could be done indirectly by temperature monitoring of the devices.
I tend to agree with the Smajdalf suggestion of a dedicated MCU which exclusively watches for failure situations. This is much more flexible. However, You could also experiment with an RC network to determine the duty cycle.

I did an experiment using LTspice to convert your duty cycle into a voltage using an RC network.
The green trace is generated from a pulse of period 20mS with on an period of 15mS  (duty cycle of 75%) fed through the RC network (measured at 'RCnet'). It quickly stabilises at 2 volts. The OP amp (configured as a comparator)  is set to trigger at 1.5 volts (red trace - measured at 'out'). A duty cycle of 50% does not trigger it. Anyway, I'm not an expert in this area of RC network design so I can't say much more and there may be a better way of doing this.


Mar 04, 2020, 03:45 am Last Edit: Mar 04, 2020, 04:32 am by edmcguirk
Just to clarify the power requirements of a vibratory pump, it is essentially a solenoid thrusting forward 50 times a second and a spring pushes it back to the starting position during the off portion of the cycle.

So, each pulse starts at 0A and ramps up to around 8A at the end of 10mS and averages out to 2A at the end of 20mS. There is no start/stall current. Every pulse is the same as the first pulse. I would imagine the mosfet turn on transient is weak but the turn off transient is strong and I think that pairs well with a pull up resistor and a pull down transistor on the gate.

edit - If I average the square of the current for average power it would be 16 multiplied by Rds of .025 for the IRLZ44N and get .4W. Is that right?

I have not had time to consider this new direction of long pulse detection though it probably will not be hugely different from some of the previous proposals.

I also am working out how I will integrate tripping the failsafe with illuminating an error LED without the arduino. (I don't know if I want to implement a watchdog MCU - still reconsidering all options)

As far as what RC network to use is concerned, my first proposals tripped when the capacitor reached something above 95% of the charging voltage and the shallow slope of the rising voltage would probably make the circuit very sensitive to manufacturing variations. However the later proposals that trip when the capacitor reaches 2/3 of the charging voltage are very reliable and easy to tune to millisecond accuracy.

Go Up