Programming
(Original Document)
Introduction
The module calculates the position reading from an incremental encoderconnected to its inputs. Depending on this position and the cam programtransferred which describes the recipe, the module controls its outputs.
We will use the IODDT Channel_0 of type T_CCY_GROUP0 which we will associate with channel 0 of the TSX CCY module situated in slot 3 of the basic rack.
We use one section to carry out the preliminary processing and another to carry out the subsequent processing.
We will also need an event task.
Preliminary section
(*SFC Chart initialization*)
IF NOT %M0 THEN SET %S21;
END_IF;
(* immediate cycle stop *)
IF %M3 THEN SET(%S21);RESET(Channel_0.Pcam_start_stop); Channel_0.ENAB_GROUP0_BITS:=0;RESET(%M3);RESET(%M0);
END_IF;
(* Power outage management *)
IF %S1 THEN SET(%S21);RESET(Channel_0.Pcam_start_stop); Channel_0.ENAB_GROUP0_BITS:=0;RESET(Channel_0.OUTS_ENABLE);
			END_IF;
(* Recipe management *)
(* saving recipe 1 in words %mw100 onwards *)
IF %M11 THEN TRF_RECIPE (Channel_0, 1,100);RESET(%M11)
		END_IF;
(* saving recipe 2 in words %MW850 onwards *)
IF %M12 THEN TRF_RECIPE (Channel_0,1,850);RESET(%M12);
		END_IF;
(*Restoring recipe 1 from the %MW100 word*)
IF %M13 THEN TRF_RECIPE (Channel_0,0,100);RESET(%M13);RESET(Channel_0.Pcam_start_stop);
		END_IF;
(*Restoring recipe 2 from the %mw850 word*)
IF %M14 THEN TRF_RECIPE (Channel_0,0,850);RESET(%M14);RESET(Channel_0.Pcam_start_stop);
		END_IF;
(* restoring the recipe switches the processor cam to STOP and so the command must be reset to zero *)
SFC
This illustration describes the Chart of the example.
Step 0 -> 1
(* start cycle? *)
%M0
Action on activation step 1
(* Initializing enable and assignment parameters *)
(* assigning tracks to GRP outputs '7 tracks / 7 outputs' *)
Channel_0.Group0_and_bits:=16#007F;
(* Reset parts counter *)
SET(Channel_0.Came_pieces_reset);
(* Authorization to control group 0 outputs *)
SET(Channel_0.OUTS_ENABLE);
(* Event authorization when angle rolls over *)
SET(Channel_0.Evt_ang_enable);
(* Acknowledge faults during start-up phase *)
SET(Channel_0.Came_ack_flt);
Step 1 -> 2)
(* fault? *)
NOT Channel_0.Ch_error;
Action on activation step 2
(* Type 1 function therefore recalibrate angle *)
SET(Channel_0.Preset_ang_enable);
Action on deactivation step 2
(* Reset recalibration *)
RESET(Channel_0.Preset_ang_enable);
Step 2 -> 3
(* Counter recalibrated? *)
Channel_0.Ang_ok;
Action on activation step 3
(*setting the cam processor to run *)
SET(Channel_0.Pcam_start_stop);
Step 3 -> 4
(* cam processor in RUN? *)
Channel_0.Pcam_on;
Action on activation step 4
(* Enabling parts counter *)
RESET(Channel_0.Came_pieces_reset);
SET(Channel_0.Pieces_enable);
Subsequent section
(* Managing faults *)
IF Channel_0.Ch_error THEN SET(%S21); END_IF;
(* Fault acknowledgement *)
IF %M1	 THEN SET(Channel_0.Came_ack_flt);RESET(%M1);
		ELSE RESET(Channel_0.Came_ack_flt);	END_IF;
