HLG Arduino Dimming

CannaBruh

Well-Known Member
What is the potentiometer doing in your HLG circuit? Now make the arduino emulate that.

How did you automate a whole room on arduino but not perform the function of a pot with arduino? Did you copy/paste code to get your room working?
 

sleepless_canuck

Well-Known Member
I learned some basic code and learned from multiple setups online.

As well as Blynk community.

I have read conflicting information about dimming the HLG driver so I was mainly curious if anyone had done it successfully.
 

CannaBruh

Well-Known Member
I get that, but what I'm getting at is do you understand what the potentiometer is doing in circuit with your HLG?

Once you understand that, then make the arduino do that thing.
 

BobCajun

Well-Known Member
You hook an optocoupler to the Arduino PWM output, hook the dimmer leads to the output of the optocoupler and use a code like this. The optocoupler reverses things so low in the code is actually the on time and high is the off time. You also need a 250 ohm resistor on the output from the Arduino before it gets to the optocoupler.The reason for the optocoupler is that the output is 5v rather than the 10v required by the driver dimmer. The driver produces it's own 10v power for the dimming, you just need the optocoupler to open and close the dimmer wire circuit with its 5v PWM output.

In this code I arbitrarily chose to use microseconds and the on/off ratio shown. I tried a bunch of different duty cycles. BTW with PWM you don't gain any efficiency from dimming the LEDs, because they're still on full power during the on part of the duty cycle.
void setup()
{
pinMode(13, OUTPUT);
}

void loop()
{
digitalWrite(13, HIGH);
delayMicroseconds(100); // Approximately 84% duty cycle @ 1KHz
digitalWrite(13, LOW);
delayMicroseconds(500);
}
 
Last edited:

BobCajun

Well-Known Member
Actually I just thought of something. Since an Arduino puts out 5v and 5v makes the driver dim to 50%, you might be able to wire it straight up, as long as you only want the driver to be at 50% current during the on part of the duty cycle. That means you could run the LEDs at half the driver current and get an efficiency gain and also avoid getting an opto and a resistor. I don't know what the current is for the Arduino PWM output though offhand. You'd have to make sure it's within the range that the driver dimmer circuit can handle. So say you want the LEDS to run at 700 ma during the on cycle. You would use a 1400 ma driver. And the code would be normal, not reversed.

Honestly I don't know how it would turn out if you hooked it up direct. I did find out that the Arduino PWM signal is 40 ma though. But I don't know how much the driver can take. The optocoupler method worked for me though. When the cycle is in the off phase I think the LED is still at 10% power though, because that's as far down as they can go. They never actually go all the way to zero, even with a potentiometer. This page has some info on meanwell dimming. Apparently there are complications with the HLG B type drivers.
 
Last edited:

Timothypaul26

Well-Known Member
There are a lot of controllers being made for fish tanks that are emulating the bulk of what we are trying to do as growers. There are even pretty cheap controllers available made from Arduino platforms for this purpose. They have some very good codes, and habe been very good references for me. I would not recommend connecting the dim leads directly to your arduino. I can't remember the ma output of the half, but arduino can't handle supplying or taking in much power. I know output on megas are around 50ma. To answer your question though. Many have been successful making dim loops on arduino for the hlg, but it will be inverted logic if using a transducer, which is the easiest way to go imo.
 

dstroy

Well-Known Member
I currently have a fit COB fixture and my room is fully automated through an arduino mega.

Has anyone on here figured how to dim HLG drivers using code instead of a potentiometer?

This is my last hurdle.

Here a pic of my app.
Yes, get a mosfet pwm thing from amazon

https://www.amazon.com/gp/aw/d/B01K7HZEO2/ref=sxts_1?ie=UTF8&qid=1506263453&sr=1&pi=AC_SX236_SY340_QL65

And 10v source for the dimming circuit.

Works great, very reliable.

You don't need the 4 channel one, but every driver you want to dim should be on its own channel.

Let me know if you need help with the code.
 

dstroy

Well-Known Member
You hook an optocoupler to the Arduino PWM output, hook the dimmer leads to the output of the optocoupler and use a code like this. The optocoupler reverses things so low in the code is actually the on time and high is the off time. You also need a 250 ohm resistor on the output from the Arduino before it gets to the optocoupler.The reason for the optocoupler is that the output is 5v rather than the 10v required by the driver dimmer. The driver produces it's own 10v power for the dimming, you just need the optocoupler to open and close the dimmer wire circuit with its 5v PWM output.

In this code I arbitrarily chose to use microseconds and the on/off ratio shown. I tried a bunch of different duty cycles. BTW with PWM you don't gain any efficiency from dimming the LEDs, because they're still on full power during the on part of the duty cycle.
That's not true, for example a 500w load @50% duty cycle is 250w RMS. It's still on 100%, but for 50% as long, so it "uses" half of the power. Hooking a multimeter up to a 10v source and then reducing the duty cycle by 50% causes the multimeter to "see" 5v, because it's 5vrms even though the source is 10v.

