Pulse Width Modulation for CL2 dosing; nearly figured out, just need a little help

defcon.klaxon

Lifetime Supporting Member
Join Date
Feb 2015
Location
Far NorCal
Posts
616
Hey guys, I have a client that has a v-notch chlorinator that doesn't run off a 4-20mA loop, it instead has two discrete inputs that drive the actuator up (closing the v-notch) or down (opening the v-notch). The PLC is a SLC 5/05.

The programmer used a pretty clever pulse width modulating technique to drive the discrete outputs. Every ten seconds, the program looks at current flowrate (in lb/day), subtracts it from the setpoint, and determines if the error is positive or negative. If positive, then it's dosing too much and sends a pulse to close the valve. If negative, then it's not dosing enough and sends a pulse to open. The duration of the pulse is determined by the magnitude of the error.

I've got this all sorted, minus the equation that determines the error. The equation expression is:

Code:
( N25:15 * ( ABS F8:8 ) ) | N25:14
and the comment for this equation is:

RAW PULSE DURATION = MODULATOR_Period * ( ABSOLUTE VALUE OF GAS FLOW ERROR)/MODULATOR MAX).

The MODULATOR_Period is set to 10, and this makes sense because the outputs are energized for the pulse duration every 10 seconds. The GAS FLOW ERROR is simply the PV-SP, so that makes sense. The one thing that doesn't make sense is the MODULATOR MAX. It's set to 30, but I can't wrap my head around where this number comes from. How can the MODULATOR_Period be 10 seconds, but the MODULATOR MAX be three times that?

I have no idea where this equation came from, so I don't know how the MODULATOR MAX is determined. Was wondering if anyone here might know more about this method and could take a stab at what MODULATOR MAX is. Thanks for any help!
 
Howzit, man? I wrote a program for some Air Handlers that used a lot of min/max values. I think if your chlorinator uses an HMI or keypad to input values to say modulator_period, the modulator max could be the max value you can enter. It's either set in the keypad, and will either show an error in range of values, or it will just write 30 in the chlorinator if you key in say 40. That's what my HMI did on the Air Handlers, just entered a max value no matter what you entered over that. Just a guess, good luck.
 
Howzit, man? I wrote a program for some Air Handlers that used a lot of min/max values. I think if your chlorinator uses an HMI or keypad to input values to say modulator_period, the modulator max could be the max value you can enter. It's either set in the keypad, and will either show an error in range of values, or it will just write 30 in the chlorinator if you key in say 40. That's what my HMI did on the Air Handlers, just entered a max value no matter what you entered over that. Just a guess, good luck.

Thanks for the response. The values for min, max and period are hard coded in the PLC, they're not operator adjustable. I've been thinking about it for awhile and I'm thinking that the MODULATOR MAX value may just be a value that is used to limit the output of the expression to a maximum value, and there's no hard and fast equation to determine what it should be set to be. For example, if I wanted the maximum pulse length to be five seconds instead of ten, I'd increase the MODULATOR MAX value to 60 instead of 30.

It would also follow that if I was using this same method to adjust flow in GPM, the error equation could result in a number in the hundreds of GPM. Thus, I'd use a MODULATOR MAX value much larger, based on what I'd want the max duty cycle to be.
 
I think a clue would be to trace where the RAW PULSE DURATION ends up. Eventual it should hit some timer and that will be in some units of msec or sec or something else.

Most likely, whoever wrote the program watched the process and picked the 30 from observation. it's basically limiting the on time of the pulse.

What is the range of the error you are seeing?
 
I think a clue would be to trace where the RAW PULSE DURATION ends up. Eventual it should hit some timer and that will be in some units of msec or sec or something else.

Most likely, whoever wrote the program watched the process and picked the 30 from observation. it's basically limiting the on time of the pulse.

What is the range of the error you are seeing?

I think you're spot on in your assessment. The RPD ends up feeding into the Timer that determines how long the pulses are allowed to energize. The code has three value checks; if the RPD is less than 0.5, then the Time is given a .PRE of 0, so it's bypassed. If the RPD is greater than 10, which is the entire PWM period, then the Timer is given a .PRE of 10000, which of course is for milliseconds so 10 seconds. If the RPD is greater than 0.5 but less than 10, then RPD is multiplied by 1000 and fed into .PRE of the Timer.

Thus, I think it's fair to say that this MAX value is simply a value that limits how big the RPD can get.

Thanks for taking a look at this; confirming what I was starting to realize definitely helps the confidence level.
 
Not sure I'm seeing the whole pictute, but isn't the modulator max setting the "gain" of this function? Since the higher the number, the lower the pulse duration?
 
Not sure I'm seeing the whole pictute, but isn't the modulator max setting the "gain" of this function? Since the higher the number, the lower the pulse duration?

I think you, ndzied1, and I are in agreement that the tag in question is simply a variable used to "tune" the amount of correction that can be applied.

Whether that value can be adjusted outside of the programming environment is another matter.
 

Similar Topics

Help me. I want to create a PLC program Pulse width modulation (PWM) with Simatic PLC s7300. using SFB49. but I have never made it. is there who...
Replies
0
Views
2,560
Hi, I am trying to write a ladder logic using PWM and INI instructions to actuate a fast switching solenoid valve at a range of frequencies. I...
Replies
9
Views
11,196
how can I change an analog output just with the program not using a digital input? also I need to ramp up and ramp down the analog output please...
Replies
5
Views
4,168
Hi, is anyone familiar with the pulse width modulation output on the SIMATIC s7-300 series? I've set up the count module in HW Config, and want to...
Replies
3
Views
5,694
Hi, I have Siemens PlC and I am trying to write program in SCL or other language. This program shut regulate temperature using pulse width...
Replies
4
Views
10,270
Back
Top Bottom