(* Reading fault type *)
IF %M2 THEN READ_STS(Channel_0);RESET(%M2);	END_IF;
EVENT-EVT1
(* Managing cycle rollovers for starting *)
(* Detecting angle number rollovers *)
IF Channel_0.Evt_ang AND %M0 THEN INC(%MW0);END_IF;
(* Action on detection of cycle rollovers, validation of cams *)
IF(%MW0=1)AND %M0 THEN SET(Channel_0.ENAB_GROUP0_BITS.1);END_IF;
IF(%MW0=2)AND %M0 THEN SET(Channel_0.ENAB_GROUP0_BITS.2);END_IF;
IF(%MW0=3)AND %M0 THEN SET(Channel_0.ENAB_GROUP0_BITS.3);END_IF;
IF(%MW0=4)AND %M0 THEN SET(Channel_0.ENAB_GROUP0_BITS.4);END_IF;
IF(%MW0=5)AND %M0 THEN SET(Channel_0.ENAB_GROUP0_BITS.5);END_IF;
IF(%MW0>6)AND %M0 THEN %MW0:=6;END_IF;
(* Managing cycle rollovers for stopping *)
(* Detecting angle number rollovers *)
IF Channel_0.Evt_ang AND NOT %M0 THEN DEC(%MW0);END_IF;
(* Action on detection of cycle rollovers, disabling cams *)
IF(%MW0=5)AND NOT %M0 THEN RESET(Channel_0.ENAB_GROUP0_BITS.0);END_IF;
IF(%MW0=4)AND NOT %M0 THEN RESET(Channel_0.ENAB_GROUP0_BITS.1);END_IF;
IF(%MW0=3)AND NOT %M0 THEN RESET(Channel_0.ENAB_GROUP0_BITS.2);END_IF;
IF(%MW0=2)AND NOT %M0 THEN RESET(Channel_0.ENAB_GROUP0_BITS.3);END_IF;
IF(%MW0=1)AND NOT %M0 THEN RESET(Channel_0.ENAB_GROUP0_BITS.4);END_IF;
IF(%MW0=0)AND NOT %M0 THEN RESET(Channel_0.ENAB_GROUP0_BITS.5);END_IF;
IF(%MW0<1)AND NOT %M0 THEN %MW0:=0;END_IF;
(* Managing event stack overflow on cam card *)
(* Detecting overflow *)
IF Channel_0.Direction_evt THEN SET(%M15);END_IF;
Variables used
Table
Address
Symbol
Comments
%M0
Dcy
Start cycle
%M1
Ack_def
Acknowledging fault
%M2
Read_def
Reading fault
%M3
Stop_imm
Immediate stop of the machine
%M5
Counter_plein
%M11
Save_recipe1
Saving Recipe 1
%M12
Save_recipe2
Saving Recipe 2
%M13
Restore_recipe1
Restoring Recipe 1
%M14
Restore_recipe2
Restoring Recipe 2
%M15
(* Detecting overflow *)
%MW0
Comp_modulo_ang
Evt. rollover counter
%MW2
Comp_comp_pieces
%I0.3.0.Err
Channel_0.Ch_error
Channel error bit
%I0.3.0
Channel_0.Ang_ok
Valid angle reading
%I0.3.0.3
Channel_0.Pcam_on
Cam processor RUN/STOP
%IW0.3.0
Channel_0.Group0_strack
State of tracks i.0 to i.7
%IW0.3.0.12.0
Channel_0.Evt_ang
Angle value rollover event
%IW0.3.0.12.6
Channel_0.Evt_pieces_full
Reaching limit value for the parts counter event
%IW0.3.0.12.15
Channel_0.Direction_evt
Direction of movement on ANG_EVT or TURN_EVT
%Q0.3.00.0
Channel_0.Preset_ang_enable
Enables (re)calibration function on angle value only
%Q0.3.00.5
Channel_0.Pcam_start_stop
Set: Cam processor start/ cam processor reset stop
%Q0.3.00.7
Channel_0.Pieces_enable
Enables the parts counter function
%Q0.3.00.8
Channel_0.Evt_ang_enable
Enables the ANG_EVT event source
%Q0.3.00.14
Channel_0.Evt_piece_full_enable
Enables the PIECES_FULL_EVT event source
%Q0.3.00.15
Channel_0.Came_ack_flt
Command to acknowledge faults present
%Q0.3.00.23
Channel_0.Came_pieces_reset
Reset parts counter
%Q0.3.0.25
Channel_0.OUTS_ENABLE
Global enabling of track outputs
%QW0.3.0
Channel_0.ENAB_GROUP0_BITS
8 enable bits associated with the group
%QW0.3.0.1
Channel_0.Group0_and_bits
8 bits for assigning tracks to group outputs