The meanwell HLG drivers DO NOT produce their own 10v for dimming.
 

kkookoo

Well-Known Member
There are a lot of controllers being made for fish tanks that are emulating the bulk of what we are trying to do as growers. There are even pretty cheap controllers available made from Arduino platforms for this purpose. They have some very good codes, and habe been very good references for me.
Can you provide some links to these? I've been looking for something I can use on an arduino for years and have come up with nothing.
 

4ftRoots

Well-Known Member
Easiest way right here.

Get this: https://www.amazon.com/gp/product/B01JG8EJVW/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1
It is basically a high frequency relay. Allows you to control through pwm.

Connect pin 1 -> arduino pwm out
Connect pin 2 -> arduino ground
Connect pin 3 -> dim + on driver
Connect pin 4 -> dim - on driver

There you go. 0% duty cycle is 100% brightness. 100% dutycycle is lowest brightness. I run my pwm at like 100hz.

Get money!

As an added bonus. Check out Mycodo here: https://github.com/kizniche/Mycodo
It's a neat RPI environmental controller. You can do it all.

I'm interested in your arduino setup. Care to share code or point me to the library your using?

Thanks!
 

kkookoo

Well-Known Member
I figured it out I figured it out

goto DFRobot.com and search for potentiometer. You can get a little circuit board for 5$ I think that can control two hlg based off the 100k ohm dimming option. No circuit design, just plug the wires and go with simple code. And I think it’s i2c so you can daisy chain them. If you want to make your own circuit board you can buy the chips from digikey that do 4 drivers with through hole and copy the circuit that DFRobot made they post the schematic.. if you can surface mount solder you can get one that does 6 drivers for like less than 3 dollars per chip with the needed parts

but the easiest way is just get a bunch of the premade ones from DFRobot and chain them together

I use the wemos mini so I was going to get custom boards made from one of those cheap china board makers and use the through hole chips and parts and make my own 4 driver versions that fit into wemos minis .. fuck yea
 

Timothypaul26

Well-Known Member
Can you provide some links to these? I've been looking for something I can use on an arduino for years and have come up with nothing.
Sorry for the late response, notifications got turned off on me. Here are a couple of options.


 

Timothypaul26

Well-Known Member
I figured it out I figured it out

goto DFRobot.com and search for potentiometer. You can get a little circuit board for 5$ I think that can control two hlg based off the 100k ohm dimming option. No circuit design, just plug the wires and go with simple code. And I think it’s i2c so you can daisy chain them. If you want to make your own circuit board you can buy the chips from digikey that do 4 drivers with through hole and copy the circuit that DFRobot made they post the schematic.. if you can surface mount solder you can get one that does 6 drivers for like less than 3 dollars per chip with the needed parts

but the easiest way is just get a bunch of the premade ones from DFRobot and chain them together

I use the wemos mini so I was going to get custom boards made from one of those cheap china board makers and use the through hole chips and parts and make my own 4 driver versions that fit into wemos minis .. fuck yea
This is a pretty clean and quick way to get going, nice find. Only concern I have, is trying to get a dimming cycle clean enough that it won't bug my eyes. If you happen to be in the garden at sunrise or sunset, it will likely be a lot of flickering effects. Most notably at the lower end <15%. If you get this going I'd love to hear how well it works for you, please report back.
 

kkookoo

Well-Known Member
This is a pretty clean and quick way to get going, nice find. Only concern I have, is trying to get a dimming cycle clean enough that it won't bug my eyes. If you happen to be in the garden at sunrise or sunset, it will likely be a lot of flickering effects. Most notably at the lower end <15%. If you get this going I'd love to hear how well it works for you, please report back.
Why would you have flickering effects? You’re assuming that it works like pwm, it’s not it’s a digital potentiometer, it’s the equivalent of using a resistance dimming knob, not pwm
 

Timothypaul26

Well-Known Member
Why would you have flickering effects? You’re assuming that it works like pwm, it’s not it’s a digital potentiometer, it’s the equivalent of using a resistance dimming knob, not pwm
I guess I am making that assumption, in that the I2C will create a similar effect. I am unfamiliar with the digital pots.
 

kkookoo

Well-Known Member
I guess I am making that assumption, in that the I2C will create a similar effect. I am unfamiliar with the digital pots.
With all the assuming on these forums it would be worth trying and then reporting. One reason I got off social media (and ditched my real accounts and made this one), is because everyone has an opinion but not many people actually know.

I haven't ordered mine yet, I was going to buy the components to test first, then go through a chinese board manufacturer and make my own custom wemos mini shields.
 
Top