FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important
information on the platform change.
09-18-2022 07:14 PM - edited 09-18-2022 07:14 PM
Hi,
for a Test Project i need to log some Data from a Sensor.
The data come from a IO-Link device in cycle time of 5ms . So i guess every 3 PLC cycle i want to record 16 Bytes (1 measurement)
I need around 10000 measurements .
I thought over the IDE App in Python or directly in Codesys.
I am little bit concerned about the storage and the record speed/ rate.
How is the most efficent way to do this ? Is there anyone who already have done this.
Any approach or example is helpful
Thanks in advanced.
Best regards
Christoph Hund
Solved! Go to Solution.
09-19-2022 08:09 AM - edited 12-21-2022 12:30 PM
As python cannot really be connected to a bus cycle in your case I would suggest to use the PLC. Create a task with the cycle time needed by you (e.g. 5ms). Setup an array with 10k variables space and go.
Of course you could also use python or data bases / cloud connector apps for this e.g. via the Bosch - DeviceBridge, Cedalo - Eclipse Mosquitto MQTT Broker or ctrlX CORE - Node-RED App.
09-19-2022 09:45 AM - edited 09-19-2022 09:47 AM
Yes we did some projects where we implemented such stuff in the PLC, as described above.
09-19-2022 01:30 PM - last edited on 09-19-2022 01:37 PM by HmiGuide
Cool , Thanks for the Feedback.
Works pretty good so far.
I have now made an Array for test purpose with a size of 10000.
Which way approach is the best from here ?
Which method you have used ?
Where is the file located on the system / in the data layer ?
Thanks for the help 🙂
09-19-2022 01:57 PM
Use library CXA_FileAsync with FB IL_FileWriteAsync. Have a look into the libaries FB, where you find an example, how to use it.
The plc app only has access to the active configuration folder of the plc app. So just provide a relative name (without a "/" at start) like "myFile.cvs" or "data/myFile.csv"
Use PLC Engineering to browse this folder.
Double click on (1) Select tab "Files" (2) Click on "Refresh" (3)
09-19-2022 02:24 PM
You can additionally access the app data (activeConfiguration). See the modified example from the CXA_FileAsyn library:
Declaration:
PROGRAM WriteFile
VAR
fbFile: CXA_FileAsync.IL_FileAsync;
fbFileWrite: CXA_FileAsync.IL_FileWriteAsync;
filename: STRING := '/var/snap/rexroth-solutions/common/solutions/activeConfiguration/testfile.txt';
itestcase: UINT := 0;
writebuf: STRING(500);
writebuflen: UDINT := 500;
writelen: UDINT := 0;
END_VAR
Implementation:
CASE itestcase OF
1: // open the file
fbFile(Enable:=TRUE, FileName:=ADR(filename), Mode:=IL_FILE_ACCESS_MODE.AM_WRITE);
IF fbFile.InOperation THEN
itestcase := itestcase + 1;
END_IF
2: // write the file
writebuf := 'BoschRexroth$R$NCtrlX Automation$R$NCXA_FileAsync$R$N';
writebuflen := IL_LEN(ADR(writebuf));
fbFileWrite(Execute:=TRUE, FileHandle:=fbFile.FileHandle, BufferAddr:=ADR(writebuf), BufferSize:=writebuflen, BytesWritten=>writelen);
IF fbFileWrite.Done THEN
fbFileWrite(Execute:=FALSE);
itestcase := itestcase + 1;
END_IF
3: // close file
fbFile(Enable:=FALSE);
If NOT fbFile.Shutdown AND NOT fbFile.InOperation THEN
itestcase := 0;
END_IF
END_CASE
IF fbFileWrite.Error OR fbFile.Error THEN
; // post some error
END_IF
09-20-2022 05:20 PM
Thanks for your help works everthing like expected with the file writeing.
But it is strange that i only get each 200ms new Data from the BUS even the Cycle Time is 5ms and i have set the Buscycle Option to the Main Task.
Is there anything which i do not cover at the moment ?
Thanks for all your help.
09-22-2022 08:14 AM
Hi, please check cycle time of the Main Task or your PLC Task, by Default it's set to 200ms
12-20-2022 08:33 AM
Moved to own topic.