generate the PWM signal with variable duty cycle according to PID output.

batindeko

Member
Join Date
Nov 2017
Location
stutensee
Posts
16
Hello Friends,

I am looking for a way to take my PID Output( it is the result of my PI Algorithm in Real format) and generate a PWM Signal in Bool. I don't know how to do that.
I use a siemens PLC 1516-3 where I've already implemented a PI Algorithm. The outcome of my PI Algorithm is a duty cycle. I also use a SSR Relay to control the temperature. my issue is how can I convert the duty cycle to pulse width.
 
First, select an appropriate period for your pulse, perhaps one second. Then, scale your PID function's CV to a range of zero to 1000. Set up a timer with a preset of 1000 milliseconds that resets itself and restarts when it reaches its preset. Then set up a comparison function so that the SSR on on when the timer's accumulated count is less than the PID's scaled CV. The larger the CV, the longer percentage of the one second period the SSR will be on. Best practice is to use a transistor output to drive the SSR and not a relay contact output.
 
First, select an appropriate period for your pulse, perhaps one second. Then, scale your PID function's CV to a range of zero to 1000. Set up a timer with a preset of 1000 milliseconds that resets itself and restarts when it reaches its preset. Then set up a comparison function so that the SSR on on when the timer's accumulated count is less than the PID's scaled CV. The larger the CV, the longer percentage of the one second period the SSR will be on. Best practice is to use a transistor output to drive the SSR and not a relay contact output.
thank for your reply. please tell me what does PID function's CV mean?
 
I'm not fluent with Siemens, but attached is an example taken from RSLogix500 Instruction documentation. Perhaps you can follow that and port it to Siemens environment?

Also, for what its worth, I've also attached an example of it in TwinCAT that we use for PWM'ing heater element from PID instruction.

PWM_RSLogix500.jpg PWM_TwinCAT.png
 
thank for your reply. please tell me what does PID function's CV mean?

SP = Setpoint
PV = Process variable.
CV = Control variable.

I'm not sure if these are common terms used in industry, or if they were originated and mainly used in Rockwell Automation world.
 
Last edited:
thank for your reply. please tell me what does PID function's CV mean?


PID Output

As Steve Bailey wrote, select the PWM generation period (pulse duration on + pulse duration off).
For example, the PWM generation period = 100 s, then if PID Output = 10%, then the pulse duration is on = 10 s, the pulse duration is off = 90 s; then if PID Output = 20%, then pulse duration is on = 20 s, pulse duration is disabled = 80 s, etc.

How to accumulate pulse duration: you can, as Steve Bailey wrote, you can accumulate scan durations, you can (if high accuracy is not required and/or the pulses are quite long) simply count scans (knowing the average scan duration)

But the selection of the PWM generation period should fit into a Procrustean bed of sufficient control accuracy (during the on/off pulse time, the controlled value should not deviate more than the specified value); on the other hand, it is desirable to reduce the number of on/offs, i.e. do not make impulses unreasonably short.

If possible, could you show the process curve?
 
Hello Friends,

I am looking for a way to take my PID Output( it is the result of my PI Algorithm in Real format) and generate a PWM Signal in Bool. I don't know how to do that.
I use a siemens PLC 1516-3 where I've already implemented a PI Algorithm. The outcome of my PI Algorithm is a duty cycle. I also use a SSR Relay to control the temperature. my issue is how can I convert the duty cycle to pulse width.


If you're using the built in PID_Compact, it has a PWM output available. If you've rolled your own algo, then do what everybody else said.
 
If you're using the built in PID_Compact, it has a PWM output available. If you've rolled your own algo, then do what everybody else said.
I wrote my own algorithm. The problem with the built in PID_Compact is the number of heater component (400).
 
Is there 400 PID loops or 1 PID loop with 400 heaters?


The pulsegen instruction can be used to generate the PWM

pgen.jpg
 
Is there 400 PID loops or 1 PID loop with 400 heaters?


The pulsegen instruction can be used to generate the PWM

there is 400 PID loops.

tell me please where do i find that instruction. what should i pay attention by using it

i want to automate my code because to enter 400 PID or PULSEGEN Instruction is too much
 
Last edited:
there is 400 PID loops.

tell me please where do i find that instruction. what should i pay attention by using it

i want to automate my code because to enter 400 PID or PULSEGEN Instruction is too much


I would assume you include the pulsegen instruction inside your PID algorithm FB, and that means you don't have to deal with all the repetitive data entry.
 
Use an array of function blocks that you can call by index. How you layout the addresses for your I/O could help you minimise the amount of input. For example if the temperature measurement inputs started at IW512 and were sequential you could use indirect addressing and not need to refer to every analogue input by symbol name, same for the the digital I/O.
 
Use an array of function blocks that you can call by index. How you layout the addresses for your I/O could help you minimise the amount of input. For example if the temperature measurement inputs started at IW512 and were sequential you could use indirect addressing and not need to refer to every analogue input by symbol name, same for the the digital I/O.
can you show me how to declare an array of FB in TIA portal. I tried but i failed
 
Create a supervisory FB to call your PID FB. Declare the array of PID function blocks in the STAT interface of the supervisory FB.

myPID.jpg
 

Similar Topics

Does anyone know a way to dynamically generate a 2D barcode on a PanelView screen? An Activex Control maybe? If such a method is out there, it...
Replies
14
Views
2,990
Hi, I am trying to generate source file of OB1 including all dependent blocks. But i am getting a message which says-->>one or more blocks...
Replies
3
Views
1,256
Hello Everyone, I would like to know where to start when designing a HMI+PLC Allen Bradley based, that complies with CFR 21 PART 11, ALCOA...
Replies
4
Views
2,912
Hello, in iFix I want to do a boolean calculation with two values, and generate an alarm if the result is true. The calculation in my BL block...
Replies
3
Views
2,181
Hello, So in RSLogix 5K I would be used to doing the following: 1. Double click the left of the rung, to bring the rung text editor, will be...
Replies
4
Views
2,103
Back
Top Bottom