News:

  • June 08, 2026, 12:57:21 PM

Login with username, password and session length

Author Topic: "High Speed" Data Logging  (Read 9187 times)

RBPLC

  • Hero Member
  • *****
  • Posts: 586
"High Speed" Data Logging
« on: June 02, 2021, 05:22:36 PM »
I have an application where I'm trying to log 12 real values at 100ms sample rate. In general, I need to log for about one hour once logging begins. I set up a FILELOG instruction with edge triggering and am using a FLASHER at 50ms for the edge trigger. I'm using the tickms() to get a relative timestamp when logging starts for each of the log entries. I noticed today that for a while (until about 10 minutes into logging) the samples were at approximately 100ms (within a few ms of 100ms, which is fine for this application). After this time, it looks like the sample rate jumped to about 200ms. My question is this: what is the optimal way to do "high speed" data logging. I assume the FILELOG instruction is not the preferred method and that the FILEWRITE is preferred. Assuming that the FILEWRITE is the preferred method, is there any issue with leaving the file open for "long" periods of time while being written to. I assume the logic flow would be FILEOPEN, write parameters for an hour and then FILECLOSE. Is this the preferred method? 

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6158
  • Yes Pinky, Do-more will control the world!
Re: "High Speed" Data Logging
« Reply #1 on: June 02, 2021, 09:46:59 PM »
I have an application where I'm trying to log 12 real values at 100ms sample rate. In general, I need to log for about one hour once logging begins. I set up a FILELOG instruction with edge triggering and am using a FLASHER at 50ms for the edge trigger. I'm using the tickms() to get a relative timestamp when logging starts for each of the log entries. I noticed today that for a while (until about 10 minutes into logging) the samples were at approximately 100ms (within a few ms of 100ms, which is fine for this application). After this time, it looks like the sample rate jumped to about 200ms. My question is this: what is the optimal way to do "high speed" data logging. I assume the FILELOG instruction is not the preferred method and that the FILEWRITE is preferred. Assuming that the FILEWRITE is the preferred method, is there any issue with leaving the file open for "long" periods of time while being written to. I assume the logic flow would be FILEOPEN, write parameters for an hour and then FILECLOSE. Is this the preferred method?

The SDCard has a limited access rate. You could log to the RAM disk, then copy the file to the SDCard.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

RBPLC

  • Hero Member
  • *****
  • Posts: 586
Re: "High Speed" Data Logging
« Reply #2 on: June 03, 2021, 07:02:30 AM »
Is there a performance difference between the FILELOG vs. FILEOPEN/FILEWRITE approach or is the SD card the limiting factor regardless of the instruction? Also, the files are > 1MB so I'd have to split the files if writing to RAM and do intermediate copies over to SD.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3827
    • Host Engineering
Re: "High Speed" Data Logging
« Reply #3 on: June 03, 2021, 08:20:02 AM »
Flash is extremely slow compared to RAM.  FILELOG is faster than doing the steps manually since it does everything internally.  The other instructions have to be synchronized with the PLC scan.

Try the RAM drive idea first and let us know if that is sufficient.

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: "High Speed" Data Logging
« Reply #4 on: June 03, 2021, 01:50:41 PM »
One other method is a circular queue in memory, depending on how much memory you have available. Use 2 pointers, one to store the time stamp and data. Another to read the data and log it.  When the 2 are equal all data is logged.