PLC
After controller start-up, the PLC run-time system receives access to the shared memory areas for V.E. variables between CNC and PLC A distinction is made between in channel and global memory areas.
gpVE[iChannelndex]r
gpVEGlob
In order to simplify the simulation of the memory area for the PLC, it is recommended to export the variable after it is created using the # EXPORT VE command .
For more information see [FCT-C22// Description]
Manual simulation of the variable structure in the PLC
This PLC example below shows how V.E. variables can be used in the PLC by simulating variable structures.
Programing Example

Access to V.E. variables in the PLC
Definition of variable structures for V.E. variables:
TYPE VECTOR_T :
STRUCT
x : LREAL;
y : LREAL;
z : LREAL;
END_STRUCT
END_TYPE
TYPE TARGET_POINT_T :
STRUCT
point : VECTOR_T;
valid : BOOL;
END_STRUCT
END_TYPE
TYPE TRAJEKTORIE_T :
STRUCT
nbr_points : DINT;
name : STRING(127);
points : ARRAY [0..9] OF TARGET_POINT_T;
END_STRUCT
END_TYPE
Definition of structures for the complete assigned V.E. memory area:
TYPE VE_GLOBAL:
STRUCT
var_global_1 : DINT;
END_STRUCT
END_TYPE
TYPE VE_CHAN_1:
STRUCT
var_chan_1 : DINT;
array_chan_1: ARRAY [0..19] OF INT;
name : STRING(127);
Trajectory: TRAJEKTORIE_T;
END_STRUCT
END_TYPE
PLC program to access V.E. variables of channel 1:
PROGAM V_E
VAR
p_ve_chan_1 : POINTER TO VE_CHAN_1;
END_VAR
(* Channel 1 with index 0 - gpVECh[0]*)
p_ve_chan_1 := ADR (gpVECh[0]^.ext_var32[0]);
IF (p_ve_chan_1^.name = ‚’)
THEN
p_ve_chan_1^.trajektorie.name := ‘My Path!’;
p_ve_chan_1^.trajektorie.nbr_points := 2;
p_ve_chan_1^.trajektorie.points[0].valid := TRUE;
p_ve_chan_1^.trajektorie.points[0].point.x := 100.0;
p_ve_chan_1^.trajektorie.points[0].point.y := 200.0;
p_ve_chan_1^.trajektorie.points[0].point.z := 300.0;
p_ve_chan_1^.trajektorie.points[1].valid := TRUE;
p_ve_chan_1^.trajektorie.points[1].point.x := 200.0;
p_ve_chan_1^.trajektorie.points[1].point.y := 400.0;
p_ve_chan_1^.trajektorie.points[1].point.z := 600.0;
END_IF;