PWM Signal is being turned off a few seconds after last duty cycle is set

I would like to use mycodo on a raspberry 4 to dim an LED with a meanwell driver with software PWM.
I would like to simulate daily light cycle like 12hrs on, 12hrs off.
It should ramp up to 100% in 15 minutes
stay a 100% 11.5 hours
ramp down to 0% in 15 minutes
stay 0% off for 12 hours.
The driver needs an inverted PWM signal.

So far ramping up and down works fine.
But after ramping down to 0% after a few seconds the PWM signal is turned off and the driver gets no signal an turns on LED to 100%.

I notice the same behaviour, when i set a duty cycle directly in the PWM output.

What is causing the PWM signal to stop?
How can i achieve a once set PWM signal to stay on until it is actively changed again?

1 Like

What does this mean? PWM signals can’t “turn off”. Do you mean the duty cycle is 0 %? Provide as much information as you can so I can understand if there’s an issue or just a misconfiguration.

1 Like

Don’t bother trying to mimic natural sunrises and sunsets by dimming your lights. There is no real benefit to it. Plants will either photosynthesize or they won’t depending on how much light they get. Just turn your lights on or off… there is really no need to ramp your lights up and down. I have yet to see any real scientific evidence that ramping your lights has any benefit at all. If you can post any white-papers or other peer-reviewed scientific studies that says otherwise, I’d be interested in reading those studies. But until that data is quantified in an actual scientific study, I just turn my lights on and off, no ramping needed. I have seen some “articles” claiming that ramp up and ramp down “makes plants grow bigger” but these articles are not scientific studies, they are anecdotal observations at best, and should not be taken as scientific evidence… just like most of the non-science-based garbage that you will read on grower’s blogs. Usually these “articles” are trying to make some kind of pseudo-scientific claim in order to sell you some expensive product that you really don’t need… like over-priced dimable grow lights.

2 Likes

This is the configuration of the output

The daily Trigger to ramp up the output

The daily Trigger to ramp down the output

When i “execute all actions” from the “Chroma Dim AUS (18/6)” the light goes on dims down to about 17%. It stays there about 30 seconds, then it goes off for another 30 seconds, then goes on again at 16%. And so on until it reaches 8%. After another 30 seconds the lamp goes on again and stays on.

The log file filtered for the guid of the output

