Dither for PWM circuit driving a proportional solenoid

Thread Starter

joedavid91

Joined Jul 14, 2017
4
Hi guys,

First of all I'd like to say that I have seen the same or similar questions asked in many forums but nobody has ever come up with a concrete solution or posted anything about the results of trying out the various suggestions given to them. So here I am still trying to figure things out so please help me out. And now to my problem

I am planning to proportionally drive a solenoid of the following specs: 24VDC,1.19A 28.5W resistance 20.2ohms +-5% at 20C

I'm planning to use the arduino to accomplish this. I'm aware of the whole concept of dither which is necessary to avoid stiction in the solenoid valve. As most of you will be aware of, we cannot freely choose the pwm frequency in the arduino but are restricted to a few discrete frequency values of which only 30.5Hz (Pin 3,9,10,11), 61Hz (pin 5,6) and 122Hz (Pin 3,9,10,11) are below 200Hz. I found optimal dither at 122Hz which is okay. ( A tiny part of the project is taken care of)

But I can't use the the dither signal alone to drive the solenoid due to obvious reasons as it is not possible for the dither signal to form a constant amplitude since the PWM frequency has to be continuously adjusted as a function of the stipulated desired current value and in the process the amplitude and the frequency of the dither will signal change accordingly. In other words i need the dither to be a constant while i'll still be able to change the average current in the solenoid to manipulate the spool proportionally.

Then I stumbled upon a concept of superimposing the dither ( low frequency signal ) on a high frequency PWM signal.




But i do not know how to do this. Some smart guy by the name of Drazzy suggested in an old arduino forum :"You could put source of a small MOSFET on one pin, and gate on the other....". If i got him right he means using one MOSFET at a lower frequency to switch another MOSFET at a higher frequency (or the other way around? i'm confused:| ).

I also came across a website that talked about combining PWM outputs. http://www.openmusiclabs.com/learning/digital/pwm-dac/dual-pwm-circuits/
Is there anyway that i can use this in this application in context?

Either way could someone shed some light on this. will this work practically? what would be the circuit like? Any useful information is welcome. Any other ways to achieve the same are also welcome.

Help a friend and thank you in advance :)
 

Bernard

Joined Aug 7, 2008
5,788
There has been some requests here on AAC on dither. Look at the top of this page at Search Forums , click & enter dither. Short on final results.
 

Sensacell

Joined Jun 19, 2012
2,819
You can do this entirely in code.

Presumably you have a control loop that feeds a desired output to the valve via PWM...
If you create a synthetic digital sawtooth or square wave signal in the MCU and add it to the signal going into the PWM, you can create dither at any arbitrary frequency or amplitude.

This makes it very flexible in terms of tuning.
 

Thread Starter

joedavid91

Joined Jul 14, 2017
4
You can do this entirely in code.

Presumably you have a control loop that feeds a desired output to the valve via PWM...
If you create a synthetic digital sawtooth or square wave signal in the MCU and add it to the signal going into the PWM, you can create dither at any arbitrary frequency or amplitude.

This makes it very flexible in terms of tuning.
Thank you for your suggestion Sensacell, I can create a digital wave in the MCU as you suggested which i presume is for the dither, but how do I add it to the main PWM signal driving the solenoid? Do i do it in software or hardware? Could you briefly explain ? (thanks!)

and that comes to the what DickCappels suggested which I think he meant for the dither signal (correct me if I'm wrong)

Like he said...just have a timed task that periodically changes the top value of the counter that you are using for PWM.


Changing the TOP value of the counter would mean changing the frequency of the PWM signal (correct me if i'm wrong again). If i periodically change TOP value of the counter (periodically change the frequency in other words ) what effect would that have? I have a hunch that's not what i want to have. I think I may have to periodically change the duty cycle. Again correct me if i'm wrong.

In any case im wondering If i need two separate PWM signals ( one at low (dither) and the other at a higher frequency) and somehow add them up or superimpose (either by hardware or software) or do i just need one PWM and let the code manipulate it?
 

DickCappels

Joined Aug 21, 2008
7,414
You are correct. It would cause frequency modulation in that case the dithering would be dutycyle modulation of a fixed pulse width.

Alternatively you can adjust the compare values but I think that is more prone to glitchy operation depending on the values you use and when you update the values.

In either case it might be best to use an interrupt that fires every time the top value is reached and then do your cycle counting and dithering right after the interrupt so as to minimize the opportunity to create glitches. That is if glitches are bad in your application -otherwise don't bother with that detail.
 

Sensacell

Joined Jun 19, 2012
2,819
My simple explanation would be to simply add the dither signal to the value going to the PWM.
Take care that if the addition overflows 8 bits, just set the PWM to 255- saturated maximum.

Think of the PWM simply as a crude Analog to Digital converter, (which it is) you are just adding a time-varying signal to whatever your control loop commands.

For example, make the dither vary from 0-8 counts, just add this changing value to the PWM output register.
Don't worry about synchronizing it to the PWM counter, assuming the PWM is much higher frequency than the dither, which it should be. Synchronizing it is unnecessary and makes tuning the dither frequency very difficult.
 
Top