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
Pulse output: 0 or 1
Use the following predefined DUT: F168_PulseOutput_Trapezoidal_DUT
Control code
Initial and final speed
Target speed
Acceleration/deceleration time
Target value
Pulse stop (fixed)
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.
Set any high-speed counter allocated to a pulse output channel to "Unused" in the system registers.
When programs are being edited in RUN mode, pulse output stops but resumes after the program changes have been downloaded.
If both the main program and the interrupt program contain code for the same channel, make sure both are not executed simultaneously.
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.
Pulse output stops when the upper limit of the internal elapsed value is exceeded if rotation is in one direction only. As a countermeasure, reset the elapsed value to 0 before executing this instruction. Pulse output does not stop when the FP0R is used in FP0 compatibility mode because the data range for the elapsed value is a signed 32-bit value.
We strongly recommend that you incorporate a forced stop option in your positioning program.
The status of the high-speed counter control flag or pulse output control flag may change while a scan is being carried out. For example, if the number of received bytes is read more than once different statuses may exist within one scan.
To run the FP0R in FP0 compatibility mode, you can download an FP0 program to the FP0R. Please note the following restrictions:
The FP0R supports signed 32-bit data for elapsed value and target value; the FP0 supports signed 24-bit data. In FP0 compatibility mode, counting and pulse output continue even if data exceeds the FP0 range.
The duty ratio is always 25% regardless of the settings in the instructions. 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.
The FP0R does not support the "no counting" setting. Instead, incremental counting is performed with the FP0 pulse output instructions set to "no counting".
The maximum pulse output frequency is 10000Hz.
Make sure the pulse output instruction does not use an output that is also being used as a normal output.
An FP0 program can only run in FP0 compatibility mode, if the PLC types (C10, C14, C16, C32, and T32) match exactly. FP0 compatibility mode is not available for the F32 type FP0R.
Channel and pulse output numbers
Channel no. | Pulse output | Pulse output method |
0 |
Y0 |
Pulse |
Y2 |
Direction | |
1 |
Y1 |
Pulse |
Y3 |
Direction |
System variables for memory areas used. Values in parentheses are valid for FP0 T32.
Description |
System variable |
|
---|---|---|
Pulse output: control flag for channel |
0 |
sys_bIsPulseChannel0Active |
1 |
sys_bIsPulseChannel1Active |
|
Pulse output: elapsed value for channel |
0 |
sys_diPulseChannel0ElapsedValue |
1 |
sys_diPulseChannel1ElapsedValue |
|
Pulse output: target value for channel |
0 |
sys_diPulseChannel0TargetValue |
1 |
sys_diPulseChannel1TargetValue |
|
High-speed counter or pulse output controlcode |
sys_wHscOrPulseControlCode |
if initial speed < 40
if initial speed > maximum speed
if initial speed < 40
if initial speed > maximum speed
In the global variable list you define variables that can be accessed by all POUs in the project.
The DUT F168_PulseOutput_Trapezoidal_DUT is predefined in the FP Library.
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
dutTrapez: F168_PulseOutput_Trapezoidal_DUT:=wControlCode := 16#102,
iInitialAndFinalSpeed := 1000,
iTargetSpeed := 7000,
iAccelerationAndDecelerationTime := 300,
diTargetValue := 10000;
END_VAR
VAR_EXTERNAL
X0_bMotorSwitch: BOOL:=FALSE;
(*at X0*)
END_VAR
VAR
@'': @'';
@'': @'';
END_VAR
When X0_bMotorSwitch turns to TRUE the function is executed.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 6 ;
NETWORK_BODY
B(B_CONTACT,,X0_bMotorSwitch,4,2,6,4,R);
B(B_VARIN,,dutTrapez,11,3,13,5,);
B(B_VARIN,,0,11,4,13,6,);
B(B_F,F168_PulseOutput_Trapezoidal!,Instance,13,1,28,6,,?DEN?Ds_dutDataTable?Hn_iPulseOutputChannel?AENO);
L(6,3,13,3);
L(1,3,4,3);
L(1,0,1,6);
END_NETWORK_BODY
END_NET_WORK
END_BODY
IF DF(X0_bMotorSwitch) then
F168_PulseOutput_Trapezoidal(s_dutDataTable := dutTrapez,
n_iPulseOutputChannel :=0);
END_IF;