# Dither for PWM circuit driving a proportional solenoid

Discussion in 'Microcontrollers, Programming and IoT' started by markdav91, Jul 30, 2017.

1. ### markdav91

9
0
Jul 30, 2017
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

2. ### Alec_t

2,935
799
Jul 7, 2015
Welcome to EP!
So, you want a 122Hz dither frequency, but what wll be your main PWM frequency?

3. ### kellys_eye

4,275
1,147
Jun 25, 2010
says who?

My understanding is that there are limits to what you can use but, between those limits, the choice is down to various register settings.

markdav91 likes this.
4. ### kellys_eye

4,275
1,147
Jun 25, 2010
If I understand you correctly you want to modulate a PWM signal with another? You could do this using a logic gate (AND two PWM signals) or do it in software since you're using such low frequencies by feeding it back into a couple of input ports and 'doing the business'.

5. ### Alec_t

2,935
799
Jul 7, 2015
I think you need to set up the main PWM frequency, then use code to jitter the register value (in OCR2A/B) which sets the main PWM duty cycle.
From what I read (I'm not familiar with Arduino), although the default 'Fast PWM' mode has only a few preset frequencies it is possible, as Kelly says, to set a wide range of PWM frequencies by use of various control registers.

6. ### markdav91

9
0
Jul 30, 2017
The main frequency would be the default on the pins, I believe that about 490 Hz on some and about 970 Hz on others. I guess 490 Hz will have to do

7. ### markdav91

9
0
Jul 30, 2017
Ahh, i wasnt aware of it, thanks for the info

2,935
799
Jul 7, 2015
9. ### markdav91

9
0
Jul 30, 2017
modulate a PWM signal with another? -> yes, if that's what it takes to get a control signal of that nature.

how do I AND 2 PWM Signals ? could you explain in brief

by feeding it back into a couple of input ports and 'doing the business' - > are you talking about a feedback and some PID algorithm?

10. ### markdav91

9
0
Jul 30, 2017
sort of read it before half way and left it thinking it would be of no good to me in this context. But now that you brought it up i guess i'll read it completely and lets see what ideas spring up

11. ### BobK

7,682
1,688
Jan 5, 2010
You don't need to combine two signals, you just need to periodically change the duty cycle. If programming at low level instead of using Arduino primitives this should be simple.

On a low-end 8-bit PIC, just for kicks I, I output a 1MHz PWM signal (yes, they go that high), changing the duty cycle every millisecond. Connected it to an antenna, and I could pick up a 1000Hz tone on an AM radio.

Bob

markdav91 likes this.
12. ### markdav91

9
0
Jul 30, 2017
Thanks Bob. I will post the results soon.

13. ### Kiwi

348
85
Jan 28, 2013
Just wondering if you are overcomplicating your project?

Have you observed stiction in your project?

All the proportional hydraulic solenoid valves that I work on in earthmoving/construction machines have a steady PWM frequency and just vary the duty cycle.

14. ### markdav91

9
0
Jul 30, 2017
Hey Kiwi, thanks for your reply, I'm not exactly working on a proportional valve, I'm trying to get it to be proportional

15. ### markdav91

9
0
Jul 30, 2017
for those who have com here in the mean time, it will be until October that i post the results.

16. ### ShewShew79

6
0
Nov 19, 2015
markdav91

Have you had any success in your question? I to would like to know how and why this is done. If I had a scope image to work from would help and I could then either build or program something to work. It seems everybody has a partial idea on how to do it but doesn't actually know how!

Regards

Shew

17. ### markdav91

9
0
Jul 30, 2017
it's not completely formatted but you'd still get an idea. check the projects section on my linkedin page.
Electronic control of hydraulic systems