Welcome
Username or Email:

Password:


Missing Code




[ ]
[ ]
Online
  • Guests: 64
  • Members: 1
  • Newest Member: omjtest
  • Most ever online: 396
    Guests: 396, Members: 0 on 12 Jan : 12:51
Members Birthdays:
All today's birthdays', congrats!
Download (31)
ScottH (37)


Next birthdays
11/03 Electroguy (94)
11/04 nitromarsjipan (2024)
11/04 mb (31)
Contact
If you need assistance, please send an email to forum at 4hv dot org. To ensure your email is not marked as spam, please include the phrase "4hv help" in the subject line. You can also find assistance via IRC, at irc.shadowworld.net, room #hvcomm.
Support 4hv.org!
Donate:
4hv.org is hosted on a dedicated server. Unfortunately, this server costs and we rely on the help of site members to keep 4hv.org running. Please consider donating. We will place your name on the thanks list and you'll be helping to keep 4hv.org alive and free for everyone. Members whose names appear in red bold have donated recently. Green bold denotes those who have recently donated to keep the server carbon neutral.


Special Thanks To:
  • Aaron Holmes
  • Aaron Wheeler
  • Adam Horden
  • Alan Scrimgeour
  • Andre
  • Andrew Haynes
  • Anonymous000
  • asabase
  • Austin Weil
  • barney
  • Barry
  • Bert Hickman
  • Bill Kukowski
  • Blitzorn
  • Brandon Paradelas
  • Bruce Bowling
  • BubeeMike
  • Byong Park
  • Cesiumsponge
  • Chris F.
  • Chris Hooper
  • Corey Worthington
  • Derek Woodroffe
  • Dalus
  • Dan Strother
  • Daniel Davis
  • Daniel Uhrenholt
  • datasheetarchive
  • Dave Billington
  • Dave Marshall
  • David F.
  • Dennis Rogers
  • drelectrix
  • Dr. John Gudenas
  • Dr. Spark
  • E.TexasTesla
  • eastvoltresearch
  • Eirik Taylor
  • Erik Dyakov
  • Erlend^SE
  • Finn Hammer
  • Firebug24k
  • GalliumMan
  • Gary Peterson
  • George Slade
  • GhostNull
  • Gordon Mcknight
  • Graham Armitage
  • Grant
  • GreySoul
  • Henry H
  • IamSmooth
  • In memory of Leo Powning
  • Jacob Cash
  • James Howells
  • James Pawson
  • Jeff Greenfield
  • Jeff Thomas
  • Jesse Frost
  • Jim Mitchell
  • jlr134
  • Joe Mastroianni
  • John Forcina
  • John Oberg
  • John Willcutt
  • Jon Newcomb
  • klugesmith
  • Leslie Wright
  • Lutz Hoffman
  • Mads Barnkob
  • Martin King
  • Mats Karlsson
  • Matt Gibson
  • Matthew Guidry
  • mbd
  • Michael D'Angelo
  • Mikkel
  • mileswaldron
  • mister_rf
  • Neil Foster
  • Nick de Smith
  • Nick Soroka
  • nicklenorp
  • Nik
  • Norman Stanley
  • Patrick Coleman
  • Paul Brodie
  • Paul Jordan
  • Paul Montgomery
  • Ped
  • Peter Krogen
  • Peter Terren
  • PhilGood
  • Richard Feldman
  • Robert Bush
  • Royce Bailey
  • Scott Fusare
  • Scott Newman
  • smiffy
  • Stella
  • Steven Busic
  • Steve Conner
  • Steve Jones
  • Steve Ward
  • Sulaiman
  • Thomas Coyle
  • Thomas A. Wallace
  • Thomas W
  • Timo
  • Torch
  • Ulf Jonsson
  • vasil
  • Vaxian
  • vladi mazzilli
  • wastehl
  • Weston
  • William Kim
  • William N.
  • William Stehl
  • Wesley Venis
The aforementioned have contributed financially to the continuing triumph of 4hv.org. They are deserving of my most heartfelt thanks.
Forums
4hv.org :: Forums :: General Science and Electronics
« Previous topic | Next topic »   

PWM to Analog

1 2 
Move Thread LAN_403
EEYORE
Mon Jul 19 2010, 09:03PM Print
EEYORE Registered Member #99 Joined: Thu Feb 09 2006, 06:10PM
Location: florida, usa
Posts: 637
Hello all,
I am building a high power LED light for my reef tank and need some help. I want to use some driver boards I made a while ago meant for driving high power lasers via an op-amp and mosfet. A voltage divider using a voltage reference varies the current from zero up to max.

Now what I need to do is be able to use a micro controller to control this current controller so that I can have special effects and special control over the leds. I know that most the microcontrollers out there that reefers like to use, use PWM output. I need to hook up the controller I made (that uses a voltage to control current) right up to a PWM output.

Can I use something like a resistor and capacitor style filter?

Thanks!
Matt
Back to top
Bjørn
Mon Jul 19 2010, 10:10PM
Bjørn Registered Member #27 Joined: Fri Feb 03 2006, 02:20AM
Location: Hyperborea
Posts: 2058
Yes as long as you don't have any special requirements when it comes to bandwidth. Connect a capacitor between ground and the PWM output using a series resistor. Make sure the rest of your circuit does not place any load on the capacitor.

