I am trying to configure the settings on my 750-450 module using codesys but I am running into the limit of what I know about programming these (which is limited). The image is what I have in my continuous function chart but I’m not sure how to actually get these two settings (eSensorType and eWireType) into the module so that I can get the adjusted output
The iwDryBulb is the raw value as it is defined in my global variables: iwDryBulb AT %IW1:INT;
The above may be way off from what I am supposed to be doing so I have also tried the following:
Based on the solution posted here:
In the below code, I have changed the 451 to 450, changed the sensor type and added the wire mode. The question I have for this is where do I put this code and how can it get called to actually configure the 750-450 module? Would I add it as a program, function block, function, POU?
For the code when I add it, it seems to redline everything past starting at IF NOT xInit_450 AND NOT xError THEN. It says ‘This code is not supported in declaration part’ which makes me assume I am not putting it in the right place. Any help would be appreciated, I’m sorry I am still pretty new at this.
VAR
usiChannel_450 : USINT (1..WagoSysModule_750_450.WagoTypesModule_750_450.MAX_CHANNEL_450) := 1;
xGetRawChannelConfiguration_450 : BOOL := TRUE;
utRawChannelConfiguration_450 : WagoSysModule_750_450.WagoTypesModule_750_450.typRawChannelConfiguration; // here also an array can be defined to configure the channels differently if necessary
ogetError_450 : WagoSysModule_750_450.WagoSysErrorBase.FbResult;
xSetRawChannelConfiguration_450 : BOOL;
osetError_450 : WagoSysModule_750_450.WagoSysErrorBase.FbResult;
osetstatus_450 : ARRAY[1..WagoTypesModule_750_450.MAX_CHANNEL_450] OF WagoSysErrorBase.FbResult;
ogetstatus_450 : ARRAY[1..WagoTypesModule_750_450.MAX_CHANNEL_450] OF WagoSysErrorBase.FbResult;
eServiceState_450_Get : WagoSysModule_750_450.WagoTypesModuleBase.eServiceState;
eServiceState_450_Set : WagoSysModule_750_450.WagoTypesModuleBase.eServiceState;
mySensorType : WagoTypesModule_750_450.eSensorType := WagoTypesModule_750_450.eSensorType.Pt100_EN60751_01; //Using Pt100's
myWireMode : WagoTypesModule_750_450.eWireMode := WagoTypesModule_750_450.eWireMode.FOUR_WIRE; // Using 4-wire RTD's
xError : BOOL;
xInit_450 : BOOL;
END_VAR
IF NOT xInit_450 AND NOT xError THEN
eServiceState_450_Get := _750_450_16.GetRawChannelConfiguration(
usiChannel:= usiChannel_450,
xTrigger:= xGetRawChannelConfiguration_450,
utRawChannelConfiguration:= utRawChannelConfiguration_450,
xError=> xError,
oError=> ogetError_450);
CASE eServiceState_450_Get OF
WagoTypesModuleBase.eServiceState.DONE : // OK
xSetRawChannelConfiguration_450 := TRUE; // trigger write
utRawChannelConfiguration_450.Settings.eSensorType:= mySensorType; //Change sensor type
utRawChannelConfiguration_450.Settings.eWireMode:= myWireMode; //Change wire mode type
(* ....
process here your utRawChannelConfiguration
possibly also with an array if the
channels are TO be set differently. *)
WagoTypesModuleBase.eServiceState.ABORT : // Error
// process here your error handling -> see oError for more information
ogetstatus_450[usiChannel_450] := ogetError_450;
xError := TRUE;
END_CASE
eServiceState_450_Set := _750_450_16.SetRawChannelConfiguration(
usiChannel:= usiChannel_450,
xTrigger:= xSetRawChannelConfiguration_450,
utRawChannelConfiguration:= utRawChannelConfiguration_450,
xError=> xError,
oError=> osetError_450);
CASE eServiceState_450_Set OF
WagoTypesModuleBase.eServiceState.DONE : // OK -> new configuration is written
xGetRawChannelConfiguration_450 := TRUE;
osetstatus_450[usiChannel_450] := osetError_450;
usiChannel_450 := usiChannel_450 + 1;
WagoTypesModuleBase.eServiceState.ABORT : // Error -> not able to write -> see oError
// process here your error handling for write -> see oError for more information
osetstatus_450[usiChannel_450] := osetError_450;
xError := TRUE;
END_CASE
// all modules changed?
IF usiChannel_450 > WagoSysModule_750_450.WagoTypesModule_750_450.MAX_CHANNEL_450 THEN
xInit_450 := TRUE;
END_IF
END_IF
The very first thing that I noticed in your code is that it is actually in the variable declaration section of the POU, not the program section. I see you have this as a FB right now, not sure what language you have it declared, but it should be structured text for the type or ST. Thirdly, I would make this a Program, not a FB, as the program as written takes care of the scanning. Once this errors are fixed, let us know you are making progress
I think I was able to work through most of my questions. I created a function block (POU_1 (FB)) using structured text for the implementation language. The top portion (which I believe is the declarations section) has the following code:
FUNCTION_BLOCK POU_1
VAR_INPUT
END_VAR
VAR_OUTPUT
END_VAR
VAR
usiChannel_450 : USINT (1..WagoSysModule_750_450.WagoTypesModule_750_450.MAX_CHANNEL_450) := 1;
xGetRawChannelConfiguration_450 : BOOL := TRUE;
utRawChannelConfiguration_450 : WagoSysModule_750_450.WagoTypesModule_750_450.typRawChannelConfiguration; // here also an array can be defined to configure the channels differently if necessary
ogetError_450 : WagoSysModule_750_450.WagoSysErrorBase.FbResult;
xSetRawChannelConfiguration_450 : BOOL;
osetError_450 : WagoSysModule_750_450.WagoSysErrorBase.FbResult;
osetstatus_450 : ARRAY[1..WagoTypesModule_750_450.MAX_CHANNEL_450] OF WagoSysErrorBase.FbResult;
ogetstatus_450 : ARRAY[1..WagoTypesModule_750_450.MAX_CHANNEL_450] OF WagoSysErrorBase.FbResult;
eServiceState_450_Get : WagoSysModule_750_450.WagoTypesModuleBase.eServiceState;
eServiceState_450_Set : WagoSysModule_750_450.WagoTypesModuleBase.eServiceState;
mySensorType : WagoTypesModule_750_450.eSensorType := WagoTypesModule_750_450.eSensorType.Pt100_EN60751_01; //Using Pt100's
myWireMode : WagoTypesModule_750_450.eWireMode := WagoTypesModule_750_450.eWireMode.FOUR_WIRE; // Using 4-wire RTD's
xError : BOOL;
xInit_450 : BOOL;
END_VAR
The lower section of the structured text function block (I don’t know what that part is called, I guess the program section) has the following code:
IF NOT xInit_450 AND NOT xError THEN
eServiceState_450_Get := _750_450_08.GetRawChannelConfiguration(
usiChannel:= usiChannel_450,
xTrigger:= xGetRawChannelConfiguration_450,
utRawChannelConfiguration:= utRawChannelConfiguration_450,
xError=> xError,
oError=> ogetError_450);
CASE eServiceState_450_Get OF
WagoTypesModuleBase.eServiceState.DONE : // OK
xSetRawChannelConfiguration_450 := TRUE; // trigger write
utRawChannelConfiguration_450.Settings.eSensorType := mySensorType; //Change sensor type
utRawChannelConfiguration_450.Settings.eWireMode := myWireMode; //Change wire mode type
(* ....
process here your utRawChannelConfiguration
possibly also with an array if the
channels are TO be set differently. *)
WagoTypesModuleBase.eServiceState.ABORT : // Error
// process here your error handling -> see oError for more information
ogetstatus_450[usiChannel_450] := ogetError_450;
xError := TRUE;
END_CASE
eServiceState_450_Set := _750_450_08.SetRawChannelConfiguration(
usiChannel:= usiChannel_450,
xTrigger:= xSetRawChannelConfiguration_450,
utRawChannelConfiguration:= utRawChannelConfiguration_450,
xError=> xError,
oError=> osetError_450);
CASE eServiceState_450_Set OF
WagoTypesModuleBase.eServiceState.DONE : // OK -> new configuration is written
xGetRawChannelConfiguration_450 := TRUE;
osetstatus_450[usiChannel_450] := osetError_450;
usiChannel_450 := usiChannel_450 + 1;
WagoTypesModuleBase.eServiceState.ABORT : // Error -> not able to write -> see oError
// process here your error handling for write -> see oError for more information
osetstatus_450[usiChannel_450] := osetError_450;
xError := TRUE;
END_CASE
// all modules changed?
IF usiChannel_450 > WagoSysModule_750_450.WagoTypesModule_750_450.MAX_CHANNEL_450 THEN
xInit_450 := TRUE;
END_IF
END_IF
In the PLC_PRG (PRG) continuous flow chart I added in a block for the POU_1. This definitely changed the raw values that I was reading for my RTD’s and they seem much more sensitive which is what I was expecting:
iwDryBulb AT %IW1:INT;
iwWetBulb AT %IW2:INT;
I’m getting values of 1164 which I am assuming is Celsius so 11.64 deg C so 52.952 deg F which seems about right to me.
I am still not sure I’m calling the POU_1 (FB) correctly, I feel like maybe it’s getting repeatedly called in PLC_PRG (PRG) when it maybe only needs to get called once somewhere else? Thoughts?
Thanks for the help, I have moved the code into a program Config450 (PRG) using structured text. Is there anything that I need to do so that this code gets executed or because it a program now it gets run automatically? It’s greyed out on the left side so I’m assuming that means it’s not being used?
I think I figured out what I was supposed to do. I configured it as a task to run every 10ms. Is this the preferred approach to executing this program?
Tom,
There are multiple ways to call a program, the way you showed above is certainly one way.
Another way would be to call the routine from PLC_PRG. It is your preference there.