Github Boards Devices Community Docs Blog

Node Red & ZactuatorPWM Not working - Solved. Operator error

I am using the ZactuatorPWM. My use case is to control a Mean Well PWM-120 LED driver. The issue I need help with is:
I cannot get the PWM to change when I send via Node Red, but it works when I use a mosquitto command line according to the Docs page. The strange thing is that when I am using the terminal in arduino IDE, the received messages look identical.
Does anyone have any idea why it reacts to the command line but not Node red?

My bad. I had the wrong topic. I missed the set portion in node red.

1 Like

Nice, do you think you could share the configuration used ?

Of course I can share. I am using a PC817 optocoupler on w0 which is pin 23. I am going to change the resistor between pin 23 and the PC817 tomorrow from a 420 ohm to a 120 ohm. I am working on the lowest dimming. The lights looked like they were on the edge of shutting down at 8% with a 4 gamma, but the lights were brighter than I was getting by adjusting a 100k trimpot. The lighting was stable with the trim pot so I should be able to replicate the results with the ESP32. I am running Hitlites 2835 High Density 44w / strip - 2 strips so 88w.

https://www.amazon.com/gp/product/B01A79H03S/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1

The dimming is not linear either so my next step is to make my 1-100 Node red dimming slider work in increments of 5. I will then set each increment like a lookup table so that 1 is off (the mean well dims to off under 6%). I cannot see a difference in brightness for anything over 70%. I have the gamma up to 4. I need to confirm I am setting the gamma correctly. I may just decide to set gamma to 1. If I use a lookup table then gamma becomes irrelevant. It would be easier to just use gamma though and let the slider do its work.

I can post my final config with flow if people are interested. This is a great application for the OMG PWM. I was happy to see it was added.

Thanks OliWright!!

Still working thru it. Don’t have a final configuration, but it is working well now except a flicker in a small range of values near completely dimmed. The Mean Well PWM function is inverted. 100% duty cycle is lights off. This makes sense because if you don’t connect anything to the dimming wires, the lights run full power. This causes an interesting issue in that the gamma is .5-4. With the mean well being inverted the gamma needs to be less than 1 rather than the default 2.2. I did not test my theory, but I figure a gamma of 2 inverted is .5, so I cannot get more than a 2 gamma without rewriting the PWM code. My original solution was to put in an inversion so that the slider msg.payload = 1-msg.payload. Another factor is how the mean well is able to dim to off and bends the curve below 10%

Capture

Using node red, my solution now was to change the node red slider to 5% increments then use a switch node to put a different number in at each 5%. 0 is off, 5% is barely on, and manually increment 20 times. This seems to work good. I think the bend change causes a kind of flicker because there is a zone that flickers, but it does not flicker below or above the zone. I am avoiding the zone with my manual inputs.

Factors I have not tested to get rid of the flicker zone:
1 - Reduce the current limiting resistor between the ESP32 and the PC817 - I think it may make the PC817 saturate more quickly and switch more quickly. Not sure it that matters, but at the really low dimming, perhaps that is part of the problem with the flicker zone.

2 - Invert the electronics so the gamma can get cranked up to 4.

Note that the PWM is reducing current. My lights are almost too bright at 100% and I am at around 85 Watts and its a 120 Watt power supply. The bend in the curve is at 10% current. If the power supply was more right sized I would get better low end dimming because I would be using 10% of 90watts so 9 watts rather than 10% of 120 watts so 12 watts. I did not buy the 90 watt version because it is not class 2 rated and I wanted the safety. If I was to start over, I would have gotten a lower wattage strip and the PWM-60-12. I am doing cove lighting so I don’t know how I could have better predicted the amount of light I needed. I decided to go conservative and dim it. I wanted the dimming anyway.

I got it to work perfectly now.

I found that the high default frequency of the default ZactuatorPWM.h was preventing the 817 optocoupler from fully turning on. The frequency of the dimming input to the PWM120 does not match the frequency of the output. The duty cycle is matched. Not fully turning on was causing the duty cycle to be incorrect. The trace in my scope looked like this: ____/ ____/ I tested a frequency of 120 and the trace from the switched side of the 817 looked like the same as the trace coming from the ESP32. This made the duty cycle better match the data sheet if I used a 1 gamma. I still had flicker.I added a trimpot in parallel with the switched side of the 817. I increased the duty cycle until I had a flicker then reduced a bit to stay clear of the flicker. I then adjusted the trimpot until I could barely see the light. I checked and a 1 duty cycle was still past the threshold of turning the lights off completely. I set my levels in node red to what looked good to my eye so that 50% was a comfortable low light and 100% was very bright. The low levels were set to be barely on and giving no light to the floor at 5% and slowly increasing. I have no flicker at any level and have every level of brightness that I want.

1 Like