Go Down

Topic: Variable DC Output of Arduino (Read 7134 times) previous topic - next topic

fussballspieler

Hello,

I need to control some coils for a focusing lens using a constant DC current. Unfortunately the Arduino only has the Digital Out (0 or 5 V) or the PWM outputs (AnalogWrite) which will not really work for this purpose since the coil needs to remain fixed at a specific location. Any suggestions on what would be the best method to accomplish this?
Is a simple DAC the best solution ( which one would be best suited for this?), or is filtering the PWM signal a better option, (The ripple needs to be very small though)
The output needs to be a DC voltage (0-5V) that can be controlled from the microcontroller. The coils operate in the range of -5V to 5V (I will use two transistors for this purpose since the current is above the max output of the Arduino)

Thank you

CrossRoads

Sure, get any simple D/A converter to do that. 8-12-16 bit converters are all readily with I2C or SPI interfaces.
In fact, Analog Devices is holding a webinar on DACs tomorrow, I posted the link to it quite recently, should be easy to find.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Grumpy_Mike

Quote
the PWM outputs (AnalogWrite) which will not really work for this purpose since the coil needs to remain fixed at a specific location

Why should that preclude using it? All you need is the appropriate RC filter.
See :-
http://www.thebox.myzen.co.uk/Tutorial/PWM.html

Onions

I recently wrote a library and designed some hardware for this. You can see the arduino topic about it here. I have also put a writeup about it on my website. You can download the library here. Let me know if you find it useful!

Onions.
My website: http://www.harryrabbit.co.uk/electronics/home.html Up and running now! (Feel free to look round!) :D

MarkT

What's the resolution, ripple and bandwidth requirements?
[ I won't respond to messages, use the forum please ]

Verdris

I'm having this problem, too.  My particular problem stemmed from an incomplete knowledge of exactly how square waves work.

I was initially under the impression that a square wave of any duty cycle would still drive at 5V, but, from Wikipedia:

"The average level of a square wave is also given by the duty cycle, so by varying the on and off periods and then averaging, it is possible to represent any value between the two limiting levels."

So a 50% duty cycle should give ~2.5V, exactly what my scope was reading.  Now, my challenge is to just amplify the 50% duty cycle to pump out I guess 10V, for a 5V average to drive my lasers.

retrolefty

Quote
So a 50% duty cycle should give ~2.5V, exactly what my scope was reading.  Now, my challenge is to just amplify the 50% duty cycle to pump out I guess 10V, for a 5V average to drive my lasers.


One would simply use the arduino pwm output signal to drive a switching transistor wired to the load (laser?) and it's desired maximum voltage used (+10vdc?). A 50% duty cycle pwm will always end up with a 50% average voltage of whatever source voltage one is applying the switcing signal to.

Lefty


Grumpy_Mike

Quote
I was initially under the impression that a square wave of any duty cycle would still drive at 5V


It will, that is 5V is the peak voltage. What that Wikipedia page is saying is that the average voltage taken over the time of a cycle will be 2.5V. This is made up of half the time it being 5V and the other half of the time it being 0V so on average it is 2.5V. This 2.5V is never actually produced unless you smooth it.

For a nice animated view of a PWM signal see:-
http://www.thebox.myzen.co.uk/Tutorial/PWM.html

Go Up