I am controlling a proportional coil on a proportional hydraulic solenoid valve. In order to reduce the chances of the spool "sticking" inside the valve I have read that a "dither" signal is required to keep the spool vibrating, basically so its never static.
I am currently running PWM to control my coil at a 122hz frequency which works well. However I am now looking to fine tune this. I know at low frequency PWM such as this dither is produced naturally as a by-product of PWM. However my PWM duty cycle varies depending on an input from a potentiometer and so it is impossible to control the dither frequency and amplitude independently of the PWM frequency.
From my research some controllers have a separate dither function, which allows a noise / dither (at a set frequency) to be superimposed over a PWM signal.
Does anyone know if it is possible to do this using software programming on the Arduino? Or if I need additional hardware?
This may sound a little crazy, but would it be possible to use another PWM signal to create a dither and then some method of combining the two?
Apologies if I haven't quite been thorough with this. I'm still learning about this dither and so would appreciate any feedback.
Of course, it's possible. I don't think you can do it with the analogWrite method. You would have to write your own PWM using the processor's hardware timers.
If you have a pwm pin and a duty cycle this could work if placed in loop where x and y are the dither range.
analogWrite(pinNumber, dutyCycle+random(-x,y));
I don't have a scope to fully check this out, but when used a pulse width reading program with dutyCycle = 127 and the dither range -5, 5 could see reasonable variation of the duty cycle.
cattledog:
If you have a pwm pin and a duty cycle this could work if placed in loop where x and y are the dither range.
analogWrite(pinNumber, dutyCycle+random(-x,y));
I don't have a scope to fully check this out, but when used a pulse width reading program with dutyCycle = 127 and the dither range -5, 5 could see reasonable variation of the duty cycle.
Oh, I see. Yes, a low frequency dither is certainly possible.
However, I don't fully understand the random(-x,y) snippet. I'm guessing this imposes a random additional duty cycle onto the main PWM duty cycle? What sort of figures would I need to use in order to implement this? On further thought though wouldn't this code just cause the duty cycle to fluctuate randomly slightly from the given duty cycle, yet maintain the same frequency? I would need to be able to independently set the dither frequency from the PWM frequency.
Basically, can you explain exactly what the above code would do?
On further thought though wouldn't this code just cause the duty cycle to fluctuate randomly slightly from the given duty cycle, yet maintain the same frequency?
Yes, that is what it does. I may have misunderstood what you desire.
I am controlling a proportional coil on a proportional hydraulic solenoid valve. In order to reduce the chances of the spool "sticking" inside the valve I have read that a "dither" signal is required to keep the spool vibrating, basically so its never static.
You'll have to explain a little more about the valve. I was thinking that the pwm duty cycle set the position of the spool within the valve, and the random variation of the duty cycle would continually change the position of the spool around a basic setting. I did not think that the frequency was important for position and 50% duty cycle at 122 Hz or 1220 Hz would place the spool at the same location. Is the proportionality of the valve opening a function duty cycle or frequency?
Please explain the role of the pwm frequency and duty cycle in regards to the function of the valve. Perhaps you could post link to the valve.
I would find out at what rate you need to move the coil, and how much. And use this information to superposition a sinus (with the amplitude and frequency from above) on to the signal you normaly would have put out on the pwm.
Most likely you do not need a propper sinus. In many cases a square wave will be sufficient. I would have started with that. You are more likely to get what you want from adding a periodic signal, than a random one.
Make a function for this additional signal as cattledog suggest with the random function. That is exactly what you want if I've understood the problem correcly.
Sorry for the delayed reply in this. Basically what I want to do is super-impose a "dither" or noise signal on top of my PWM which is used to randomize quantization error.
So for example I want to run a high frequency PWM eg. 3kHz to supply current to my solenoid, yet introduce a timed and periodic signal (thanks Bernie) of a chosen frequency eg. 140hZ within that high frequency PWM. I would also like to be able to set the amplitude of this dither or ripple frequency by adjusting the duty cycle independently of the the main high frequency PWM duty cycle. Thus, varying the current level set by the high frequency PWM by a certain percentage to produce the ripple.
How could I modify Cattledog's code to introduce this periodic signal?
Doing it in hardware with two pins on different timers is possible - but not like they show, that's for sound. You could put source of a small MOSFET on one pin, and gate on the other....
Just looking at the options available and the feasibility of each.
So basically DrAzzy, something like the attached circuit? Using the drain from your described MOSFET configuration (FET 1) to drive the gate of a second MOSFET?
I can understand the concept of this, essentially switching low frequency PWM source input with a high frequency gate input. What effects would this have the drain of the first FET?
By programming the low frequency (FET source) PWM pin to supply a duty cycle 6% less of that of the high frequency (FET gate) PWM pin, could I essentially achieve the ripple and control shown below?
The diagram below shows Hi frequency PWM and the need for superimposed ripple / dither which can be controlled independently of the PWM frequency and amplitude.
Below is the inherent ripple as a by-product of low frequency PWM. However the ripple is controlled by duty cycle and frequency of the PWM and as such the amplitude will change with duty cycle. In my case this is not ideal. I know I will have better results with hi freq PWM with a superimposed dither.
I hope this helps paint a clear picture of my requirements.
aarg:
Of course, it's possible. I don't think you can do it with the analogWrite method. You would have to write your own PWM using the processor's hardware timers.
what about using a transistor to filter the two together after output