Hello All,
I am trying to do something quite simple but not use to some of Twincat's instructions/syntax.
I am programming in Structured Text and want to fill an array with say raw vibration data and then calculate the RMS over 200 samples of that data.
I have created an array:-
******************************************
VAR
raw_vib_data:real; (* Raw vibration Data *)
vib_array: ARRAY[1..200] OF REAL; (* Array to hold 200 samples of raw vibration data *)
END_VAR
in the program file:-
vib_array[1]:=raw_vib_data; (* At this point in time copy the current raw data into the 1st field of the array *)
****************************************
Now say the program is called 10 ms, I want to shift all the array data up 1(i.e content of 3 go into 4,2 go into 3, 1 go into 2 etc, so on the next scan I can fill data cell 1 up again etc.
I have done this with ease in the past when using Rockwell control logix FFL/FFU FIFO Load/unload instructions but Twincat doesn't have this. I have noticed there is a rotate left/right that I thought may allow me to rotate the array data but this is a bit rotate and cant be used with an array of REALS.
I know how to do the rest of it I just cant get the load/unload of the array working.
Any help appreciated.
Thanks Matt
I am trying to do something quite simple but not use to some of Twincat's instructions/syntax.
I am programming in Structured Text and want to fill an array with say raw vibration data and then calculate the RMS over 200 samples of that data.
I have created an array:-
******************************************
VAR
raw_vib_data:real; (* Raw vibration Data *)
vib_array: ARRAY[1..200] OF REAL; (* Array to hold 200 samples of raw vibration data *)
END_VAR
in the program file:-
vib_array[1]:=raw_vib_data; (* At this point in time copy the current raw data into the 1st field of the array *)
****************************************
Now say the program is called 10 ms, I want to shift all the array data up 1(i.e content of 3 go into 4,2 go into 3, 1 go into 2 etc, so on the next scan I can fill data cell 1 up again etc.
I have done this with ease in the past when using Rockwell control logix FFL/FFU FIFO Load/unload instructions but Twincat doesn't have this. I have noticed there is a rotate left/right that I thought may allow me to rotate the array data but this is a bit rotate and cant be used with an array of REALS.
I know how to do the rest of it I just cant get the load/unload of the array working.
Any help appreciated.
Thanks Matt
Last edited: