Announcement

Collapse
No announcement yet.

data retrieval from multiple arrays

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Originally posted by franji1 View Post
    FILELOG cannot handle a row containing 256 elements. You will have to do your own file logging using FILEOPEN, multiple FILEWRITEs, FILECLOSE.

    A STAGE Program that you RUN 27 times, setting SS0 to the desired file name, and copying the 256 data values for a specific block to a common buffer, doing the RUN, when done, copy the next set of 256 data values into the common buffer, then doing the RUN again (with the same file name), again, and again.

    So I see a HIGH LEVEL STAGE program sequencing the 27 blocks by RUNNING a FILE LEVEL STAGE program 27 times that writes/appends the current block to the file.

    So the high level PROGRAM basically "RUNs" the low level PROGRAM 27 times, once for each buffer
    Is there a programming example that shows a version of this concept anywhere? While I understand the concepts, I have to admit I have no idea how to do that.

    Do I use a FOR Loop to do this?

    What is the "common buffer" you refer to above?

    How/where do I control how the data is written to the file? Can each block be placed in its own column in the .csv file? Would this create (27) separate files, or one file?

    Sorry for the million questions. The lack of how-to documentation and examples is making this very difficult to get started.



    Thanks,

    Ryan Poethke

    Comment


    • #17
      This is very specific to your application.

      This is a PLC, so FOR/NEXT loops with FILE I/O will not work as you would expect as in a BASIC program (gotta let the PLC scan breathe).

      I am assuming
      1. you want 1 file per data set
      2. You create a specific (time-stamped) file with all 27 sets of 256 values
      3. When you restore, you pick ONE of these files and it restores all 27 sets of 256 values

      So, do you want 27 lines of 256 values, or 256 lines of 27 values? I assumed the first, but I want to know for sure what you want. What does the user of this file expect? We can write the code in the PLC either way. How will the user of this file view the data? Excel? Database? Notepad?
      There are 10 kinds of people in this world, those who know binary, and those who do not.

      Comment


      • #18
        Originally posted by franji1 View Post
        This is very specific to your application.

        This is a PLC, so FOR/NEXT loops with FILE I/O will not work as you would expect as in a BASIC program (gotta let the PLC scan breathe).

        I am assuming
        1. you want 1 file per data set
        2. You create a specific (time-stamped) file with all 27 sets of 256 values
        3. When you restore, you pick ONE of these files and it restores all 27 sets of 256 values

        So, do you want 27 lines of 256 values, or 256 lines of 27 values? I assumed the first, but I want to know for sure what you want. What does the user of this file expect? We can write the code in the PLC either way. How will the user of this file view the data? Excel? Database? Notepad?
        Ideally, one file per data set.

        Time stamped - I have figured out how to create a string in SS0 that creates " "Cues" SDT0.Day SDT0.Month SDT0.Year"," SDT0.Hour"H" SDT0.Minute"M" SDT0.Second "S" " for the file name. If I use this string for the file name, it should create a current-to-the-second date stamp, yes?

        Yes, I'd like to restore by picking ONE of these files and it will restore 27 sets of 256 values all at once. The operator could restore a "snapshot" of the data - they don't get to pick and choose what positions to restore.

        27 columns of 256 values would be ideal. I've attached a screen grab of an excel file I mocked up with what I'd like to see. Most of the time, the operator would simply use the backed up, date-stamped file to restore from the SD card. .csv would be helpful if anyone ever decided they wanted the data in Excel.

        Click image for larger version

