Hi all, next challenge
From a PLC I receive data in form of a 'struct in struct' principle which I want to use in the simulation model. How to connect the substructs to a 'for each' block in simulink (and how to configure it)?
In details:
The PLC logs the data each PLC scan according to the structure of its program. The data has an array of devices 'arrstDevDspBox(n)' and that contains several substructs (the layout/byte size is known). It is buildup like this:
simSignalDataIn.arrstDevDspBox(1).stHW.stIN.stAdc.C1 = timeseries(int16(1),simTimeData);
simSignalDataIn.arrstDevDspBox(1).stHW.stIN.stAdc.R1 = timeseries(int16(1),simTimeData);
simSignalDataIn.arrstDevDspBox(1).stHW.stIN.stAdc.C2 = timeseries(int16(1),simTimeData);
simSignalDataIn.arrstDevDspBox(1).stHW.stIN.stAdc.R2 = timeseries(int16(1),simTimeData);
simSignalDataIn.arrstDevDspBox(1).stHW.stIN.stAdc.C3 = timeseries(int16(1),simTimeData);
simSignalDataIn.arrstDevDspBox(1).stHW.stIN.stAdc.R3 = timeseries(int16(1),simTimeData);
simSignalDataIn.arrstDevDspBox(1).stHW.stIN.stAdc.C4 = timeseries(int16(1),simTimeData);
simSignalDataIn.arrstDevDspBox(1).stHW.stIN.stAdc.R4 = timeseries(int16(1),simTimeData);
simSignalDataIn.arrstDevDspBox(1).stHW.stIN.nStatusFromMotors = timeseries(uint16(1),simTimeData);
simSignalDataIn.arrstDevDspBox(1).stLYR.stIN.stDevDspProbeA.bCmdMoveUpComplete = timeseries(logical(1),simTimeData);
simSignalDataIn.arrstDevDspBox(1).stLYR.stIN.stDevDspProbeA.bStaDriveIssue = timeseries(logical(1),simTimeData);
simSignalDataIn.arrstDevDspBox(1).stLYR.stIN.stDevDspProbeA.bStaOperational = timeseries(logical(1),simTimeData);
simSignalDataIn.arrstDevDspBox(1).stLYR.stIN.stDevDspProbeB.bCmdMoveUpComplete = timeseries(logical(1),simTimeData);
simSignalDataIn.arrstDevDspBox(1).stLYR.stIN.stDevDspProbeB.bStaDriveIssue = timeseries(logical(1),simTimeData);
simSignalDataIn.arrstDevDspBox(1).stLYR.stIN.stDevDspProbeB.bStaOperational = timeseries(logical(1),simTimeData);
simSignalDataIn.arrstDevDspBox(1).stLYR.stIN.bCmdClearBuffer = timeseries(logical(1),simTimeData);
simSignalDataIn.arrstDevDspBox(1).stLYR.stIN.bStaHeightMeasurementActive = timeseries(logical(1),simTimeData);
simSignalDataIn.arrstDevDspBox(1).stLYR.stIN.fActXposition = timeseries(double(1),simTimeData);
This data is imported into MATLAB and the structure is available as 'struct in struct' of timeseries. I created a subsystem that is capable of handling this device data which I want to call in a 'for each' loop.
So with the example above I want to connect 'simSignalDataIn.arrstDevDspBox(n).stHW.stIN' to the input 'i_stHW' from the 'for each' block. And the 'simSignalDataIn.arrstDevDspBox(n).stLYR.stIN' to the input 'i_stLYR' from the 'for each' block. In case that it matters, all block inputs have a distinct 'simulink.bus' definition available.
Within a text based (PLC) programm I would make something like:
i_stHW := simSignalDataIn.arrstDevDspBox(idx).stHW.stIN, ...
i_stLYR := simSignalDataIn.arrstDevDspBox(idx).stLYR.stIN)
So how to do this in simulink? Thanks for any reply upfront.
Ludo