RSLogix 500 Array Help

jwalz2014

Member
Join Date
Jan 2012
Location
Michigan
Posts
7
Hello all,

I am trying to make an array so that each time a button on my touchscreen is pressed, my program records the date, time and a counter value of what I am recording into my micro 1100 PLC. I then want to be able to read the last 10 times that the button was pressed. I am using the FFL function (FIFO load) and writing the values of each that I am recording into seperate arrays. The issue I am running into is being able to display the last history of the values in order of the most recent history. Such as if I pushed the button today, todays history would be at the top of the list. All other history would be moved down one step.

My question is: is there any way to write a value to the beginning of an array and shift each array value over by 1, dropping off the right most value into the abyss?
 
This will sound a little backwards but it will help.

Let's say one of your arrays is N10:0 through N10:9

When a new value is recorded do this:

COP N10:1 N10:0 9 - this shifts the data in N10:0 - N10:9 up one position. The former value in N10:0 is gone.

MOV New Value into N10:9

So that N10:9 is the very last value, N10:8 is the next to the last etc.

Use this type logic for each of your arrays.
 
This is what I would do. Use an integer register (N7) as your array.
The counts will be in N7:0, N7:10, N7:20, N7:30,...etc.
The hour will be in N7:1, N7:11, N7:21, N7:31, ... etc.
The minutes will be in N7:2, N7:12, N7:22, N7:32,...etc.

When you look at the data table, the data will just be in the columns as you read across (count - hour - min - whatever).

B3:0 is the trigger (ie pushbutton on panelview).

Then create a new rung (in an offline program)and paste the following:

XIC B3:0/0 OSR B3:0/1 BST MOV N7:90 N7:100 NXB MOV N7:80 N7:90 NXB MOV N7:70 N7:80 NXB MOV N7:60 N7:70 NXB MOV N7:50 N7:60 NXB MOV N7:40 N7:50 NXB MOV N7:30 N7:40 NXB MOV N7:20 N7:30 NXB MOV N7:10 N7:20 NXB MOV N7:0 N7:10 NXB MOV C5:0.ACC N7:0 BND


XIC B3:0/0 OSR B3:0/2 BST MOV N7:91 N7:101 NXB MOV N7:81 N7:91 NXB MOV N7:71 N7:81 NXB MOV N7:61 N7:71 NXB MOV N7:51 N7:61 NXB MOV N7:41 N7:51 NXB MOV N7:31 N7:41 NXB MOV N7:21 N7:31 NXB MOV N7:11 N7:21 NXB MOV N7:1 N7:11 NXB MOV S:40 N7:1 BND

XIC B3:0/0 OSR B3:0/3 BST MOV N7:92 N7:102 NXB MOV N7:82 N7:92 NXB MOV N7:72 N7:82 NXB MOV N7:62 N7:72 NXB MOV N7:52 N7:62 NXB MOV N7:42 N7:52 NXB MOV N7:32 N7:42 NXB MOV N7:22 N7:32 NXB MOV N7:12 N7:22 NXB MOV N7:2 N7:12 NXB MOV S:41 N7:2 BND


I didn't finish the rest, but you should get the idea. It is not as slick as a FIFO load, but this is a very easy to understand set of rungs.
 
You can also do this using a temporary file. Either find or create a file of the same size as the one which holds your data. Let's use N7 and N8 for the example. To enter a new value, COP N7:0 N8:0 9 (number of values to move), then COP N8:0 N7:1 9. Finally, move the new value into N7:0. What you've effectively done is move each value in N7 to N7+1. The data moves 'down' in the file. The value at the end of the file is overwritten with the value in the next lower address.
 
You can also do this using a temporary file. Either find or create a file of the same size as the one which holds your data. Let's use N7 and N8 for the example. To enter a new value, COP N7:0 N8:0 9 (number of values to move), then COP N8:0 N7:1 9. Finally, move the new value into N7:0. What you've effectively done is move each value in N7 to N7+1. The data moves 'down' in the file. The value at the end of the file is overwritten with the value in the next lower address.

Bernie posted a much more efficient (i.e. memory usage and execution time) method which achieves the same
 
Hello all,

I am trying to make an array so that each time a button on my touchscreen is pressed, my program records the date, time and a counter value of what I am recording into my micro 1100 PLC. I then want to be able to read the last 10 times that the button was pressed. I am using the FFL function (FIFO load) and writing the values of each that I am recording into seperate arrays. The issue I am running into is being able to display the last history of the values in order of the most recent history. Such as if I pushed the button today, todays history would be at the top of the list. All other history would be moved down one step.

My question is: is there any way to write a value to the beginning of an array and shift each array value over by 1, dropping off the right most value into the abyss?

Hi and welcome to the forum!

I recently had a similar adventure with building an array and a display table on a PV+ for tracking setpoint change histories. That adventure is documented on this thread. See the zipped file attached to the last post, it is a version of the program that I ended up using that was developed for a ML1100 processor that I was running on the RSEmulator to debug the logic at home.

Ladders 4 and 5 are the ones to pay attention to. I prefer the indirect addressing method used there to using FIFO instructions, because it is more flexible, and doesn't monopolize the processor's index register (S:24).
The data table N9 can either show the time/date data for the ten most recent events in the queues (which can hold up to 255 events), or an operator can "navigate" back through the data back to the beginning of the queue.

