Sitrain s7-1200 Pwm_pid

Embed Size (px)

Citation preview

  • SIEMENS

    ContentPulse Width Modulation (PMW)PID ControflerCtosed Loop Controlled SystemController BufidAdd Cyclic Interrupt OBAdd PID ControllerCompact and Expanded ViewFormal Parameter - InputFormal parameter- OutputFormal Parameter - SlateDefine VariableConfigurationInput ScalingInput MonitoringSet PWM HysteresisOutput LimitsManual PID parameterVariable for Warning LimitsCommissioning - WorkflowCommissioningCommissioning - Kind of CommissioningCommissioning - OnlinePID Exercise ....................................................................................................................................Exercise - PID ControllerExercise 8-1: Add Ne~v Project with HardwareExercise 8-1: Setup PLC tagsExercise 8-1: Add program and OBExercise 8-1: Add P]D ControllerExercise 8-1: Parametefize PID ControllerExercise 8-1: Scale the InputsExercise 8-1: Download whole projectExercise 8-1: Commissioning PID Controfler

    Page3679

    1213141516

    18

    21222324252627343538394O

    424344454647

    SITRAIN Training for $7-1200 TIA SystemAutomation and Industrial Solutions Page 1 Pulse Width Modulation & PID Controller

  • PID ControllerExercise PID

    SITRAIN Training for $7-1200 TIA SystemAutomation and Industrial Solutions Page 2 Pulse Width Modulation & PID Controller

  • Pulse Width Modulation (PWM)SIEMENS

    CTRL_PWM InstructionThe CTRL_PWM Pulse Width Modulation (PWM) instruction provides a fixed cycle time output with avariable duty cycle. The PWM output runs continuously after being started at the specified frequency(cycle time). The pulse width is varied as required to effect the desired control. Duty cycle can beexpressed as a percentage of the cycle time (0 - 100%), as thousandths (0 - 1000), as ten thousandths(0 - 10000), or as $7 analog format. The pulse width can vary from 0 (no pulse, always off) to full scale(no pulse, always on).Since the PWM output can be varied from 0 to full scale, it provides a digital output that in many ways isthe same as an analog output. For example, the PWM output can be used to control the speed of a motorfrom stop to full speed, or it can be used to control position of a valve from closed to fully opened.

    $7-1200 TIA SystemSITRAIN Training for Page 3 Pulse Width Modulation & PID ControllerAutomation and industrial Solutions

  • Pulse Width Modulation (PWM)SIEMENS

    Two pulse generators are available for controlling high-speed pulse output functions: PWM and Pulsetrain output (PTO). PTO is used by the motion contro~ instructions. You can assign each pulse generatorto either PWM or PTO, but not both at the same time.The two pulse generators are mapped to specific digital outputs as shown in the above table. You canuse onboard CPU outputs, oryou can use the optional signal board outputs. The output point numbersare shown in the above table (assuming the default output configuration). If you have changed the outputpoint numbering, then the output point numbers will be those you assigned. Regardless, PTOI/PWM1uses the first two digital outputs, and PTO2/PWM2 uses the next two digital outputs, either on the CPU oron the attached signal board. Note that PWM requires only one output, while PTO can optionally use twooutputs per channel. If an output is not required for a pulse function, it is available for other uses.

    $7-1200 TIA Syste[nSITRAIN Training forAutomation and Indus~al Solutions Page 4 Pulse W~dth Modulation & PID Controller

  • PID Controller

    SIEMENS

    , Pulse Width Modulation (PWM) PID Controller, Exercise PID

    $7-1200 TIA SystemSlTRAIN Training for Page 5 Pulse Width Modulation & PID ControllerAutomation and Industrial Solutions

  • Closed Loop Controlled System

    Controller

    w e

    actuator

    Controller PWM

    SIEMENS

    Controlled(disturbanCe)z

    Fan

    High Speed Counter

    A block diagram showing a PID closed loop control implementation where the measured feedback iscompared with the setpoint to determine the error. The error is then used by the PID loop algorithm toadjust the PID output to eliminate the error.

    $7-1200 TIA SystemSITRAIN Training for Page 6 Pulse W~dth Modulation & PID ControllerAutomation and Industrial Solutions

  • Closed Loop Controlled System

    SIEMENS

    actuator(disturbance)

    Z

    Controlled

    Controller PWM Fan

    High Speed Counter

    The PID controller is implemented in the 1200 CPU by the PID Compact instruction box located in theExtended Instruction Task Card. This PID control loop will use-a PWM instruction and a High SpeedCounter instruction to control the speed of the fan motor on the training simulator.

    $7-1200 TIA SystemS TRAIN Tra n ng for Page 7 Pulse Width Modulation & PID ControllerAutomation and ndustda~ Solutons

  • SIEMENS

    Controller Build

    PID Loop ControllerThe PID Compact instruction provides the CPU 1200 user with a PID loop control algorithm that hasautomati~ and manual mode available along with self tuning optimization The pID_Compact instructionbox has inputs where the setpoint and process variable (actual value) are connected. The inputconnections provide process data for the PID algorithm which then drives the output to the final element.

    $7-1200 TIA SystemPulse Width Modulation & PID ControllerSITRAIN Train ng for Page 8

    Automation and Industrial So utions

  • Controller Build

    SIEMENS

    The PiD Compact instruction is programmed in a Cyclic Interrupt OB for execution which executes at aspecifie~-cycle time. The cycle time can be viewed or changed in the prope[ties of the Cyclic InterruptOB. During the programming of the PID_Compact instruction a data block is created and automaticallyplaced in the Technological Object folder.

    $7-1200 TIA SystemSITRAIN Training for Page 9 Pulse Width Modulation & PID ControllerAutomation and Industrial Solutions

  • Add Cyclic Interrupt OB

    SIEMENS

    Adding and configuring the Cyclic Interrupt OB through the Add new block prompt in the Program blocksfolder. When the Add new block dialog box opens, the OB button is selected followed by selecting theCyclic interrupt, the program language, the OB number, and cyclic execution time; click OK to completethe configuration.

    S7-1200 TIA SystemS TRAIN Tra n ng for Page 10 Pulse W]dth Modulation & PID ControllerAutomation and ndustdal So utons

  • Add PID Controller

    SIEMENS

    Open the Cyclic Interrupt OB to view the LAD networks, then open the Extended Instructions and dragand drop the PID Compact instruction on to the open LAD network. A dialog box will open where aninstance data bloc-k will be configured and be attached to the pID_Compact instruction box.

    $7-1200 TIA SystemSlTRAIN Training for Page t 1 Pulse Width Modulation & PID ControllerAutomat[on and Industrial Sotutlons

  • Compact and Expanded View

    SIEMENS

    PID Compact instruction box can be expanded or collapsed by clicking on the little arrow head at thebottom of the PID_Compact instruction box. tn the expanded state, additional inputs/outputs are exposedand connections can be made then the instruction box can be collapsed to conserve space.

    $7-1200 TIA SystemSlTRA~N Training for page 12 Pulse W~dth Modulation & PID ControllerAutomation and Industrial Solutions

  • SIEMENS

    input:"Automatic Mode"

    .= from the user programAnalog Input

    := "Manual mode"

    ~dable for Manuat Mode"restart counter

    := "inactive Mode"

    The PID Compact instruction inputs not only provide connection points for the controlled processsetpoint-~nd measured feedback, it also provides an input connection to change the state of thecontroller mode. 1he PID controller can be in manual mode, which is the default mode, or auto mode.When the PID controller is in auto mode, the P[D controller automatically adjusts the loop output tomaintains the loops setpoint value, such as a desired temperature.

    $7-1200 TIA SystemSlTRAIN Training for Page 13 Pulse Width Modulation & PID ControllerAutomation and Industrial So~utlons

  • The PID Compact instruction outputs not only provides a connection point for the controlled process finalelement-~ut it also provides different types of output connections to match what it is driving, such as anoutput for pWM or an output as a Real number data type. Limit and warning alarm bits can beconfigured along with locations that record the mode of the controller and displays error codes in theevent of an error condition which makes troubleshooting easier.

    $7-1200 TIA SystemSITRAIN Training for Page 14 Pulse ~Mdth Modulation & PID ControllerAutomation and Industrial Solutions

  • Formal Parameter - StateSIEMENS

    The chart above shows the numerical codes that are displayed in the State output which describes theStatus of the PID controller. A memory location must be configured to State output in order for thenumerical codes to be displayed.

    $7-1200 TIA SystemSITRAIN Training for Page 15 Pulse W~dth Modulation & PID ControllerAutomation and Industrial Solutions

  • SIEMENSDefine Variable

    Symbolic programming provides an advantage, you will find the program much clearer and easier to readif you use symbols (for example fan) instead of the absolute addresses. To allow the use of symbols, youcan enter a name, the absolute address, the data type and a comment for every address used. Onceyou have defined a symbol, it can be used throughout the entire user program of a programmablemodule; symbolic names are entered in the PLC tags folder.

    $7-1200 TIA SystemSlTRAIN Tra n ng for Page 16 Pulse Width Modulation & PID ControllerAutomation and Industrial So u ons

  • Clicking on the Configuration button in the upper right hand corner of the pID_Compact instruction boxopens to the configuration topics such as Basic parameters, Input scaling, and Advanced settings whichstores the loop tuning parameters for the pID_Compact box instruction.

    $7-1200 TIA SystemSITRAIN Training for Page 17 Pulse Width Modulation & PID ControllerAutomation and Industrial Solutions

  • SIEMENSInput Scaling

    Configuring the Input/Output fields in the dialog box is made easier by the following special features,The Intellisence feature aids in configuration by providing a list of

    Intellisense and automatic connection, slideonly valid possible connection variables (symbolic names) like the Input value input shown in theabove. The automatically connection feature then connects that symbolic variable to the correct input oroutput of the pID_Compact box instruction.

    $7-1200 TIA SystemSITRAIN Training for Page 18 Pulse Width Modulation & PID ControllerAutomation and Industrial Solutions

  • SIEMENSInput Scaling

    The input scaling takes the raw data value from the analog input signal such as 0 to 27648 or -27648 to+27648 and assigns the desired engineering units. So that the value entered at the upper limit is nowassociated with the max raw data value of 27648 and the value entered at the lower limit is nowassociated with the minimum raw data value of 0 or -27648. This is dependent on the type of analogsignal entering the analog card.

    S7-1200 TIA SystemSITRAIN Training for Page t9 Pulse Width Modulation & PID ControllerAutomation and Industrial Solutions

  • Input Monitoring

    SIEMENS

    Numerical alarm warning points are entered into the input monitoring menu prompt and will be used toset alarm bits that can be configured on the pID_Compact instruction box.

    $7-1200 TIA SystemSITRAIN Training for Page 20 Pulse Width Modulation & PID ControllerAutomation and Industrial Solutions

  • Set PWM Hysteresis

    SIEMENS

    Edit the PWM limits menu prompt to enter the minimum on time and the minimum off time of the outputsignal of the piD_Compact instruction. PID_Compact instruction will not change the signal Time-on orthe signal Time-off past these limits.

    $7-1200 TIA SystemSITRAIN Training for Page 21 Pulse W~dth Modulation & PID ControllerAutomation and Industrial Solutions

  • Edit the Output limit menu prompt to enter an upper limit and a low limit for the PID_Compact instructionto use in the function calculation.

    $7-1200 TIA SystemSITRAIN Train ng for Page 22 Pulse W~dth ModuLation & PID ControllerAutomation and Industrial So utions

  • SIEMENS

    If the PID tuning parameters are known, the PID tuning parameters values can be set manually throughthis configuration dialog box and then the check box should be checked in order to utilize thoseparameters, as shown in the slide. The PID tuning parameters can be determined by using the auto-tunefeature.

    $7-1200 TIA SystemSITp~&.IN Training for Page 23 Pulse Width Modulation & PID ControllerAutomation and Industrial Solutions

  • Optional warning alarm bit variable can be configured in the piD_Compact instruction box to provideinputs to logic operation and/or drive animation on the HML

    $7-1200 TIA SystemSlTRA N Train ng for Page 24 Pulse Width Modulation & PID ControllerAutomation and Indus dal So utions

  • SIEMENSCommissioning - Workflow

    Download Projected controller +technological object

    start commissioning

    start scope

    , Run "Startup Tuning"(turn-over tangent method)

    Run "Tuning in Run"(Step response)

    Upload PiD-parameterto project

    activate automatic modeSet [oPID_compact-DBsReti-Mde] to mode 3

    After the PID Compact instruction box has been configured and compiled, the program can be downloadto the 1200 C-PU then tested through the Commissioning function as listed in the slide.

    $7-1200 TIA SystemSlTRAIN Training for Page 25 Pulse Width ModuLation & PID ControllerAutomation and Indus~a! Solutions

  • Invoke the Commissioning function by clicking the Commissioning button in the upper right hand cornerof pID_Compact instruction box,

    $7-1200 TIA SystemSlTRAIN Training for Page 26 Pulse Width Modulation & PID ControllerAutomation and In6ustda~ Solutions

  • The Scope has buttons where you can start/stop the measurement and the ability to select the sampletime in ms through the provided sample time field.

    $7-1200 TIA SystemSITRAIN Training for Page 27 Pulse Width Modulation & PID ControllerAutomation and Industrial Solutions

  • The Commissioning scope has several very useful features such as fix scale.

    $7-1200 TIA SystemSITRA N Train ng for Page 28 Pulse W~dth Modulation & PID ControllerAutomation and Indus dal So u ions

  • The Commissioning scope has several very useful features such as the tool to Zoom in.

    S7-1200 TiA SystemSITRAIN Training for Page 29 Pulse W~dth Modulation & PID ControllerAulornalJon and Industrial Solutions

  • The Commissioning scope has several ve~ useful features such as the too[ to Zoom out.

    $7-1200 TIA SystemSITRAIN Training for Page 30 Pulse V~dth Modulation & PID ControllerAutomat(on and Industrial Solutions

  • SIEMENS

    The Commissioning scope has several very useful features such as a window that displays the currentvalues.

    $7-1200 TIA SystemSITRAIN Training for Page 31 Pulse Width Modulation & PID ControllerAutomation and Industrial Solutions

  • SIEMENSCommissioning

    The Commissioning Scope has several features such as the auto tuner function which calculates the PiDloop tuning parameter then uploads them to the PID loop controller, Clicking the button in theoptimization window begins the process.

    $7-1200 TIA SystemSITRAIN Training for Page 32 Pulse Width Modulation & PID ControllerAutomation and Industrial Solutions

  • Commissioning - Kind of CommissioningSIEMENS

    ]he auto tuner creates a step change in the process them monitors the response of the process todetermine to determine the PID loop tuning parameters. The step change causes the process to oscillateas illustrated in the graphic above and illustrated in the slides that follow.

    $7-1200 TIA SystemSITRAIN Training for Page 33 Pulse Width Modulation & PID ControllerAutomation and Industda! Solutions

  • The auto tuner creates a step change in the process them monitors the response of the process todetermine the PID loop tuning parameters. After looking at the setpoint, input, and output, in the graphyou notice that the PID setpoint was changed and the PID input and PID output react to the change. Aprogress bar displays the progress time until the function is completed.

    $7-1200 TIA SystemSITRAIN Training for Page 34 Pulse V~dth Modulation & PID ControllerAutomation and In(~ustdal Solutions

  • "The step change causes the process to oscillate as illustrated in the graphic above.

    $7-1200 TIA SystemSlTRAIN Training for Page 35 Pulse W~dth Modulation & PID ControllerAutomation and Industrial Solutions

  • SIEMENSCommissioning - Online

    The auto tuner calculates the PID tuning parameters then it stores them in PID_Compact data block thathas been associated with PID instruction.

    $7-1200 TIA SystemS TRA N Tra n ng for Page 36 Pulse V~dth Modulation & PID ControllerAutomation and Indus dal So u ons

  • PID ExerciseSIEMENS

    , Pulse Width Modulation (PWM),, PID Controller Exercise PID

    $7-1200 TIA Systen~SlTRAIN Training forAutomation and Industrial So~ulions Page 37 Pulse W~dth Modulation & PID Controller

  • Exercise - PID ControllerSIEMENS

    Hands-on

    Lets just do it ..... the lab for you

    $7-1200 TIA SystemSITRAIN Training for Page 38 Pulse V~dth Modulation & PID ControllerAutomation and Industrial Solutions

  • Task

    Process

    Add new project

    2.3.4.5.

    Click in the Task menu Project > NewName the project ,,Project_exemise_PID_loop"Start "Add new device"Add "Unspecific CPU"Detect (upload) "hardware configuration"

    S7-1200 TIA SystemSITRAIN Training for Page 39 Pulse Width Modulation & PID ControllerAutomation and Industrial Solutions

  • Task

    ProceSs

    Define variable

    6. Start Tag-Editor with a double click

    7, Set up the displayed tags.

    $7-1200 TIA SystemS TRAIN Tra n ng for Page 40 Pulse Width Modulation & PID ControllerAutomation and ndustdal So u ions

  • Hands-on

    Task

    Process

    Implement program code n Man and add cyclc OB

    9,10.11.12,13.14.15.

    Open "Main" (OB1)Add program code like displayedAdd new block out of the project treeSelect "cyclic interrupt OB"Type in the name "cyclic interrupt._PID controlleFGive the OB the manual block number "300"Define the scan time with "lOOms"Hit the Checkbox "Add new and open"

    SITRAIN Training for $7-1200 TIA SystemAutomatlon and Industrial Solutions Page 41 Pulse Width Modulation & PID Controller

  • Task

    Process

    Add PID Controller

    16.

    17.18.

    Add "PID_Compact" block out of the extended instructionsin the "cyclic interrupt_PID controller (OB300).Give the "InstanceDB / Technological object" a name.Add "Instance DB/Technological object" by hitting OK Button.

    $7-1200 TIA SystemSlTRAIN Training forAutomation and industrial Solutions Page 42 Pulse W~dth Modulation & PID Controller

  • Task

    Process

    Parameterize the PID Controller

    19.20.21.22.23.24.25.

    26.

    Mark the "PID_Compact" blockSelect the point basic settings"Select as controller type "Temperature"Select as unit "C".Activate the checkbox "Invert PID-Controller output."Set the Set-point to "85."Select "Input_PER" for the Input value andtype in the variable "heat_sensor" (IW66),Select "OutpuLPER" for the Output value andtype in the variable "fan" (QWS0) an.

    SITRAIN Training for $7-1200 TIA SystemAutomation and Industrial Solullons Page 43 Pulse Width Modulation & PID Controller

  • Exercise 8-1: Scale the InputsSIEMENS

    Task Input scaling

    Process 27.28.29.30.

    Select the point "input scaling".Select for the Scaled upper value "100C.Select for the Scaled lower value "0C."Select for the analog/d{gital converter the values"0" for the lower limit and "27648" for the upper limit.

    SITRAIN Training for $7-1200 T]A SystemAutomation and Industrial Solutions Page 44 Pulse Width Modulation & PID Controller

  • SIEMENSExercise 8-1: Download whole project

    Hands-o~}

    Task Download the whole project

    Process 31.32.

    "Save" the project.Download "All" to the PLC

    SITRAIN Training for S7-1200 TIA SystemAutomation and Industrial Solutions Page 45 Pulse Width Modulation & PID Controller

  • SIEMENS

    Task Commissioning the PID Controller

    Process 33.34.35.36.

    Start the "Commissioning"Start the scope.Select "Tuning in run" and hit the "Start tuning" buttonAfter successful commissioning hit the button"Upload PID parameters to project" and save the project.

    SITRAIN Training for $7-1200 TIA SystemAutomation and industrial Solutions Page 46 Pulse Width Modulation & PID Controller