Variable resistance to control MEAN WELL HLG-120H-42B

I would like to control LED lighting being run by a MEAN WELL HLG-120H-42B. I know I can easily do this with a easily with a PWM signal, but that is not what I want to do. Ideally, I would output an average of 50% brightness, with time periods that are higher output and others that are lower. Running a LED with 50% the current is significantly more efficient that using a PWM to run it at 100% of the current and flickering it on and off 50% of the time.

This involves either a simply voltage signal between 0 and 10 volts, or variable resistance (like a potentiometer) on a 10 volt line, both do the same thing. Here are the specs if you need more detail:
https://www.jameco.com/Jameco/Products/ProdDS/2148210.pdf

My actual project is my aquarium lighting, which will use 8 drivers total, 2 of which are HLG-120H-42B's.

BTW - is there an easy way to simply turn a driver on/off using and arduino? Most likely with a switch at the AC current before it even hits the driver.

I believe what you want is a DAC (digital to analog converter). This blog listed the DAC solutions that were available in 2011: Embedded newbie: Review of Arduino DAC solutions

The new Due has 2 DAC's built in (though evidently there was a library bug that you could only use 1, but that will be fixed shortly). Of course it will take some time before you can buy a Due from a vendor that has it in stock.

I believe what you want is a DAC (digital to analog converter). This blog listed the DAC solutions that were available in 2011: Embedded newbie: Review of Arduino DAC solutions
The new Due has 2 DAC's built in (though evidently there was a library bug that you could only use 1, but that will be fixed shortly).

A DAC would be nice, but I certainly could make this work with other options. For example, if I could use a digital output to set my signal to either 0V (full power) or 5V(half power) I could choose either 100% or 50% power. If I could carry a PWM signal on the same circuit, I'd have full dimming capability with full efficiency at 50% and 100% power (but sub-optimal for in-between values).

Of course it will take some time before you can buy a Due from a vendor that has it in stock.

Do you mean a few days or a few years?

Running a LED with 50% the current is significantly more efficient that using a PWM to run it at 100% of the current and flickering it on and off 50% of the time.

Really???? The total power consumed (watt-hours) is the same in either case. (I don't know if the perceived brightness is the same, but I'd assume so.)

If you just want two ranges, you don't need a full DAC. I haven't got the details completely figured-out in my head, but you can simply use two Arduino outputs.... One switching-on 5V, and another switching-on 10V.

