Programming instructions 6
6.2 Extended instructions
6.2.7 Motion control instructions
The motion control instructions use an associated technology data block and the dedicated PTO (pulse train outputs) of the CPU to control the motion on an axis. For information about the motion control instructions, refer to the online help of the TIA portal.
MC_Power enables and
disables a motion control axis. MC_Reset resets all motion control errors. All motion control errors that can be acknowledged are acknowledged.
长沙工控帮教育科技有限公司整理
Programming instructions 6.2 Extended instructions
MC_Home establishes the relationship between the axis control program and the axis mechanical positioning system.
MC_Halt cancels all motion processes and causes the axis motion to stop. The stop position is not defined.
MC_MoveJog executes jog mode for testing and startup purposes.
MC_MoveAbsolute starts motion to an absolute position.
The job ends when the target position is reached.
MC_MoveRelative starts a positioning motion relative to the start position.
MC_MoveVelocity causes the axis to travel with the specified speed.
6.2.8 Pulse instruction
6.2.8.1 CTRL_PWM instruction
ཱ ཱ
① Cycle time The CTRL_PWM Pulse Width Modulation (PWM)
instruction provides a fixed cycle time output with a variable 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. ② Pulse width time
Duty cycle can be expressed as a percentage of the cycle time (0 – 100%), as thousandths (0 – 1000), as ten thousandths (0 – 10000), or as S7 analog format. The pulse width can vary from 0 (no pulse, always off) to full scale (no pulse, always on).
长沙工控帮教育科技有限公司整理
Programming instructions 6.2 Extended instructions
Since the PWM output can be varied from 0 to full scale, it provides a digital output that in many ways is the same as an analog output. For example, the PWM output can be used to control the speed of a motor from stop to full speed, or it can be used to control position of a valve from closed to fully opened.
Two pulse generators are available for controlling high-speed pulse output functions: PWM and Pulse train output (PTO). PTO is used by the motion control instructions. You can assign each pulse generator to 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 following table. You can use onboard CPU outputs, or you can use the optional signal board outputs.
The output point numbers are shown in the following table (assuming the default output configuration). If you have changed the output point numbering, then the output point numbers will be those you assigned. Regardless, PTO1/PWM1 uses the first two digital outputs, and PTO2/PWM2 uses the next two digital outputs, either on the CPU or on the attached signal board. Note that PWM requires only one output, while PTO can optionally use two outputs per channel. If an output is not required for a pulse function, it is available for other uses.
Description Default output assignment
Pulse Direction
Configuring a pulse channel for PWM
To prepare for PWM operation, first configure a pulse channel in the device configuration by selecting the CPU, then Pulse Generator (PTO/PWM), and choose either PWM1 or PWM2.
Enable the pulse generator (check box). If a pulse generator is enabled, a unique default name is assigned to this particular pulse generator. You can change this name by editing it in the "Name:" edit box, but it must be a unique name. Names of enabled pulse generators will become tags in the "constant" tag table, and will be available for use as the PWM parameter of the CTRL_PWM instruction. You have the option to rename the pulse generator, add a comment, and assign parameters as follows:
PWM pulse options
● Pulse generator used as follows: PWM or PTO (choose PWM)
● Output source: onboard CPU or Signal Board
● Time base: milliseconds or microseconds
长沙工控帮教育科技有限公司整理
Programming instructions 6.2 Extended instructions
● Pulse width format:
– Percent (0 – 100) – Thousandths (0 – 1000) – Ten-thousandths (0 – 10000) – S7 analog format (0 – 27648)
● Cycle time: Enter your cycle time value. This value can only be changed here.
● Initial pulse width: Enter your initial pulse width value. The pulse width value can be changed during runtime.
Output addresses
Start address: Enter the Q word address where you want to locate the pulse width value.
The default location is QW1000 for PWM1, and QW1002 for PWM2. The value at this location controls the width of the pulse and is initialized to the "Initial pulse width:" value specified above each time the PLC transitions from STOP to RUN mode. You change this Q-word value during run time to cause a change in the pulse width.
LAD FBD
Parameter Parameter
type Data
type Initial value Description
PWM IN WORD 0 PWM identifier:
Names of enabled pulse generators will become tags in the "constant" tag table, and will be available for use as the PWM parameter.
ENABLE IN BOOL 1=start pulse generator
0 = stop pulse generator
BUSY OUT BOOL 0 Function busy
STATUS OUT WORD 0 Execution condition code
Operation
A data block (DB) is used by the CTRL_PWM instruction to store parameter information.
When placing a CTRL_PWM instruction into the program editor, a DB will be assigned. The data block parameters are not separately changed by the user, but are controlled by the CTRL_PWM instruction.
Specify the enabled pulse generator to use, by using its tag name for the PWM parameter.
长沙工控帮教育科技有限公司整理
Programming instructions