Hi Guys! I am making a device for my high school scientific experiment. I need to be able to apply accurate and steady voltages ranging from 0V to 5V from an output pin. This will be used to create a mini electrical field in a 14mm by 14mm well of water full of Paramecium. I am planning to achieve this from the Arduino Uno by using pulse width modulation. I was wondering if pulse width modulation alone could achieve accurate and steady voltages from an output pin. I have read online about low pass filter and I was wondering if they were necessary for what I am doing in my experiemnt. If so, could you guys please outline what electronic parts I will need and show me a detailed description of the wiring. Thank you guys!!!
This will filter the PWM to a steady voltage. It will take about half a second for the voltage on the output to reach the expected level after you set the PWM.
Yours,
TonyWilk
I am Sorry if I am hijacking, but.. Is the posted filter usable for all PWM frequencies or does one need to change caps or resistors with different frequencies? AFAIK some pins have a frequency of 31250hz and others have 62500hz..
I was wondering if pulse width modulation alone could achieve accurate and steady voltages from an output pin.
No.
No voltage derived from PWM is ever a steady voltage, in fact a steady voltage is almost impossible to achieve anyway. Their is always a varying component, due to noise or ripple. A filter will reduce the ripple from a PWM signal but will never remove it.
How good it is at removing the ripple depends on three factors:-
- The break point frequency of the filter, sometimes called the cut off frequency. This is the point where the ripple has dropped to a half of what it was.
- The order of the filter - that is how fast the filter attenuates signals as the frequency of those signals increase above the break point.
- The frequency of the ripple ( PWM ) and how close it is to the break point.
Note that the heaver the filtering, that is the more it smooths and attenuates the signal, the more time you have to wait between changing the PWM duty cycle and seeing this change reflected in a steady output.
An important part of design is in deciding what amount of ripple you can cope with and design to that.
You can use a DAC or a board like the Due that has a real DAC if you need steady voltages.
This will filter the PWM to a steady voltage.
No, it won't. The average output voltage depends on the load characteristics and as mentioned in reply #3, ripple is unavoidable. Furthermore as the PWM duty cycle (and average output voltage) decreases, the ripple gets worse.
jremington:
No, it won't. The average output voltage depends on the load characteristics and as mentioned in reply #3, ripple is unavoidable.
Of course you are right to point this out, put for the OP, it could quite fine. If he wants to create an electric field, he is driving no load but only loading a small capacitor. It should work, depending on how fast he expects to change the field.
I think you need to give a better definition to "accurate and steady".
As long as you keep the voltage into the Arduino steady your filter will provide repeatable and steady results.
Here, by steady I mean if you put a simple voltmeter (2 digits to the right of the dp.) on the output, it will read the same voltage "every time" Well maybe the last digit will flicker between two values.
However if you put an oscilloscope on the output you will see some variation at the PWM frequency. With your 2 stage RC the variation will be small but will exist.
My opinion your approach is fine for what you are doing. If you wanted an output with no ripple then you should use a DAC as suggested earlier.
Good luck
You also have to think about loading. The circuit shown in reply #1 will only work into a relatively high impedance load. It's hard to guess what your Paramecium cell impedance will be. The solution is to add an output buffer or current amplifier.
Here's a calculator:
http://sim.okawa-denshi.jp/en/PWMtool.php
Maybe I should clarify the filter in my reply #1.
The assumption is the OP wants a fairly steady-state DC level (over several seconds at least). In simple terms the first RC knocks off the sharp edges, the second provides a long time constant to "average' the PWM signal. I've just simulated this and it wasn't a bad guess.
With such a long time constant it will take 0.5secs for the output to be within 10mV of the target voltage,
after 1 sec it'll be within 1mV (with ripple << 0.1mV)
For just about all practical purposes the output has negligible ripple and it would not matter if your PWM was driven at 30kHz or 60kHz.
Ripple is not unavoidable... it is simply a trade-off against settling time.
You also have to think about loading.
Very true, I made another assumption... water has a reasonably high resistance and I guess - no, wait...
...I just got some pond water and measured a couple of probes stuffed ~15mm apart in a glassfull at c. 250kohms (the precise details of the cell construction and electrode size will affect this a lot).
The 'resistance' of the cell will affect the actual voltage, so it would have to be calibrated.
Yours,
TonyWilk
P.S. There will also be electrolysis effects to consider.
TonyWilk:
The assumption is the OP wants a fairly steady-state DC level
[...]
For just about all practical purposes the output has negligible ripple
You are aware of the fact that you put 11000Ohm in series there, which prohibits most practical purposes, especially those that require a steady-state direct current of any significant size? This is ONLY good if you need hardly any current but only need to drive a very high (>>11kOhm) input.
Maybe I should clarify the filter in my reply #1.
Better to just drop it completely. As others have said, spend a couple of dollars on a DAC module.
The output voltage is not even predictable unless the load impedance is completely understood.
Here is what the output would look like for that filter, with 1 kHz PWM, 10% on time, 5V Vcc, into a 1K Ohm load:
How useful does that look?
jremington:
Better to just drop it completely. As others have said, spend a couple of dollars on a DAC module.The output voltage is not even predictable unless the load impedance is completely understood.
Here is what the output would look like for that filter, with 1 kHz PWM, 10% on time, 5V Vcc, into a 1K Ohm load
[/quote]
I have a strong feeling you are being deliberately obtuse here.
You specifically model a stupidly low PWM rate and then decide to slap a 1K load onto an RC filter in an attempt to make some sort of point.
Does this even try to help the OP in any way?
So, go on... go get yourself a DAC module (the MCP4725 has been mentioned) and stick your 1K load on that and see what it does (not terrible, I'll admit, but far from ideal).
Or perhaps model a much more reasonable PWM rate and try the (assumed) expected load of c. 250kohm.
Maybe even consider helping by suggesting that a buffer may be needed (for filtered PWM or DAC) if the Paramecium species is, instead of fresh water, in particularly salty water and the load resistance is actually very low.
Yours,
** TonyWilk**
Does this even try to help the OP in any way?
Yes, it clearly shows the fatal weakness of your proposal, which offered complete confidence that this would solve the OP's problem, without knowledge of the impedance of the OP's target circuitry.
It steers the OP towards the more practical and realistic approaches suggested by others, such as using an inexpensive DAC.
You specifically model a stupidly low PWM rate
Ummm, 1 kHz, which is over twice the frequency chosen by the Arduino designers for the analogWrite PWM signal, which on most pins is approximately 490 Hz. The output ripple would have been much worse if I had chosen the actual frequency of the analogWrite signal.
Note to the OP:
The output impedance of the Adafruit MCP4725 DAC module is 1 Ohm, and it can supply 25 mA of current to the target device.
So, it can easily handle low impedance loads (down to about 200 Ohms) without the need for a buffer amplifier, as suggested by the previous poster.
The medium in which the Paramecium Caudatum will be in is less than 1 ml of fresh water. The filtered PWM signal will be running through the water with ground across the other side of the well. For electrodes I plan on using 0.7mm graphite found in mechanical pencils. Also i will be using 1/4 inch wide copper tape to wrap around graphite and transfer the filtered signal from the output wire to the graphite electrode. Will the RC filter shown in reply 1 and also the adafruit DAC be suitable for this impedance load.
I wouldn't want to resort to using a DAC as i'm positioning many electrodes on the well which will all require a filtered pwm signal and don't want this project to get too expensive. An RC filter sounds cool too. I don't mind the filter taking too long to get to the target voltage btw.
I think you are fine witth n RC filter. I suspect above discussion came to be due to Tony's problematic presentation (from not mentioning to set he Arduino to a reasonable PWM frequency to claiming applicability to "all practical purposes").
You want a constant voltage, you don't mind delays ... if RC filtering PWM is for anyone, it is probably for you.
What is the goal of this experiment?
jremington:
The output impedance of the Adafruit MCP4725 DAC module is 1 Ohm, and it can supply 25 mA of current to the target device.So, it can easily handle low impedance loads (down to about 200 Ohms) without the need for a buffer amplifier, as suggested by the previous poster.
To anyone: Read the datasheet yourself, make up your own mind. It's your project.