Name:	sample record file.png
Views:	109
Size:	17.9 KB
ID:	124595

        I appreciate all your help with this. I feel all thumbs with attempting to get this to work.



        Thanks,

        Ryan Poethke
        Attached Files

        Comment


        • #19
          Since my assumption was incorrect, then we CAN use the FILELOG instruction. That does simplify things one way, but adds a little complexity in another (but not bad).

          FILELOG can handle 27 items in 1 row (actually, 28 since the first column will be the Cue Number)

          So a new PROGRAM called LogData that uses array indexing to log 256 rows of 27 data points (plus the array index, aka CueNum)
          In Stage S0, it sets CueNum (say V100) equal to 0, then JMP to S1 to do the 0th row, JMPs to S2 to increment V100 (or exit once we reach 256), then JMPs back to S1

          SG S0
          RST ErrorBit (say C100?)
          MOVE 0 CueNum (V100)
          JMP S1

          SG S1
          FILELOG
          CueNum
          LxOne[CueNum] // create a nickname for LxOne[CueNum] called Lx_One, then the header for this column in the CSV file will be the nickname "Lx_One", not "BlkA[CueNum]"
          LxTwo[CueNum] // NN for LxTwo[CueNum] is "Lx_Two"
          LxThree[CueNum] // NN for LxThree[CueNum] is "Lx_Three"
          . . .
          LxTwentySeven[CueNum] // NN for LxTwentySeven[CueNum] is "Lx_TwentySeven"
          OnSuccess JMP S2, OnError JMP S99

          SG S2
          INC CueNum

          CueNum < 256
          JMP S1

          CueNum >= 256
          EXIT

          SG S99
          SET ErrorBit
          EXIT

          So in $Main (or the the "calling" code block), generate the file name in SS0, then RUN this LogData PROGRAM. When LogData.Done is ON, then it has EXITed, then check the ErrorBit to see if it failed.

          The nicknames are helpful so the CSV file will utilize the NICKNAME in the header line, not the ELEMENT name. I guess you don't have to do that, it might be good to have the header be "LxOne[CueNum]" ?
          Last edited by franji1; 08-09-2019, 03:22 PM.
          There are 10 kinds of people in this world, those who know binary, and those who do not.

          Comment


          • #20
            Originally posted by franji1 View Post
            Since my assumption was incorrect, then we CAN use the FILELOG instruction. That does simplify things one way, but adds a little complexity in another (but not bad).

            FILELOG can handle 27 items in 1 row (actually, 28 since the first column will be the Cue Number)

            So a new PROGRAM called LogData that uses array indexing to log 256 rows of 27 data points (plus the array index, aka CueNum)
            In Stage S0, it sets CueNum (say V100) equal to 0, then JMP to S1 to do the 0th row, JMPs to S2 to increment V100 (or exit once we reach 256), then JMPs back to S1

            SG S0
            RST ErrorBit (say C100?)
            MOVE 0 CueNum (V100)
            JMP S1

            SG S1
            FILELOG
            CueNum
            LxOne[CueNum] // create a nickname for LxOne[CueNum] called Lx_One, then the header for this column in the CSV file will be the nickname "Lx_One", not "BlkA[CueNum]"
            LxTwo[CueNum] // NN for LxTwo[CueNum] is "Lx_Two"
            LxThree[CueNum] // NN for LxThree[CueNum] is "Lx_Three"
            . . .
            LxTwentySeven[CueNum] // NN for LxTwentySeven[CueNum] is "Lx_TwentySeven"
            OnSuccess JMP S2, OnError JMP S99

            SG S2
            INC CueNum

            CueNum < 256
            JMP S1

            CueNum >= 256
            EXIT

            SG S99
            SET ErrorBit
            EXIT

            So in $Main (or the the "calling" code block), generate the file name in SS0, then RUN this LogData PROGRAM. When LogData.Done is ON, then it has EXITed, then check the ErrorBit to see if it failed.

            The nicknames are helpful so the CSV file will utilize the NICKNAME in the header line, not the ELEMENT name. I guess you don't have to do that, it might be good to have the header be "LxOne[CueNum]" ?
            franji1,
            You're the best! I'll try that on Monday morning. Thank you for all your help!


            Ryan Poethke

            Comment


            • #21
              Doh! For the nicknames, use the desired names, i.e. "Lx1" "Lx2" . . . "Lx27". Nicknames CAN contain alpha-numeric and underscores. The header line of output file of your FILELOG will utilize the nicknames, so Excel will look perfect!
              There are 10 kinds of people in this world, those who know binary, and those who do not.

              Comment

              Working...
              X