circuit to drive MOSFET and relay from same PWM output?

dmaxben

Member
I tried several searches (relay pwm*, smooth pwm*, pwm* on* off*, pwm* darlington, etc) but couldnt really come up with anything that matched what I am looking for.

Basically, I want to simultaneously drive a PWM solenoid valve, and actuate a standard electromechanical relay from the same PWM output on the PICAXE. The reason Im not just using one PWM output for the solenoid, and then a separate digital output tied to a darlington transistor to drive the relay, is because I am all out of available pins, and my PCB size will not accommodate a larger PICAXE.

When the solenoid valve is actuated, it ramps up from 0% duty cycle to 98% duty cycle over a time period of roughly 1 second. The solenoid is not designed for 100% duty cycle, which is why I ramp it up to 98% and hold it there until I want to turn it off/close the valve. Then I have an additional electromechanical relay (to trigger a separate non-PWM on/off valve) that I want to trigger at the same time the PWM solenoid is ramped up/turned on.

It is not time-critical when the relay is triggered over the course of the ~1 second PWM ramp-up to the solenoid, just as long as the relay transitions from "off" to "on" by the time the PWM has ramped up to 98%.

The MOSFET is a logic-level N-channel ST-Micro P20NF06L, which I have hooked up to the PWM output via a 330ohm resistor for protection.

I have attached a rough schematic (please excuse the MS Paint drawing!) of what Im thinking might work. I didnt draw in all of the details on the schematic, but the 5v supply is all properly regulated. The circuit already works perfectly to drive the solenoid, I just want to add in the additional "on/off" relay-trigger portion.

If I add in a 1N4004 diode, and then a capacitor (as shown), and then tie that into a darlington array (ULN2003), and then drive the relay with the ULN2003...will that be a sufficient circuit to "translate" the PWM signal from the PICAXE into a steady-state "high" logic level for the ULN2003? And will that little addition to the circuit otherwise affect proper PWM operation of the MOSFET?

In other words, will this circuit shown in my schematic properly "split" the signal coming from the PICAXE...with "part of the signal" going to the MOSFET as PWM, and the other "part of the signal" going to the ULN2003 as an "on/off" signal?

Also, im not sure what kind of capacitor I should use (polarized cap or not??), and what value would be needed....100uf?

thanks
Ben

circuit.jpg
 

g6ejd

Senior Member
Some thoughts:

Your 'charge-pump' that drives the ULN2003 will have a time constant that is determined by the input resistance of the 2003 device, you may find it better to add a parallel resistor so that you can determine the correct time constant T=CR and hence the value of C. In practice your charge pump will quickly reach the maximium voltage (from your PICAXE input) and trigger your relay, this will result in relay chatter for sure. You may need to limit the PWM output in normal use to some nominal amount to prevent the relay from switching, say 50-75% and only when you go to 100% does the relay go.

Whatever you do it will be a compromise.

Think about making the relay latching, perhaps two, so that you can simulate a bistable logic gate.
 
Last edited:

bluejets

Senior Member
The solenoid is not designed for 100% duty cycle, which is why I ramp it up to 98% and hold it there until I want to turn it off/close the valve. Then I have an additional electromechanical relay (to trigger a separate non-PWM on/off valve) that I want to trigger at the same time the PWM solenoid is ramped up/turned on.
View attachment 11493
Unsure what this could be. Maybe more detail.

Other than that, maybe a monostable but then you need to turn it off. Bistable needs 2 signals so back to square 1.
 

AllyCat

Senior Member
Hi,

I don't really understand the significance of a "PWM solenoid valve" (or why 98% is significantly better than 100%), but what frequency is the PWM?

Have you tried simply connecting the relay coil directly across the solenoid winding, since they both appear to be rated at 5 volts? Relays have a certain amount of (mechanical) hysteresis so (provided the PWM frequency is fairly high) it should snap in and out quite cleanly.

Cheers, Alan.
 

bluejets

Senior Member
Duty cycle usually refers to on time against off time for equipment like welding machines. Say 30% duty cycle meaning 18 minutes on and 42 minutes off. Never seen it on a solenoid valve however.
Can't quite grasp what you are trying to do.
 

premelec

Senior Member
I haven't followed this all but --- put a capacitor in parallel with the relay and put a diode to that from the PWM so the capacitor charges a bit with each PWM... if you need to PWM and set relay independently of the PWM you DO have a problem... :)
 

AllyCat

Senior Member
Hi Ben,

Just a diode directly charging a capacitor will "short out" the PWM waveform until the capacitor charges. The capacitor in the OP's diagram could be quite small so it might not matter, but one large enough to be useful across the relay will "damage" the PWM drive. So I stand by my original suggestion to try just the relay connected directly across the solenoid. The inductance of the relay/solenoid probably stores more energy (i.e. filters any potential "relay chatter" better) than a capacitor.

You haven't said if it's important for the relay to also release in synchronism wih the solenoid valve. That may determine the discharge time constant of any (C.R) "filter" based design.

Cheers, Alan.
 

Goeytex

Senior Member
As I gaze into the crystal ball, I imagine that the "pwm solenoid" is something like a fuel injector that controls the flow of a gas or a fluid. I am guessing that the PWM frequency is on the slow side and for each PWM Cycle the solenoid must activate (open valve) and deactivate (close valve).

If this is the case, I would think that putting a relay coil in parallel to the solenoid would result in the relay buzzing at the PWM frequency just like the "pwm solenoid".

In any case, the OP has not provided enough information so that folks can offer good help. We are still in guess mode.

We need:
1. Datasheet for the :"pwm solenoid"
2. Solenoid Current / coil resistance
3. Complete Picaxe Code
4. PWM Frequency
5. Datasheet for Relay
6. Relay coil resistance
 

Colinpc

New Member
Can you add a "missing pulse detector" to the ouput? When the output starts to pulse, the detector will be in one state (use this to operate relay) and when the pulses stop, the detector will change state and turn off relay. Just google "missing pulse detector 555" and work from there.

Use a buffer between the Picaxe output and detector to limit loading.

Fred
 

dmaxben

Member
Sorry everyone! Ive been away, havent really had time to check this thread here. I really appreciate all of the help here. I have to run out again but Ill be back later on tonight with more information (more detailed schematic and info about the driver, solenoid, etc)

thanks
Ben
 
Top