1 choose the right language to implement the code, Structered Text is imho the most suited. FBD or CFC could also be used, but that is a matter of taste. In your case something visual like FBD or CFC is probably advised since you say you are a beginner and do not provide any previous programming experience.
2 write an code (FB) that can open, close, read and write files from disk.
If you need examples, try to google for it or ask your OEM supplier for examples
3 read a file into memory and organise it using an array.
good luck
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm currently solving it using Ladder, but I can also try it in FBD. I transferred the file (which contains 15 numbers) into the PLC memory using FTP, used a function to open the file and read it. Right now i'm struggling to move the numbers from the file to an array.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you can read the file, moving data to an array shouldn't be an issue.
1) What does your data on disk look like?
2) Build a struct element which can hold this re-occuring data
3) Read from 1 to N elements data into array of struct element[N]
Last edit: hermsen 2021-08-06
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I just started learning how to program PLCs and I've been struggling with reading data from a file into an array.
short primer: on how to tackle this.
1 choose the right language to implement the code, Structered Text is imho the most suited. FBD or CFC could also be used, but that is a matter of taste. In your case something visual like FBD or CFC is probably advised since you say you are a beginner and do not provide any previous programming experience.
2 write an code (FB) that can open, close, read and write files from disk.
If you need examples, try to google for it or ask your OEM supplier for examples
3 read a file into memory and organise it using an array.
good luck
I'm currently solving it using Ladder, but I can also try it in FBD. I transferred the file (which contains 15 numbers) into the PLC memory using FTP, used a function to open the file and read it. Right now i'm struggling to move the numbers from the file to an array.
Last edit: bogdaniovu 2021-08-06
If you can read the file, moving data to an array shouldn't be an issue.
1) What does your data on disk look like?
2) Build a struct element which can hold this re-occuring data
3) Read from 1 to N elements data into array of struct element[N]
Last edit: hermsen 2021-08-06
can you please be so kind and help me with the diagram or code, for the past 5 days i've been searching for a solution
Then you should at least post your code as .pro
Last edit: hermsen 2021-08-08
Sorry for the late reply.
Last edit: bogdaniovu 2021-08-09