2023-10-21 18:24:30,531 - DEBUG - mycodo.controllers.controller_output - output_on_off(a23dc437-a3e9-4a28-b54b-e17adad8e0b7, on, 0, pwm, 20.0, 0.0, True)
2023-10-21 18:24:30,866 - DEBUG - mycodo.influx - Write point success: b'percent,channel=0,device_id=a23dc437-a3e9-4a28-b54b-e17adad8e0b7,measure=duty_cycle value=20'
2023-10-21 18:25:20,496 - DEBUG - mycodo.controllers.controller_output - output_on_off(a23dc437-a3e9-4a28-b54b-e17adad8e0b7, on, 0, pwm, 19.0, 0.0, True)
2023-10-21 18:25:21,177 - DEBUG - mycodo.influx - Write point success: b'percent,channel=0,device_id=a23dc437-a3e9-4a28-b54b-e17adad8e0b7,measure=duty_cycle value=19'
2023-10-21 18:26:10,508 - DEBUG - mycodo.controllers.controller_output - output_on_off(a23dc437-a3e9-4a28-b54b-e17adad8e0b7, on, 0, pwm, 18.0, 0.0, True)
2023-10-21 18:26:10,939 - DEBUG - mycodo.influx - Write point success: b'percent,channel=0,device_id=a23dc437-a3e9-4a28-b54b-e17adad8e0b7,measure=duty_cycle value=18'
2023-10-21 18:27:00,495 - DEBUG - mycodo.controllers.controller_output - output_on_off(a23dc437-a3e9-4a28-b54b-e17adad8e0b7, on, 0, pwm, 17.0, 0.0, True)
2023-10-21 18:27:00,920 - DEBUG - mycodo.influx - Write point success: b'percent,channel=0,device_id=a23dc437-a3e9-4a28-b54b-e17adad8e0b7,measure=duty_cycle value=17'
2023-10-21 18:27:50,514 - DEBUG - mycodo.controllers.controller_output - output_on_off(a23dc437-a3e9-4a28-b54b-e17adad8e0b7, on, 0, pwm, 16.0, 0.0, True)
2023-10-21 18:27:50,948 - DEBUG - mycodo.influx - Write point success: b'percent,channel=0,device_id=a23dc437-a3e9-4a28-b54b-e17adad8e0b7,measure=duty_cycle value=16'
2023-10-21 18:28:40,495 - DEBUG - mycodo.controllers.controller_output - output_on_off(a23dc437-a3e9-4a28-b54b-e17adad8e0b7, on, 0, pwm, 15.0, 0.0, True)
2023-10-21 18:28:40,891 - DEBUG - mycodo.influx - Write point success: b'percent,channel=0,device_id=a23dc437-a3e9-4a28-b54b-e17adad8e0b7,measure=duty_cycle value=15'
2023-10-21 18:29:30,547 - DEBUG - mycodo.controllers.controller_output - output_on_off(a23dc437-a3e9-4a28-b54b-e17adad8e0b7, on, 0, pwm, 14.0, 0.0, True)
2023-10-21 18:29:31,006 - DEBUG - mycodo.influx - Write point success: b'percent,channel=0,device_id=a23dc437-a3e9-4a28-b54b-e17adad8e0b7,measure=duty_cycle value=14'
2023-10-21 18:30:20,498 - DEBUG - mycodo.controllers.controller_output - output_on_off(a23dc437-a3e9-4a28-b54b-e17adad8e0b7, on, 0, pwm, 13.0, 0.0, True)
2023-10-21 18:30:20,865 - DEBUG - mycodo.influx - Write point success: b'percent,channel=0,device_id=a23dc437-a3e9-4a28-b54b-e17adad8e0b7,measure=duty_cycle value=13'
2023-10-21 18:31:10,497 - DEBUG - mycodo.controllers.controller_output - output_on_off(a23dc437-a3e9-4a28-b54b-e17adad8e0b7, on, 0, pwm, 12.0, 0.0, True)
2023-10-21 18:31:10,970 - DEBUG - mycodo.influx - Write point success: b'percent,channel=0,device_id=a23dc437-a3e9-4a28-b54b-e17adad8e0b7,measure=duty_cycle value=12'
2023-10-21 18:32:00,529 - DEBUG - mycodo.controllers.controller_output - output_on_off(a23dc437-a3e9-4a28-b54b-e17adad8e0b7, on, 0, pwm, 11.0, 0.0, True)
2023-10-21 18:32:01,033 - DEBUG - mycodo.influx - Write point success: b'percent,channel=0,device_id=a23dc437-a3e9-4a28-b54b-e17adad8e0b7,measure=duty_cycle value=11'
2023-10-21 18:32:50,504 - DEBUG - mycodo.controllers.controller_output - output_on_off(a23dc437-a3e9-4a28-b54b-e17adad8e0b7, on, 0, pwm, 10.0, 0.0, True)
2023-10-21 18:32:50,952 - DEBUG - mycodo.influx - Write point success: b'percent,channel=0,device_id=a23dc437-a3e9-4a28-b54b-e17adad8e0b7,measure=duty_cycle value=10'
2023-10-21 18:33:40,478 - DEBUG - mycodo.controllers.controller_output - output_on_off(a23dc437-a3e9-4a28-b54b-e17adad8e0b7, on, 0, pwm, 9.0, 0.0, True)
2023-10-21 18:33:40,884 - DEBUG - mycodo.influx - Write point success: b'percent,channel=0,device_id=a23dc437-a3e9-4a28-b54b-e17adad8e0b7,measure=duty_cycle value=9'
2023-10-21 18:34:30,515 - DEBUG - mycodo.controllers.controller_output - output_on_off(a23dc437-a3e9-4a28-b54b-e17adad8e0b7, on, 0, pwm, 8.0, 0.0, True)
2023-10-21 18:34:31,367 - DEBUG - mycodo.influx - Write point success: b'percent,channel=0,device_id=a23dc437-a3e9-4a28-b54b-e17adad8e0b7,measure=duty_cycle value=8'
2023-10-21 18:35:20,450 - DEBUG - mycodo.controllers.controller_output - output_on_off(a23dc437-a3e9-4a28-b54b-e17adad8e0b7, on, 0, pwm, 8.0, 0.0, True)
2023-10-21 18:35:20,675 - DEBUG - mycodo.influx - Write point success: b'percent,channel=0,device_id=a23dc437-a3e9-4a28-b54b-e17adad8e0b7,measure=duty_cycle value=8'


