Solenoid PWM

Status
Not open for further replies.

Mosaic

Well-Known Member
Hi I have a 16V, 1.4A Solenoid (diaphragm) valve that I want to apply PWM control to.

Can anyone advise on the appropriate pwm frequency?

Also, a suitable logic level MOSFET for this app?
 
This is one of those projects where virtually anything will do. I dont know of any power fets that wont take the voltage, anything that will take more than a couple of amps will be good enough, and it wont get hot. Frequency around 20 Khz, so you cant hear it whistle, around 80 khz if theres a cat sleeps nearby. Dont forget the flywheel diode, which has to be a bit special. It must be a fast turn off diode, or a schottky. UF5400 comes to mind. Dont use a mains rectifier across the valve coil, it will get hot and smoke for no easy to see reason. If you leave the diode out altogether, everything else will get hot.
hope this is of soome help
 
Hmm, I found a solenoid that want between 15 to 40Hz.
Must be inductance related as the higher the freq. the more impedance is generated for a given coil inductance. Actually it seems that solenoids generally need much less Hz than motors.

Thing is, 40Hz is under the pwm lowest freq. (about 488Hz) at 8Mhz Fosc.

Looks like a case of isr driven pwm
 
Use shorter PWM period "frames" and interrupt "helper" code to link these "frames" into the much longer 40-Hz (25-msec) period. Very low overhead. Very high resolution.

Regards, Mike

Code:
;******************************************************************
;
;  //  setup a 1000 usec PWM period with PR2 = 249 and prescaler
;  //  4:1 (4 MHz clock) or 16:1 (16-MHz clock) and use 25 of
;  //  these shorter PWM "frames" to make the much longer 25-msec
;  //  period.  Resolution is 1-usec.
;
;  int width = 1500;              // pulse width, 0..24999 (usecs)
;  int pulse = 0;                 // ISR work variable
;  int frame = 1;                 // frame number 1..25
;
;  void ISR()
;  { PIR1bits.TMR2IF = 0;         // clear Timer 2 interrupt flag
;    frame--;                     // decrement frame number
;    if (frame == 0)              // if end of 25 msec period
;    { frame = 25;                // reset for new 25 msec period
;      pulse = width;             // reset 'pulse' work variable
;    }
;    if ((pulse > 1000)           // if pulse > 1000 usecs
;    { CCPR1L = 250;              // do a 100% duty cycle frame
;      CCP1CONbits.CCP1Y = 0;     //
;      CCP1CONbits.CCP1X = 0;     //
;      pulse -= 1000;             // subtract 1000 usecs
;    }
;    else
;    { CCP1CONbits.CCP1Y = (pulse & 1);
;      CCP1CONbits.CCP1X = (pulse & 2);
;      CCPR1L = (pulse >> 2);     // 0..249 (0..999 usecs)
;      pulse = 0;                 // remaining frames are 0%
;    }
;  }
 
Is that basically outputting 1 ms bits of a hi freq. pwm?
Won't that still induce higher impedance due to coil inductance?
 
Is that basically outputting 1 ms bits of a hi freq. pwm?
Won't that still induce higher impedance due to coil inductance?
It's actually linking together 25 higher frequency PWM "frames" to produce the much lower 40-Hz PWM signal you require.

The PWM module is double-buffered. That is, the value you place into the CCPR1L "duty cycle" register during the end-of-period PR2 match interrupt will be used by the PWM module as the new duty cycle value at the next end-of-period PR2 match interrupt. You're always setting up the duty cycle for the next PWM period. When you set the duty cycle to 100% the output will remain "on" for the full 1000-usec period and so if you set the pulse width variable to 12500 usecs you'll generate 12 PWM "frames" with 100% duty cycles (1000-usecs "on") and one PWM "frame" with a 50% duty cycle (500-usecs "on" and 500-usecs "off") followed by another 12 PWM "frames" with 0% duty cycle (1000-usecs "off").
 
Last edited:
ok, i see. That's kinda deep. Got that in asm code perhaps?

Btw Mike, when starting a solenoid I'd need to do like a 90% PWM at first to get over inertia?
How many periods shuold I run 90% before I drop to say the tgt 40%? I'm hoping your experience can guide me here!
 
I don't have any experience with solenoids. Sorry! And, there should be some ASM examples on the Forum somewhere.
 
? and?? Suddenly everyone's talking in curly writing that I can't untangle. You are building a pulse fuel system for a ramjet? an infrasonic weapon? a communist agitator?
where does 15Hz come in? Is it a full automatic spudgun:
 
Spuffy: Auto boost control .

Here's what i've dug up:

For solenoids there are frictional losses and inertial issues with the changing direction as well as fluctuating inductance and reluctance as the air/coil gaps varies. Motor control hi freq. type PWM will fail here.
To run solenoids I need dither to keep the valve out of stiction issues.
 
Last edited:
Are you trying to make the valve assume a known position, like a servo? like you send it a signal to tell it where you want it, and it goes there and stays there, regardless of variations of pressure?
You can put a small resistor,say 0.01 ohms or so, in the source leg of the fet, with an amplifier to feed a voltage proportional to current into an adc. By switching on the fet, taking a reading, waiting a millisecond or so, and taking another reading, you can find the rate of change of current, and get a value for the inductance of the coil, which varies with its position. compare this with the signal that tells it where you want it to be, and change the mark space ratio so that it goes there. With some messing about you can make it overshoot its new position some, and continue to oscillate about where you want it. This will all be nicely nonlinear, the inductance changes at a fearsome rate as the solenoid closes, but there are lookup tables.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…