Trapezoidal Control
This instruction automatically performs trapezoidal control according to the parameters in the specified DUT.Pulses are output from the specified channel when the control flag for this channel is FALSE and the execution condition is TRUE.
Input
Starting address of area containing the data table
FP-S, FP-X:
F171_PulseOutput_Trapezoidal_DUT
FP0R:
F171_PulseOutput_Trapezoidal_Type0_DUT
F171_PulseOutput_Trapezoidal_Type1_DUT
Pulse output channel:
FP-XH C30 T/P: 0–3
FP-XH C60 T/P: 0–5
FP-S: 0, 2
FP-X R: 0, 1
FP-XC14T: 0, 1, 2
FP-X C30T/C60T: 0, 1, 2, 3
FP0R: 0, 1, 2, 3
Use the following predefined DUT: F171_PulseOutput_Trapezoidal_DUT.
The following parameters can be specified in the DUT:
Initial and final speed
Target speed
Acceleration/deceleration time
Target value
Pulse output control flag
Execution condition
The pulse output frequency changes according to the specified acceleration/deceleration time.The difference between target and initial speed determines the slope of the ramps.
FP-X: When a pulse output instruction is executed and pulses are being output, the pulse output control flag (e.g. sys_bIsPulseChannel0Active) of the corresponding channel is TRUE. No other pulse output instruction can be executed as long as this flag is TRUE.
FPS: The high-speed counter control flag (e.g. sys_bIsHscChannel0ControlActive) and the pulse output control flag (e.g. sys_bIsPulseChannel0Active) are assigned to the same special internal flag number (e.g. R903A). Therefore, when a high-speed counter instruction or a pulse output instruction is executed, both the high-speed counter control flag (e.g. sys_bIsHscChannel0ControlActive) and the pulse output control flag (e.g. sys_bIsPulseChannel0Active) for the channel used are TRUE. No other high-speed counter instruction or pulse output instruction can be executed as long as this flag is TRUE.
FPS: Executing the circular interpolation control instruction F176_PulseOutput_Center sets the circular interpolation control flag (sys_bIsCircularInterpolationActive) to TRUE. The status of this flag is maintained until the target value is reached (even if the execution condition is no longer TRUE). During this time, other pulse output instructions cannot be executed.
FPS: Set any high-speed counter allocated to a pulse output channel to "Unused" in the system registers.
FP-X: Set "Pulse output" for the desired channel in the system registers.
We strongly recommend that you incorporate a forced stop option in your positioning program.
Use the following predefined DUT: F171_PulseOutput_Trapezoidal_Type0_DUT (maximum speed = first target speed) or F171_PulseOutput_Trapezoidal_Type1_DUT (maximum speed = 50kHz).
The target speed can be changed during pulse output.
Two control methods are available:
Type 0: The speed can be changed within the range of the target speed specified first.
Type 1: The speed can be changed within the range of the maximum speed (50kHz).
The following parameters can be specified in the DUT:
Pulse output characteristics
Initial and final speed
Target speed
Acceleration time
Deceleration time
Target value
Pulse output control flag
Execution condition
Decelerated stop request
Type 0:
The difference between target speed and initial speed determines the slope of the acceleration ramp.The difference between target speed and final speed determines the slope of the deceleration ramp.
Type 1:
The difference between the maximum speed of 50kHz and the initial speed determines the slope of the acceleration ramp.The difference between the maximum speed of 50kHz and the final speed determines the slope of the deceleration ramp.
Pulses are output using a duty of 25%.With the pulse output method "pulse/direction", pulses are output approx. 300ms after the direction signal has been output; the motor driver characteristics are simultaneously taken into consideration.
Decelerated stop
To perform a decelerated stop, set bit 5 of the data register storing the pulse output control code from FALSE to TRUE (e.g. MOVE(16#120, sys_wHscOrPulseControlCode);
).When a decelerated stop is requested during acceleration, deceleration is performed with the same slope as deceleration from the target speed.
Changing the target speed during pulse output
Type 1: The speed can be changed within the range of the maximum speed (50kHz).
Target speed
1st change of target speed
2nd change of target speed
Acceleration time
Acceleration
Deceleration
Deceleration time
Pulse output control flag
Execution condition
To change the speed, keep the execution condition TRUE.
Type 0:
If a value larger than the target speed at start-up is specified, it will be corrected to the target speed at start-up.
Type 1:
If the target speed is set to a value larger than 50kHz, it will be corrected to 50kHz.
If the elapsed value crosses over the acceleration forbidden area starting position (e.g. sys_diPulseChannel0AccelerationForbiddenAreaStartingPosition) during acceleration, acceleration cannot be performed.
The deceleration speed cannot be lower than the corrected final speed.
As soon as you begin editing a program online (i.e., in RUN mode) using this instruction, pulse output will stop.
If both the main program and the interrupt program contain code for the same channel, make sure both are not executed simultaneously.
We strongly recommend that you incorporate a forced stop option in your positioning program.
All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.
VAR
bMotorSwitch: BOOL:=FALSE;
dutTrapez: F171_PulseOutput_Trapezoidal_DUT:=dwControlCode := 16#1100;
(*Control code:
Digit 3: 1=Duty ratio 25%
Digit 2: 1=Frequency range 48Hz-100kHz
Digit 1: 0=Relative value control
Digit 0: 0=CW/CCW*)
END_VAR
VAR_EXTERNAL
X0_bMotorSwitch: BOOL:=FALSE;
(*at X0*)
END_VAR
VAR
diInitialSpeed: DINT:=100;
diTargetSpeed: DINT:=2000;
diAccelerationTime: DINT:=300;
diTargetValue: DINT:=10000;
@'': @'';
END_VAR
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 16 ;
NETWORK_BODY
B(B_CONTACT,,bMotorSwitch,4,1,6,3,R);
B(B_F,E_MOVE!,Instance,17,4,23,8,,?DEN?D?AENO?C);
B(B_F,E_MOVE!,Instance,17,8,23,12,,?DEN?D?AENO?C);
B(B_VAROUT,,dutTrapez.diTargetSpeed,23,6,25,8,);
B(B_VARIN,,diTargetSpeed,15,6,17,8,);
B(B_VAROUT,,dutTrapez.diAccelerationAndDecelerationTime,23,10,25,12,);
B(B_VARIN,,diAccelerationTime,15,10,17,12,);
B(B_F,E_MOVE!,Instance,17,12,23,16,,?DEN?D?AENO?C);
B(B_VAROUT,,dutTrapez.diTargetValue,23,14,25,16,);
B(B_VARIN,,diTargetValue,15,14,17,16,);
B(B_F,E_MOVE!,Instance,17,0,23,4,,?DEN?D?AENO?C);
B(B_VAROUT,,dutTrapez.diInitialAndFinalSpeed,23,2,25,4,);
B(B_VARIN,,diInitialSpeed,15,2,17,4,);
L(7,2,7,6);
L(7,6,7,10);
L(1,2,4,2);
L(6,2,7,2);
L(7,2,17,2);
L(7,6,17,6);
L(7,10,17,10);
L(7,10,7,14);
L(7,14,17,14);
L(1,0,1,16);
END_NETWORK_BODY
END_NET_WORK
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 6 ;
NETWORK_BODY
B(B_CONTACT,,bMotorSwitch,4,2,6,4,R);
B(B_VARIN,,dutTrapez,14,3,16,5,);
B(B_VARIN,,0,14,4,16,6,);
B(B_F,F171_PulseOutput_Trapezoidal!,Instance,16,1,31,6,,?DEN?Ds_dutDataTable?Hn_iPulseOutputChannel?AENO);
L(6,3,16,3);
L(1,3,4,3);
L(1,0,1,6);
END_NETWORK_BODY
END_NET_WORK
END_BODY
IF DF(bMotorSwitch) then
dutTrapez.diInitialAndFinalSpeed:=diInitialSpeed;
dutTrapez.diTargetSpeed:=diTargetSpeed;
dutTrapez.diAccelerationDecelerationTime:=diAccelerationTime;
dutTrapez.diDeviationCounterClearSignalOutputTime:=10;
END_IF;
IF DF(bMotorSwitch) then
F171_PulseOutput_Trapezoidal(s_dutDataTable := dutTrapez,
n_iPulseOutputChannel :=0);
END_IF;