Pages: [1]   Go Down
Author Topic: Variable DC Output of Arduino  (Read 6399 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 538
Posts: 27097
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34184
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Newcastle, England
Offline Offline
Sr. Member
****
Karma: 3
Posts: 489
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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

0
Offline Offline
Shannon Member
****
Karma: 206
Posts: 12179
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What's the resolution, ripple and bandwidth requirements?
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Full Member
***
Karma: 1
Posts: 117
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17294
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34184
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: [1]   Go Up
Jump to: