Shifting of Arrays For Login History

jrsnydley

Member
Join Date
Dec 2014
Location
Minnesota
Posts
155
Hello everyone, I am working on trying to record a history of user logins with a time stamp. It will record their user ID and the time that they logged in on a PanelView Plus 7 1200.

I am programming the PLC (1756-L82ES) in Studio 5000 (v32) and trying to use the FAL instruction to shift a couple of arrays. One is an array of STRINGS containing the user ID and the other is an array of a Date and Time UDT which is a 7-DINT array to capture the time stamp.

I quickly discovered that the FAL expression and destination tags cannot be of the datatype STRING or a UDT. I thought maybe using STOD and vice versa to sort out the user ID but I think I would have to do that for each element in the array. I am not sure how I would do the timestamp other than maybe having a separate array for each element such as Year[50], Month[50]...etc.

Does anyone know an easy way to accomplish what I am trying to do?
 
How exactly are you trying to 'shift' the arrays? Are you just trying to push the data down (or up) one element at each new login (eg first login goes in [0], next login pushes old data down to [1] and itself goes in [0] etc)?

If so, see Ron's posts #3 and #4 in this thread for how the COP instruction can do it.
 
My arrays are 50 elements. In the FAL instruction, I was using Array[0] as the expression, Array[1] as the destination, and 49 as the length. Then I had a COP instruction after that with a tag containing the current STRING that was being copied to Array[0].

I will check out the link.
 
My arrays are 50 elements. In the FAL instruction, I was using Array[0] as the expression, Array[1] as the destination, and 49 as the length.


where was .POS used?


I think it should be Array[49-.POS] as the destination, and Array[48-.POS] as the expression, and 'All' as Mode.
 
There is a trick to FFL and FFU.
Have FFU above FFL trigger by the same rang, and very important, make your initial Control.POS = the last position. For example, if you have 10 array, set the initial pos to 10(just type in the constant).
You last array will be your current input data, the history data will shift upward. Array[0] will be your oldest history, Array[9] will be your latest(current input value). FFU to a temp tag, the same data type.
I've try strings and DINT, they all work well.
Very simple logic.
 
Last edited:
How exactly are you trying to 'shift' the arrays? Are you just trying to push the data down (or up) one element at each new login (eg first login goes in [0], next login pushes old data down to [1] and itself goes in [0] etc)?

If so, see Ron's posts #3 and #4 in this thread for how the COP instruction can do it.

I read the thread, they are way too complicated.
FFU + FFL is very easy to shift arrays.
You can try it.
 
I read the thread, they are way too complicated.
FFU + FFL is very easy to shift arrays.
You can try it.

A single COP and MOV is 'way too complicated'?!? Two COP if shifting the other direction? These are dead simple instructions.
 
There is a trick to FFL and FFU.
Have FFU above FFL trigger by the same rang, and very important, make your initial Control.POS = the last position. For example, if you have 10 array, set the initial pos to 10(just type in the constant).
You last array will be your current input data, the history data will shift upward. Array[0] will be your oldest history, Array[9] will be your latest(current input value). FFU to a temp tag, the same data type.
I've try strings and DINT, they all work well.
Very simple logic.
It can also do 2 dimension arrays, as long as you have the same data type.
For you case create a data type and then create a temp tag with the new data type, then store all the information from the source array. The create a array using the new data type to store as many history as your system can handle. FFU and FFL will fill up the new data type array upward. The last array is the latest history, array[0] will be the oldest history.
I have tried it will 2 dimension string arrays, it works fine.
 
This subroutine uses the DTOS & CONCAT instructions to build a timestamp

01/14/2013 08:35:57

Just unzip and import into program to create subroutine.

use the STR_TimeStamp[0] tag for logging or display.


If you want to store an array of values. Make a UDT of all values needed. Use the Copy Instruction. If you need to save 50 values then Make your array a length of 51. Copy your info into Array[50]. Then Copy Array[1] into Array[0] for a length of 50. This will shift your data. It basically copies values 1-50 and paste those values in 0-49. Your most recent data will be in 49 and you oldest data will be in 0. This way your oldest to newest data is always in the same order. Even if you could use a FAL it would rollover once you reach the length set then start overwriting at 0. So now your oldest and newest data is mixed once rollover occurs. Just one more note make sure you one shot your copy instructions to only move 1 step at a time.
 
A single COP and MOV is 'way too complicated'?!? Two COP if shifting the other direction? These are dead simple instructions.
Only COP and MOV wont work, You will need one-shot. I've tried it, will will populate it every cycle instantly filled all array with one value.
It is the same idea, anyway. FFL and FFU is real shifting array, it does not need one-shot. FFL + FFU also need to make sure initial position values is the last array. I would think AB has a reason to build FFL, even though COP and MOV can do the same thing.
I just saw his question about Shifting array, and he could not do it. I just tried FFL and FFU to do real shifting, and it works.
Anyway
There is always many solutions to the same issue. COP and MOV is not bad.
 
LOL, It took me awhile to figure out FFL + FFU; I just googled it, some other people are using the same method. LOL, I should have google it first.
 
Only COP and MOV wont work, You will need one-shot. I've tried it, will will populate it every cycle instantly filled all array with one value.
And an unconditional FFL/FFU will work? It's up to the user to correctly set the conditions to trigger the COP/MOV, same as it would be with your suggested FFL/FFU. A separate oneshot may or may not be required depending on how the login process is being handled.

Either method will certainly work, but FFL/FFU will require more memory than the equivalent COP method due to needing a control tag, and will take significantly longer to execute.

ofc memory is cheap and we're talking microseconds difference, so neither is likely a real concern.
 

Similar Topics

Greetings, I am trying shift data in an array (such as Array[0] is shifted into Array[1], Array[1] is shifted into Array[2]......all...
Replies
10
Views
365
Hello Guys, I think I need to use SCL for the following task but am very weak using SCL in tia portal. I have results history data block. It is...
Replies
14
Views
3,053
Why encremental encoder have a phase shift of 90°between A,B phases ,if it's 60° 30° what happen what's the difference ,can we change the 90°in...
Replies
47
Views
10,916
Hey guys, What do you suggest for doing a shift of dints within an array like this? Thanks, Kevin
Replies
12
Views
2,591
Hardware PLC: Mitsubishi Q06UDV Servo Module: Mitsubishi QD77MS2 Servo Amplifier: Mitsubishi MR-JE Series Amplifier Customer has restarted...
Replies
4
Views
3,033
Back
Top Bottom