I have a structured text program running in codesys 3.5, in which I want to set the mode of some motor to several values. In order to have good encapsulated code I defined the following struct:
{attribute 'strict'}
TYPE PD4_modes :
(
no_mode := 0,
position:= 1,
velocity := 2,
homing_mode := 3
) UINT;
END_TYPE
However as soon as I try to assign this value to the appropriate variable (an sint
) which drives the motor mode as so:
mot1_ctrmode = PD4_modes.homing_mode
I get the error: type PD4_modes cannot be cast to sint
. Why is that? I thought I defined the modes as uint in the struct? Therefore no casting should be necessary right? I also tried to erase the attribute strict
but that did not help...