3
After first scan, use MC_MoveVelocity to continually set the PWM frequency (for example: 50,000 => 50 KHz) from global variable
G_PWM_Frequency. PWM axis will run forever (until Program Mode, MC_Halt, and so on).
__SYSVA_FIRST_SCAN
Rockwell Automation Publication 2080-UM002K-EN-E - March 2019
MC_MoveVelocity_1
MC_MoveVelocity
EN
PWM0
AxisIn
TRUE
Execute
G_PWM_Frequency
Velocity
50000.0
Acceleration
50000.0
Acceleration
Deceleration
0.0
1
Jerk
DirectionIn
0
POU PWM_Program
The POU defines four variables.
Variable MC_Power_1
(* *)
Direction: VAR
Data Type: MC_Power
Attribute: ReadWrite
Direct variable (Channel):
Variable Update_PWM_Duty_Cycle
(* *)
Direction: Var
Data type: BOOL
Attribute: ReadWrite
Direct variable (Channel):
ENO
Axis
InVelocity
Busy
Active
Direction
CommandAborted
Error
ErrorID
Variable MC_MoveVelocity_1
(* *)
Direction: VAR
Data Type: MC_MoveVelocity
Attribute: ReadWrite
Direct variable (Channel):
Variable MC_Power_1
(* *)
Direction: VAR
Data Type: MC_Power
Attribute: ReadWrite
Direct variable (Channel):
Motion Control Chapter 7
131