rslogix5000 counter.pre load

rigicon

Member
Join Date
Aug 2009
Location
kent
Posts
415
I want to load the counter.pre with a dint tag. Easy way is mov tag into counter.pre. lazy me. I have 16 counters all with name counter1 ....counter16. is there an easier way. the value comes from a PV. I have 4 sets of the above.
 
Try using an array of counters. You can then set them all with an FAL instruction.

FAL CounterSetControl 16 0 ALL Counters[CounterSetControl.POS].PRE Preset_From_PV
 
Last edited:
There are at present 16 processes that are identical in structure but independent of each other hence the need for the seperate counters. What the PanelView does is set a global value for all alarm counters. In other words if process 5 has 3 failures then stop the rest carries on. There are 4 sets of counters in each process or 64 global settings.

Alaric I like your idea and I think that is the only shorter way of doing it but there is existing code. How to set up an array etc. I think I'll just use 4 rungs with 16mov's in each rung. I have a bit that will write the values in so I'll jmp past the code if not needed.
 
Last edited:
Its perfectly OK to just use 16 MOVes.


I'm not sure if you are asking how to set up an array or just commenting on the need to do it. Just in case:
You set up an array in the new tag definition dialog box. Click on the elipses (...) button next to the DataType to open the "Select Data Type" dialog. In the Data type field type cou, the auto complete should complete the field as COUNTER. At the bottom of the window is an array dimensions field. Set DIM0 to 16 and click OK. You will be returned to the new tag dialog to finish naming and describing your array. Notice that in the Data Type field there data type now says COUNTER[16]. The brackets [ ] tell you its an array and the number between the brackets tell you how many elements are in the array. You can think of an array as being analogous to the files in SLCs, MLx, and PLC/5 processors, ie, T4, C5, N7 were essentially arrays.
 
This may or may not be of any use to you. Since I am not sure if you already have an array of counters or someone actually took the time to create "counter1" through "counter16", but anyway if you indirectly address the array you can get it done with one mov statement. If you need to move the value into all the counters during ONE program scan, just use a FOR loop.

I have attached a simple example.

TEST.jpg
 
Since I am not sure if you already have an array of counters or someone actually took the time to create "counter1" through "counter16"
Yes muggins here a while back and the machine is running now. Each counter was created. Wasn't sure about arrays. I like your for loop will it still work or do I have to make an array?
 
I can't think of any way to indirectly address individual counters. You would have to have an array for this to work. You could always create a counter array and make this work, but since the work is already done, enough said.
 
Yes muggins here a while back and the machine is running now. Each counter was created. Wasn't sure about arrays. I like your for loop will it still work or do I have to make an array?

Loops can be very useful, but they come with a bit of overhead. In this case, if you do convert to an array, a FAL will set them all at once.

As far as actual execution goes, if you've already programmed the 16 brute force MOVs then anything else you do is not going to be as optimized. Loops and FALs mainly save the programmer work and that train has already left.
 
Thanks guys. Next time I will definitely use arrays.
Learning the hard way seems to be my motto.
At least I am learning though.
 
It is better to use 16 MOV instructions. Just think about another poor guy who is going to look into your code in case of troubleshooting or future updates. It is easy to deal with simple code.
 
Just for the heck of it I made a new program and set up the Array Count. member=Countest ; Data Type COUNTER[10}
I have done a similar thing for a recipe the other week.

I then made a tag and yup the array came to life - soooooo easy and sweet. All that programming oh well thanks to PLCS.net I have learn't yet again thanks again everyone.
 
Last edited:

Similar Topics

Hi! So my problem is a little funky, I had Studio 5000 v 24 and 30 installed, but forgot to install RSLogix (which I cannot go without). Is there...
Replies
2
Views
112
So I had an odd request from a customer for the above. I have written the logic and tested it all in one PLC with only using 7 outputs and 7...
Replies
15
Views
427
Hello everyone, I have an RSLogix5000 project which is running live in the factory but I need to make some changes to the logic. I want to test...
Replies
0
Views
1,120
Good Morning Everyone, I'm looking to use the GSV instruction to get I/O fault codes for my project so I know if there's a comms issue in my E/IP...
Replies
5
Views
864
The machine is running production. When trying to go online with the laptop the whole machine looses communication and faults out. Drives, HMI...
Replies
13
Views
1,930
Back
Top Bottom