Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched.
Close
First you have to create a structure:
In CoDeSys you have to add to the application a "DUT: Data Unit Type". Give it a name and select Structure.
Now you can add the (standard) variables which are part of this structure.
In your POU you can add a new variable of the structure which you have created. e.g.:
aStruct:ARRAY[0..constant]OFmyStructure;
In this case myStructure is the name of your new type.
aStruct is the instance of this struct.
In CoDeSys you can use the variable: aStruct[index].standardVar
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You have to put the instance of the structure (EQ_SDI_TEMP_SONDA : ARARAY[0..5] OF EQ_SDI_TEMP_SONDA_ATT;) in the POU or Global Variable List. Not in the Structure itself.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I want to implement that program written in C with CoDeSys written in ST language. I don't know how to do "EQ_SDI_TEMP_SONDA[i].m_TempNOK".
The program:
/******
OBJECT ATTRIBUTES /
struct EQ_SDI_TEMP_SONDA_ATT EQ_SDI_TEMP_SONDA[c_EQ_SDI_TEMP_SONDA_MAX_OBJ];
/*****
METHODS /
/------------------------------------------------------------
---- EQ_SDI_TEMP_SONDA_SetInput ----------------------------------*
void EQ_SDI_TEMP_SONDA_SetInput(CS_UNSIGNED8 i,
CS_UNSIGNED16 In1, / Entrada temperatura SDI. /
CS_BOOLEAN1 In1Ok, / Validez de la entrada. /
CS_UNSIGNED16 In2 / Entrada temperatura PLC. /
) {
/---- Local Variables --------------/
/---- Comprobacion de index --------------/
PLC_CheckIndex(EQ_SDI_TEMP_SONDA_SetInput, i, c_EQ_SDI_TEMP_SONDA_MAX_OBJ);
/---- Timers -----------------------/
/---- Code -------------------------/
/---- Former values -------------------------/
}
/------------------------------------------------------------
------- EQ_SDI_TEMP_SONDA_GetValue ------------------------------
CS_BOOLEAN1 EQ_SDI_TEMP_SONDA_GetValue(CS_UNSIGNED8 i) { / Devuelve el valor. /
}
First you have to create a structure:
In CoDeSys you have to add to the application a "DUT: Data Unit Type". Give it a name and select Structure.
Now you can add the (standard) variables which are part of this structure.
In your POU you can add a new variable of the structure which you have created. e.g.:
In this case myStructure is the name of your new type.
aStruct is the instance of this struct.
In CoDeSys you can use the variable: aStruct[index].standardVar
I make this but isn't correct.
TYPE
EQ_SDI_TEMP_SONDA_ATT:
STRUCT
m_TempNOK : BOOL;
EQ_SDI_TEMP_SONDA : ARARAY[0..5] OF EQ_SDI_TEMP_SONDA_ATT;
END_STRUCT;
END_TYPE
You have to put the instance of the structure (EQ_SDI_TEMP_SONDA : ARARAY[0..5] OF EQ_SDI_TEMP_SONDA_ATT;) in the POU or Global Variable List. Not in the Structure itself.