How to make a pulsing/breathing pwm output on a PLC?

Here is an example of a PWM type simulator in free software. CoDeSys.

The PWM in this example is 10hz and is outputting the PWM equivalent of a Sine wave with a 5 second period.

I used a function generator to create a sine wave with the period I would want the lights to pulse at and scale that sine wave to 0 to 1.0.

Then I run a timer that resets itself every cycle (10Hz -> 100ms timer). I then create a number from 0 to 1.0 by dividing the elapsed time of the timer by the total time of the timer. So this number represents a fraction of the elapsed time. i.e., when the number is 0.3, 30% of the period has passed. When the number is 0.75, 75% of the period has passed etc.

Lastly, compare the current percentage of the PWM period to the sine wave percentage. If the PWM period percentage is <= the Sine wave percentage then turn the output on, otherwise, turn it off.

Here's a little video...

https://youtu.be/rDETvu1tuDE
 
Here is an example of a PWM type simulator in free software. CoDeSys.

The PWM in this example is 10hz and is outputting the PWM equivalent of a Sine wave with a 5 second period.

I used a function generator to create a sine wave with the period I would want the lights to pulse at and scale that sine wave to 0 to 1.0.

Then I run a timer that resets itself every cycle (10Hz -> 100ms timer). I then create a number from 0 to 1.0 by dividing the elapsed time of the timer by the total time of the timer. So this number represents a fraction of the elapsed time. i.e., when the number is 0.3, 30% of the period has passed. When the number is 0.75, 75% of the period has passed etc.

Lastly, compare the current percentage of the PWM period to the sine wave percentage. If the PWM period percentage is <= the Sine wave percentage then turn the output on, otherwise, turn it off.

Here's a little video...

https://youtu.be/rDETvu1tuDE

Wow, you're awesome. Thanks for providing me with a starting point. I will have to copy it and tinker with the variables before I will have any idea of how the heck it works, but I think the video will be a lot of help.

I'm guessing that the next thing I will need to discover is how to linearize it properly for an LED. My understanding is that human eyesight resolves light in a nonlinear fashion, so I will have to adjust the ramping to accommodate that.

Thanks again.
 
Wow, you're awesome. Thanks for providing me with a starting point. I will have to copy it and tinker with the variables before I will have any idea of how the heck it works, but I think the video will be a lot of help.

I'm guessing that the next thing I will need to discover is how to linearize it properly for an LED. My understanding is that human eyesight resolves light in a nonlinear fashion, so I will have to adjust the ramping to accommodate that.

Thanks again.

Well it was extremely frustrating, but I got a copy of the program built and running. I've never used function block programming or Codesys in my life, but at least I got this far.
 

Similar Topics

Hi all, I am wanting to pulse an inverter to drive 2 seconds on and 2 seconds off 20 times after my machine crashes and builds back a slug of...
Replies
5
Views
2,684
I would like to energize an output for say 3 seconds, and then de-energize for 3 seconds, and then re-energize for 3 seconds, and off again for 3...
Replies
7
Views
2,132
I have device which pulses a NO contact when it is in alarm (roughly 2 second pulse every 15 seconds). I need to move a 3-way valve when when my...
Replies
2
Views
2,546
Im running a few simple ladder programs in Simatic Step7. How do I pulse an input on and off so i can see its effect on the output. And also how...
Replies
3
Views
1,664
Good morning! I'm trying to find a DIN rail-mountable 4-0channel PWM amplifier that is capable of accepting a 5VDC PWM with a maximum frequency...
Replies
2
Views
103
Back
Top Bottom