I think the template here can be modified to fit your application pretty easy. I never took the time to add rung comments to this "template" program, as it was only for personal use, so if you have any questions about it, don't hesitate to ask. I would disregard Ladder 6, as it was only there to simulate PLC system time, which the Emulator I was using didn't support.

Hope this helps.

Cheers,
Dustin

🍻
 
+1 on Bernie's suggestion. Turn your arrays upside down so the newest data is at the end of the array. On your touch screen display you can still order the newest data first by reversing the order of your display tags.
 
Hey thanks everyone. Bernie, I took you idea and modified it a touch. I did COP N10:0 N10:1 9. This shifted everything to the right by one. Then I moved my new value into N10:0. That way I didn't have to make everything backward compatible with your method. Thanks for the suggestions on this.

Thanks everyone else as well.
 
:8
Hey thanks everyone. Bernie, I took you idea and modified it a touch. I did COP N10:0 N10:1 9. This shifted everything to the right by one. Then I moved my new value into N10:0. That way I didn't have to make everything backward compatible with your method. Thanks for the suggestions on this.

Thanks everyone else as well.

Have you tested your method? COPying in the "upward" direction will put the value in N10:0 into ALL the registers, rather than shifting the data. That is because the PLC executes the COP instruction in this order:

N10:0 » N10:1
N10:1 » N10:2
N10:2 » N10:3
...
N10:8 » n10:9

Once you COP N10:0 to N10:1, you can see that that value will be COPied all down the line.
 
You need to understand that COP copies one word at a time beginning at the source address to the destination address. It then repeats copying source address + 1 to the destination address +1, and so forth until all words are copied. Like all computer instructions it is absolutely literal, it has no magical abilities.

Lets say that

N10:0 = 10
N10:1 = 20
N10:2 = 30
N10:3 = 40
N10:4 = 50


Now lets step through COP #N10:0 #N10:1 4
The 10 in N10:0 gets copied to N10:1.
The 10 in N10:1 gets copied to N10:2.
The 10 in N10:2 gets copied to N10:3.
The 10 in N10:3 gets copied to N10:4.


You array is now filled with the value 10 and
N10:0 = 10
N10:1 = 10
N10:2 = 10
N10:3 = 10
N10:4 = 10


Now lets step through COP #N10:1 #N10:0 4
The 20 in N10:1 gets copied to N10:0.
The 30 in N10:2 gets copied to N10:1.
The 40 in N10:3 gets copied to N10:2.
The 50 in N10:4 gets copied to N10:3.

You array now looks like
N10:0 = 20
N10:1 = 30
N10:2 = 40
N10:3 = 50
N10:4 = 50



edit:
If you just can't wrap your mind around turning the array upside down then its a simple matter to program individual MOV statements - you've spent more time on the problem than programming 9 MOVes would take and the code is almost as efficient.
MOV N10:9 N10:10
MOV N10:8 N10:9
MOV N10:7 N10:8
MOV N10:6 N10:7
.
.
MOV N10:0 N10:1
MOV C5:0.ACC N10:0
 
Last edited:
This issue comes up so often.

Why doesn't Rockwell just fix the COP routine so if can copy either up or down one item. It would take little time compare to all the hours people waste on forums and trying to work around the limitations of COP.

The C and C++ equivalent has been fixed or decades.
 
Yep, your all correct. Went to try it this morning, and worked just like TConnolly wrote.

I used Bernie's copy format and had to move around the displays on my screens and some of the programming, but low and behold, all has worked perfectly.

Maybe one day Rockwell will look at this forum...
 
Hello, I was wondering how your program records the date and time of when the button is pressed? I know this is very late but I'm using the emulate version of 500 and can't figure out how to record data with timestamps. I can't use the data logging tool since I'm running the emulator. Thank you!
 
ben,
I'm not 100% sure how these folks did it (I didn't read the entire thread) but I've seen it done and have done it myself.

The way I do it is to use one integer as the key...say N17. All the integers in N17 are part of the key. Meanwhile all the integers in N18 are hours. All the integers in N19 are minutes. Another variable is stored in N20. Use SQC to find the key value and then copy the position into an integer...say N7:0. Use N7:0 as the index value to get info out of (or into) N17, N18, N19, N20, etc. I've seen this done to select recipe settings ( and used it that way myself). I've used it as a crude datalogger detecting when somebody switches a piece of equipment into manual mode so they can go walk the dog. "I don't know what happened the basket just never can out....I don't know why they got melted."
 
Last edited:

Similar Topics

Hello, I'm using a counter as a timer to get a time value to get the current cycle time and last cycle time. I need to put this "last cycle...
Replies
3
Views
2,782
Hi Everyone, I am not proficient in RSLogix 500 so I have a question regarding the evaluation of N7:0 data as an input. So as I understand in...
Replies
1
Views
79
I have a little bit of experience with Allen-Bradley. I have a Micrologix 1500 (RSLogix 500) and a PanelView Plus 7 (FactoryTalk View Studio ME)...
Replies
3
Views
159
buen dia. tengo una falla al pasar los tags de mi plc SLC 5 0/4 a mi panel me aparece un error Problem writing value " " to item <tag name>...
Replies
1
Views
81
Will someone please convert this logic to pdf?
Replies
2
Views
127
Back
Top Bottom