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

rjk_cmh

Member
Join Date
Jun 2019
Location
uʍop ǝpᴉsdn
Posts
30
There are plenty of examples on the internet of how to make an LED fade on and off in a sort of pulsating or breathing pattern, but these all use analog circuitry and 555 timers for the most part. I'd like to figure out how to implement something like this in a PLC's digital logic, using some high speed PWM magic.

My assumption is that I would need to first create some kind of S-curve ramp generator, and then use that to control the pulse width of a PWM output. However I don't really know how to do this at all. What would be the best way?

I would like to test this on some fairly cheap hardware, or perhaps in a free software simulator. I have some Velocio "PLC" hardware, and I like the look of the various inexpensive options from Automation Direct. How should I achieve this weird goal?
 
if I understand you correctly, digital I/o only.

so let's see what you want.
1. turn on and off an output to a light using an output.
2. you want to turn this output on / off using pulse width modulation.

so, in regards to #1, how would you turn the light on / off constantly if the plc logic on that rung is true all the time, lets say for 1 second intervals?

apply this to #2

james
 
Yes, digital I/O.
I don't want to switch the PWM output on and off like you seem to be suggesting, but I actually want to vary the pulse width on a pre-programmed ramp.
Here's a video of the outcome I want to achieve digitally:
https://www.youtube.com/watch?v=JRkum0bj2zA

My problem is that I have never used any high speed I/O logic before, and am a beginner at ladder logic in general.
 
Most digital IO will be way to slow to do that.

There are some PWM outputs but you need to research if your platform has it available.
 
Last edited:
Most digital IO will be way to slow to do that.

Surely something in the kilohertz range would be sufficient, and most HSIO points should be able to achieve that right? I've seen some systems that should be able to output in the megahertz range, which should be plenty for this sort of PWM I would think.
 
Correct you’ll need something high speed, which will limit your applications and usually come with a price tag.

I miss read your initial post and thought you were wanting to do this with regular discrete IO, not high speed.
 
I would think this would be pretty easy with any PLC that can do PWM. The Unitronics Samba line, and AB MicroLogix can do it, to think of a few cheap ones.
 
What are you trying to control?
It may not be possible depending on what you are trying to control.

The PLC will do normal PLC things, but I don't want to have separate electronics to run some fancy LEDs in a cool blinky pattern. It's a learning project, really. The PWM routine would just run LEDs.

I want to be able to tune the ramp up and ramp down S-curves independently, as well as the carrier frequency of the PWM and the dwell time at the top and bottom of the ramp. I started this project assuming that there might be some kind of pre-built function block available that I could plug the numbers into, but quickly found out that I would have to roll my own, and I have no idea where to start.
 
The PLCs I have used have simple registers that you can use for frequency and % ON, so that part is pretty much done for you. All you need to do is the math for whatever curve you're looking for to adjust the ramp.
 
The PLCs I have used have simple registers that you can use for frequency and % ON, so that part is pretty much done for you. All you need to do is the math for whatever curve you're looking for to adjust the ramp.

Well I came fairly close to flunking alegbra in school... Is that something I'm going to need? I hate math. :sick:
 
It may depend on how fancy of a curve you want, or what curve generating functions exist in whichever PLC you select. I'm with you on being super rusty at basic math, I would probably just google formulas for whichever curve I wanted and see about how to program it afterwards.
 
What about using a stepper motor control output? They are independant of the PLC scan times.



The SLC line has a stepper card, and I work on some small automation machines with IDEC PLC's that directly control 4 stepper motors.


With that you can control the output parameters. That might be able to control the LED's the way you want.
 
What about using a stepper motor control output? They are independant of the PLC scan times.



The SLC line has a stepper card, and I work on some small automation machines with IDEC PLC's that directly control 4 stepper motors.


With that you can control the output parameters. That might be able to control the LED's the way you want.
Another good idea. I think most of the PLC hardware ought to be able to do it, especially if I keep the carrier frequency low, say about 1-2 khz. I think the main sticking point is figuring out how to program in this sort of sequence though. I have done some in depth Google searching, and I can't seem to find any similar projects being done digitally - most of them use analog stuff with resistors and capacitors and 555 timers.
 
I just checked the IDEC program for how it controls a stepper motor.


In the attached screenshot the rate of the output is controlled by the DWord in the S1 register. Writing a different number to that DWord while the PWM command is active would change the output frequency.


You can use a pulse to ADD and SUB from the DWord to set limits, or every 1/2 second write a new value to it. With one input on you could ADD & SUB a value of 1, another input for faster response could ADD & SUB 10 or 15 each pulse.


Using timers and counters to control the register you could make it pulse and grow and fade.

Capture.JPG
 

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,674
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,119
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,542
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,657
I have a project to control the speed of motor DC using PWM Output on PLC and when im on working i have a several trouble and of of them is the...
Replies
6
Views
168
Back
Top Bottom