We can now control the motor and read whether it has reached the zero position. But we don't want to move the mirror ourselves all day. Ideally, there should be a program which can be loaded, to which the mirror angles will be adjusted.
I've chosen that this program can be set by the user using a file in the Comma Separated Value (CSV) format. This is a super easy spreadsheet format and is recognised by all spreadsheet programs.
The spreadsheet saved as a regular text file, so you can see its contents in Notepad, and is formatted as follows:
The first column is the time stamp, the second column the required pillar a position, and the third column the required pillar b position. All data is separated by a comma, that is why it's called CSV.
To load this into Labview, I've created another subroutine "read program".
There are some things going on which take it beyond the "beginner" stage, but it's not too hard to understand.
On the far left, the path to the program.csv file is built by using the application path and tacking on "program.csv". The file is then loaded by "read delimited spreadsheet". The header data is removed from all the data by selecting everything from row 1 onwards (row 0 is the header data). From there on, columns 0, 1, and 2 are selected separately to process the time, pillar a position, and pillar b positions.
Labview then still thinks a 1 column array should be presented as a 2D array, so it's reshaped into a 1D array.
The time string array cannot be used directly to compare time, it first needs to be formatted into a time stamp. This is a bit more tricky, and involves parsing the time string (in 24H format), to get hours, minutes, and seconds, and updating those fields in a time stamp, so that the current date (day/month/year) is also correct. It may not make a lot of sense, you'll just have to play around with it to see.
Then the time stamps are in the correct time stamp format.
The pillar a and b positions need to be converted from strings to decimals.
This subroutine then exports three arrays: the time stamp array, the pillar a position array, and the pillar b position array.
Finally, the data is formatted in a cluster. This is a data format similar to a structure or object; instead of having 3 arrays with timestamp, pillarApos and pillarBpos, there is one array/list/structure/cluster in which each entry has one time stamp and the corresponding pillarApos and pillarBpos. Sometimes this makes it easier to process data and not accidentally select the wrong position for the correct time. The cluster also has a datapoint "done", which is not loaded from the program.csv but used in the main program to keep track of which data points have already been processed.
The cluster information will then be used in the main loop to check if the mirror angles are in the correct position: in a continuous loop it checks the actual time, in which position the mirror should be in, based on the program.csv, and in what position the mirror is now.
More about that later.