This is a synchronous graph of the output

I have absolutly no clue what is causing the on/off behaviour starting at 17%
and no clue what is causing the PWM to turn off.
On the mosfet board there is a LED showing if the signal has PWM.
Hence i think some other task (builtin timer) is turning of the PWM signal on the GPIO pin.

But it could be very well a configuration error.

Thanks, and I get it. However since i now have the possibility to do so. I’d like to try it as a proof of concept.
I would be totally fine, if this it not possible at all, to just turn it on and off.
However this is not possible, as even the simple function to turn off:


does only work for about 30 seconds…

ps all the times, durations and percentages are just for testing the scenario.

The first glaring problem I see is that you have the same name setup in both of your Trigger Daily Time Point functions…
[Chroma Dim AUS (18/6)].
This name should be unique for each Function. Maybe label one “ramp-up” and one “ramp-down” or one as “lights-on” and one as “lights-off”.

Also, I would recommend not using the Daily Time Point and instead using the Daily Span function for you lights, this way even if the power goes off, when the system comes back up again your lights will turn on… if you are just using a Daily Time Point, and the power goes out, your lights will not turn back on when the power comes back until the next power-on time (the next day).

Here is what the Daily Span for an 18/6 lighting program would look like…


So what is happening here is that this function turns on your lights at 5am (Start Time).
Then it creates a bunch of smaller time “loops” within the time span that it is set to be on, in this case 300 seconds or 5 minutes, this is the Period time.
This way your lights keep getting turned on in 5 minute loops (300 seconds) and essentially this allows the function to keep making sure the lights are turned on.
Even if the power goes out and comes back up later, this function will keep making sure the lights are turned on every 5 minutes in between the times of 05:00 and 23:00.
Once the span reaches the End Time (23:00 hours 11pm), it will run it’s last 5 minute loop (Period time) and then the output will shut off (lights off). It is VERY IMPORTANT to set the Duration time on the Action Output to the same time as the Period time during the Span. I usually set the Duration time to a few seconds longer than the Period time to make sure the lights don’t flicker off then back on again at the end of each Period loop.

I also use just one Daily Span Function for all of my watering…


In this function I am telling it to only water between the hours of 5:00am and 11:00pm, and only once every 7200 seconds (2 hours). And I have my watering pump set as the Action Output. And the duration for the water pump to be on for each watering cycle is 120 seconds (2 minutes).
So my plants automatically get watered every 2 hours for 2 minutes and only between the hours of 5am and 11:pm (which is when the lights are on). And if the power goes out and comes back up (like during a lightning storm), this function will just pick up where it left off and I know the plants will still get watered on schedule. This way I don’t need to keep the Pi on a UPS if I don’t want to.
All of this reliability with only one Function to setup.

The other big problem is that you are trying to use the PWM as your On/Off switch. You should be using a relay as your on/off switch to completely kill the power to the drivers when you want your lights off. If you really feel the need to ramp your lights, you should use separate PWM Functions to do that… one at either end of the Daily Span function.

Are these the only output/functions you have existing in Mycodo, to remove any other potential conflicts?

@KyleGabriel This is the same problem I reported here months ago…

Yes, there are 3 more GPIO Outputs for different Pins. They were all deactivated, when the issue happened.
For these outputs there are alike functions. Also deactivated.
Then there are 2 more MQTT Outputs. for these i have active Bang-Bang Hysteric functions.

It sounds a lot like this issue, yes.

Interesting observation: Since my post with the screenshots i left everything turned on. And now the LED stays at 8% (and PWM LED is constantly on).

I changed only two configs since last posts, no reboot was performed:

Duration of ramp down from 600.0 to 30.0 seconds

Startup Value and Shutdown Value both from 0.0 to 100.0

As it then worked as it should do. I left it on over night and in the morning the correct PWM value was still set.

–
I did a few more tests today. And cannot reproduce the issue anymore. Even if i change back to the original timings and Startup/Shutdown State values.
All still working fine.

Which leaves me clueless, what led to the original issue.
Wild guesses:

  • Could be faulty hardware (PWM module). Unlikely because it showed a different value, than configured in the UI.
  • Maybe, some old scheduled actions from a previous day, that fit in the Daily time Point trigger condition a day later.
  • Maybe a kind of overload on the rpi let to a delayed execution

I will test it again with scheduled times and then more PWM modules and report back.