Back to top
EEYORE
Mon Jul 19 2010, 10:33PM
EEYORE Registered Member #99 Joined: Thu Feb 09 2006, 06:10PM
Location: florida, usa
Posts: 637
Hello,
There shouldnt be any load on the PWM output since it is controlling the voltage on the op-amp input pin. How should I calculate this RC filter? Im guessing it will depend on the PWM?


Anything in particular to consider about using this method? I have seen a few people using an op-amp to actually perform this task. Might I be able to just skip the RC filter since I am using this as an input to the op-amp inplace of its current voltage reference+divider method to get a variable (and stable) voltage?

Thanks!
Matt
Back to top
Bjørn
Tue Jul 20 2010, 12:06AM
Bjørn Registered Member #27 Joined: Fri Feb 03 2006, 02:20AM
Location: Hyperborea
Posts: 2058
If you want a voltage you need a filter, a simple RC filer or something more advanced. It may work without and run control the LEDs by PWM or it might destroy the LEDs, it all depends.

The cut off frequency is 1/(2*PI*R*C), that is the frequency that will be halved in power after passing through the filter.
Back to top
Pinky's Brain
Tue Jul 20 2010, 12:36AM
Pinky's Brain Registered Member #2901 Joined: Thu Jun 03 2010, 01:25PM
Location:
Posts: 837
Just PWM switching the LEDs directly is a lot more energy efficient of course.
Back to top
EEYORE
Tue Jul 20 2010, 02:11AM
EEYORE Registered Member #99 Joined: Thu Feb 09 2006, 06:10PM
Location: florida, usa
Posts: 637
Thanks guys...

I chose to avoid PWM as the main way to control the LEDs so that I could just use my on board voltage reference+divider to mix two different strings of LEDs. Blue (460nm) and white (6500k). I can dim the whites with one trimpot and as a result have a more blue looking tank. Or I could dim the blues for a more white looking tank. If I choose to use a microcontroller to do all this for me, then I can switch the op-amps inputs (its a dual op-amp) over to a microcontroller via the RC filters to turn the PWM into a voltage.

This can also double as a very high power laser diode driver. smile

Sound good?
Matt
Back to top
UltraMagnus
Tue Jul 20 2010, 06:03AM
UltraMagnus Registered Member #2875 Joined: Mon May 24 2010, 08:28AM
Location: England
Posts: 42
A lot of PIC microcontrollers have an analogue output, not sure if that may be easier
Back to top
Mattski
Tue Jul 20 2010, 07:48AM
Mattski Registered Member #1792 Joined: Fri Oct 31 2008, 08:12PM
Location: University of California
Posts: 527
Since you're not using this PWM to actually drive the LED's, and little current will flow to the opamp, you should make the cutoff frequency pretty low just to filter the signal better. I would put the filter cutoff a decade (factor of 10) or more below your switching frequency. There is a tradeoff in that if you need to be able to quickly change that filtered analog voltage, you need the cutoff frequency to be higher. But 50Hz is probably a good conservative upper bound, so for example 500Hz cutoff will give you tons of signal bandwidth while probably filtering it pretty good too.

edit: If you want to know where the filter theory comes from, take a look at Link2 As Bjorn pointed out an RC filter is a first order filter with a cutoff of 1/(2*pi*R*C). At low frequencies, including 0Hz (for an unchanging DC output voltage), the voltage gain of the filter is 1: no gain and no loss. At frequencies above the cutoff frequency, the gain basically decreases a factor of 10 for every factor of 10 increase in frequency.

The PWM signal that you are filtering consists of the DC or average component that you want to be output as a constant voltage, plus sine waves at the switching frequency of the PWM and its harmonics. If you make a first order filter with a cutoff at 1/10 the switching frequency you will thus be attenuating the switching components by a factor of 10 or more.
Back to top
lightlinked
Tue Jul 20 2010, 10:48AM
lightlinked Registered Member #2087 Joined: Tue Apr 21 2009, 08:32AM
Location:
Posts: 115
wouldnt it be more ideal to use a high power led driver SMPS buck controller? it would be more efficient since it would be a constant current LED controller based on a switching design so you would not be dissipating power away as heat for current limiting as a linear design would.
Back to top
radiotech
Tue Jul 20 2010, 03:40PM
radiotech Registered Member #2463 Joined: Wed Nov 11 2009, 03:49AM
Location:
Posts: 1546
First, does your micro have an output that can be configured as an analog output?

Can you add a photoresistive element to your current controllers input system of voltage dividers such that if a light shines on the element the resistance drops? A CdS cell does this. Then get the PWM output to light a While LED shining on the CdS cell. This will give you isolation. Connect a 0.47ufd capacitor across the CdS cell.

If the PWM output source 0.06 Amps-, use a 2 volt #49 lamp instead of the LED.
Back to top
1 2 

Moderator(s): Chris Russell, Noelle, Alex, Tesladownunder, Dave Marshall, Dave Billington, Bjørn, Steve Conner, Wolfram, Kizmo, Mads Barnkob

Go to:

Powered by e107 Forum System
 
Legal Information
This site is powered by e107, which is released under the GNU GPL License. All work on this site, except where otherwise noted, is licensed under a Creative Commons Attribution-ShareAlike 2.5 License. By submitting any information to this site, you agree that anything submitted will be so licensed. Please read our Disclaimer and Policies page for information on your rights and responsibilities regarding this site.