Or, you can low-pass filter the regular PWM to get a smooth DC signal. (You'd need an op-amp to linearly double the filtered 0-5V output.)

bvbellomo:

Of course it will take some time before you can buy a Due from a vendor that has it in stock.

Do you mean a few days or a few years?

I have no idea how backordered the Due is (it was just announced last week). Days is too short of a time period, years too long. If I had to guess, by January time frame it should be easily available like the Uno is now.

Really???? The total power consumed (watt-hours) is the same in either case.

Both consume almost exactly the same power, with probably a trivial difference due to driver inefficiencies.

(I don't know if the perceived brightness is the same, but I'd assume so.)

Nope, not linear. For example CREE XPE-Green gives me about 25% more output at 500mA than it does cycling 1000mA 50% of the time:
http://www.cree.com/led-components-and-modules/products/xlamp/discrete-directional/~/media/Files/Cree/LED%20Components%20and%20Modules/XLamp/Data%20and%20Binning/XLampXPE.pdf

This isn't a big deal if you plan to do a 1 hour ramp up/ramp down with 10 hours in the middle of the day at full power, which is what most aquarists do, but what is the fun in that? Ideally I'd like to have 6 hours ramping up and 6 hours ramping down with further ramping down to simulate for cloud cover. Sounds complicated, but it really isn't much harder from a hardware perceptive, and Arduino is capable of much more complex programs.

If you just want two ranges, you don't need a full DAC. I haven't got the details completely figured-out in my head, but you can simply use two Arduino outputs.... One switching-on 5V, and another switching-on 10V.

I didn't know it could switch on 10V, but even switching between 0 and 5V on the same output that carries my PWM could work.

Or, you can low-pass filter the regular PWM to get a smooth DC signal. (You'd need an op-amp to linearly double the filtered 0-5V output.)

This sounds perfect, but I'm a software guy, can you give me a gentle introduction to the hardware I would need to buy to low pass an Arduino PWM output to get a smooth 0-10V DC signal?

If I had to guess, by January time frame it should be easily available like the Uno is now.

That is perfect for me. I am getting married and have to completely renovate my house, and this is just a side project.

even switching between 0 and 5V on the same output that carries my PWM could work.

That was a mistake, it gives good efficiency and good control between 50%-100% power, but I can't dim below 50% that way. Going between 0, 5 and 10 with a PWM would work.

How does the PWM output work? Is there an input that corresponds to the output? For example, can I just hook 10V somewhere and output a 0-10V PWM signal? Or I am forced to output at 5V and someone how need to turn this into 10V?

bvbellomo:
How does the PWM output work? Is there an input that corresponds to the output? For example, can I just hook 10V somewhere and output a 0-10V PWM signal? Or I am forced to output at 5V and someone how need to turn this into 10V?

If you are using PWM from an Arduino it will be the same voltage level as what is powering the microprocessor IC (usually 5 VDC but sometimes 3.3 VDC. You will need some type of amplifying or level shifting circuitry to increase the signal to a higher voltage level.

As far as correlating input all the following assumes your inputs are configured for the same voltage level as the PWM signal...

PWM is a square wave, so a digital input would read it either LOW or HIGH depending upon what part of the waveform the signal is on the pin at any given time. If you have the proper logic, either software or hardware-based), you could determine things like frequency and duty cycle. ADC is intended for true analog signals, not digital pulses, but most of the time would read close to the extremes of the range of numbers used for the conversion (e.g. around 0 for when the signal is LOW and for HIGH around 2n - 1, where "n" is the number of bits of resolution). The only time you'd see a number toward the middle is if the ADC managed to catch some part of the near instantaneous transition between the two extremes. So generally nothing is gained by using ADC on a PWM signal, unless it is coupled with some sort of buffer or record of past values (like in a digital oscilloscope).

If you are using PWM from an Arduino it will be the same voltage level as what is powering the microprocessor IC (usually 5 VDC but sometimes 3.3 VDC. You will need some type of amplifying or level shifting circuitry to increase the signal to a higher voltage level.

Any suggestions as to how to amplify the signal?

PWM is a square wave, so a digital input would read it either LOW or HIGH depending upon what part of the waveform the signal is on the pin at any given time. If you have the proper logic, either software or hardware-based), you could determine things like frequency and duty cycle. ADC is intended for true analog signals, not digital pulses, but most of the time would read close to the extremes of the range of numbers used for the conversion (e.g. around 0 for when the signal is LOW and for HIGH around 2n - 1, where "n" is the number of bits of resolution). The only time you'd see a number toward the middle is if the ADC managed to catch some part of the near instantaneous transition between the two extremes. So generally nothing is gained by using ADC on a PWM signal, unless it is coupled with some sort of buffer or record of past values (like in a digital oscilloscope).

By ADC, are you referring to the DAC on the Duo? Does this mean the Duo can't output a constant 1.2345 V signal, for example? Anyone, I think the correct road to go down is using a capacitor as a low-pass filter for the standard PWM. I could get this working first with PWM only, then try to add the filter.

The Uno advertises: Digital I/O Pins 14 (of which 6 provide PWM output). Does this mean I get 6 separate PWM outputs? Or do I only get 3 (if a negative and positive pin are needed for each) or some other number?

Even if I get 6 PWM signals, that isn't enough. Can someone suggest which Arduino I would want?

bvbellomo:
The Uno advertises: Digital I/O Pins 14 (of which 6 provide PWM output). Does this mean I get 6 separate PWM outputs? Or do I only get 3 (if a negative and positive pin are needed for each) or some other number?

Even if I get 6 PWM signals, that isn't enough. Can someone suggest which Arduino I would want?

You get 6 separate PWM outputs. Note, that if you use the servo library, it disables PWM for 2 of the outputs (pin 9 and 10).

The Mega 2560 provides 15 PWM pins, the recently announced Due has 12 PWM pins. The teensy 3.0 has 10 PWM pins.

I posted the 5V to 10V question on an aquarium forum, and most people are using a separate 10V supply and an NPN 2N2222 transistor to switch between 10V and ground. All the PWM from Arduino does is control the transistor.

If I go with this approach, the DAC is useless since I don't want an analog signal sent to my transistor. But I can still use the capacitor low pass filter trick.

The Mega 2560 provides 15 PWM pins, the recently announced Due has 12 PWM pins. The teensy 3.0 has 10 PWM pins.

Other than cost, any reason not to just use a Mega? The Due has more computing power, but I think they all have more than I need.

bvbellomo:
Any suggestions as to how to amplify the signal?

You could use a transistor (either BJTs or MOSFETs would work) and some resistors for a simple level converting circuit (as in this schematic).

Or you could use an op-amp based non-inverting amplifier with a voltage gain of about 3.85, but since a PWM signal is digital there's no innate advantage to use this method.

bvbellomo:
By ADC, are you referring to the DAC on the Duo? Does this mean the Duo can't output a constant 1.2345 V signal, for example? Anyone, I think the correct road to go down is using a capacitor as a low-pass filter for the standard PWM. I could get this working first with PWM only, then try to add the filter.

No, I'm referring to analog-to-digital conversion and this capability exists in some form on all official (and probably all non-official) Arduino boards, not just the Due. DAC, or digital-to-analog conversion is basically the opposite process and the Due is currently the only official Arduino board to have real DAC outputs. In some circumstances PWM (which again all Arduinos have) can be used to effectively simulate ADC, but that really only works with some types of parts.

I don't know if the Due can output exactly 1.2345 VDC. However, since it's DAC has 12-bit resolution that means there are 4,096 distinct voltage levels it can output between 0 and 3.3 VDC. So even if it cant output that specific value it can get very close. By the way, if you wanted to amplify an analog voltage like this than you would need something like the op-amp based amplifier I mentioned before, rather than just a logic level shifter.

I don't know if the Due can output exactly 1.2345 VDC. However, since it's DAC has 12-bit resolution that means there are 4,096 distinct voltage levels it can output between 0 and 3.3 VDC. So even if it cant output that specific value it can get very close

That is good enough, it doesn't need to be very close. From the early description of the DAC I thought this might only output a wave, for example, a smooth wave between 0 and 1.2345 V at a specific frequency.

Or you could use an op-amp based non-inverting amplifier with a voltage gain of about 3.85

Can you tell me more about this? I am a software guy. I see some very cheap op-amps online, but they all have much larger voltage gains. Also, why 3.85? 3.3V (or 5V) + 3.85V is less than 10V

bvbellomo:
That is good enough, it doesn't need to be very close. From the early description of the DAC I thought this might only output a wave, for example, a smooth wave between 0 and 1.2345 V at a specific frequency.

A DAC takes an integer value (specifically a number between 0 and 2n-1, where n is the resolution in bits) each cycle and outputs a voltage level between the minimum and the maximum output voltage. For example, on the Due 0 would be 0 VDC and 4,095 would be 3.3 VDC; but many DACs have a much wider output voltage range, including negative voltages on some. If you want a constant output, just keep feeding the DAC the same integer value. If you want some sort of waveform vary the integer value so you get the frequency and wave shape you want.

bvbellomo:
Can you tell me more about this? I am a software guy. I see some very cheap op-amps online, but they all have much larger voltage gains. Also, why 3.85? 3.3V (or 5V) + 3.85V is less than 10V

Amplification is generally expressed as a factor (AV) that's either the ratio of output over input , AV = VOUT / VIN , or multiplied with the input to get the desired output, AV * VIN = VOUT. Regarding the value of 3.85, for some reason I thought the desired voltage was 12 VDC not 10 VDC. 3.85 * 3.3 VDC = 12.705 VDC So you'd have enough for 12 VDC plus the forward voltage drop of a standard diode to prevent any back EMF.

Can you post an example of an amplifier similar to what might work to give me a better idea?

If this maxes out at 9V, I lose a small amount of dimming range (lowest brightness settings) which is not a big deal. If this maxes out at 12V and blows my driver ($20-$100) this is a big deal.

bvbellomo:
Can you post an example of an amplifier similar to what might work to give me a better idea?

The gain for an op-amp is usually set using two or more resistors, there exact configuration is based on what type of amplification circuit you use. In a non-inverting amplifier you'd normally have two resistors (R1 & R2) configured similar to a voltage divider between the output and ground, with point between R1 and R2 going to the inverting input ("-" or "V-" on schematics) of the op-amp. The ratio between them determines the gain, for many op-amp "families" the formula for voltage gain will be AV ? (R1/R2)+1 but check the datasheets for the exact performance of a specific part. The other connections are straight-forward the non-inverting input is connected to the input voltage, and the positive power supply pin needs to be at least as high as your desired output voltage level (it doesn't matter if it's higher) and your negative power supply pin will be grounded (Aside: most op-amps can have negative voltages but in this case you don't want to do that).

Here's an example of a non-inverting amplifier using a LM358N op-amp. If you were to use that op-amp and wanted to output exactly 10 VDC from exactly 3.3 VDC, the voltage gain would need to be 3.0303... (i.e. AV = VOUT / VIN = 10/3) Therefore, the ratio of resistor values should be 2.03... (i.e. R1/R2 = AV - 1 = 3.03... - 1). The exact resistance values you use are less important than achieving the necessary ratio of resistance values.

Edit: Here's a [url=http://www.allaboutcircuits.com/vol_3/chpt_8/1.html[/url] on using op amps...