Question on AB PLC

If you are doing too much in the loop or looping too many times, you can trigger a watchdog or overlap. If you can 't spare a small chunk of scan time in this routine, then you are right, otherwise, there may have been an error in your loop construct...I have a L23E doing two conditional loops that repeat up to 120 times each, and they often happen during the same scan without much of a blip on scan time.

I'm not sure why also. There is only 2 consecutive rungs looping, like


-----<LBL>------------ A + 1 ------------


-------------------- A < 128 ----- JMP---------
|
|
------A >= 128 ----- A = 0------

And it only loop like max ~128 times..


You should at least advise them that their requirement is an impediment and a superior method exists. (Explain addressing bits within DINT arrays as being everything and more than B3:[x].)

Actually, they have valid reasons too..

Bcoz their specification is up to 128 states. Using the Boolean array is more "readable" and easier to maintain.. If using DINT, it would be 4 DINT elements and the current state bit display in the rung would not be so "intuitive"..
 
Last edited:
Let me ask you a question: What is so hard about adding an instruction to write the state number in series with the state coil? Even if you have 128 them it should take less than half an hour to paste them in unless the logic is scattered all over the place. And its easy for anyone who looks at the program latter to understand.

The actual act is not difficult, but a bit troublesome. It's not just cut and paste, but also to make sure the correct state number is keyed in at every rung.

Also, it is not so easy to ensure that all the state numbers are correctly entered, as every rung has the instruction and the value is different for every rung. If a particular entry is wrong it is not so easy to discover also as only that "particular" state is reported wrongly.

For the COP boolean array to DINT method, if there is a bug in the code, it occurs at only 1 place and almost all the states will be reported wrongly and easy to "discover" the bug.

However, the COP boolean array to DINT method does have some shortcomings.. I guess.. which I'll elaborate in the next post.
 
Ohh got caught again
Thanks for reminding me why I NEVER use BOOL[n] as a Tag Type

Only way around it that I know is to use UDT's as follows

MyBool_UDT
BitArrray BOOL[128]

MyDINT_UDT
Dint_Array DINT[4]

Both are the same size so you can COP from one to another

One question.. other then DINT, is there any unsigned long integer data type in AB controllers that can be used?

Wonder if this method will have a problem at state 31, 63, 95, 127 etc.. when the 31st bit in the DINT is turned on.

I guess in Ab controllers, "1000000000000000000000000000000" is = -1?

Any elegant work around methods? other then addition code to arrest this specific situation..

Thanks.
 
The value is twos complement binary. In the PLC, it will be treated as signed, but there is no reason you can't display it as unsigned on your HMI, etc...not sure why you would need to work with the whole DINT, other than to CLR it at each state transition.

It should not matter what the value of the DINT is anyway since they are really a collection of mutually exclusive bits, you should not be looking for equality or doing math on the individual DINT(s), just XIC and XIO the appropriate bits.

Perhaps I misunderstood the question.

Paul
 
Perhaps I misunderstood the question.

Paul

Hi Paul, thanks for the reply.

Actually, I wanted to display the state in numeric display, like current state is "50", "51" etc.. for easy readability on HMI.

Hence, I need to map the boolean bits to a DINT first, then, taking log to base 2, directly convert it to a number.

At such, whether the value is interpreted as "2147483648" or "-1" makes a big difference to the calculated value.

That is the basis of my concern/question..
 
Last edited:
Depending on the HMI, you should be able to display the state based on LSB, or by value with the decimal equivalent of each state used as the value indicator tag:

1="state 1 text"
2="state 2 text"
4="state 3 text"
8="state 4 text"
and so on.

Since you have four dints that represent 128 states, doing the bit hack method or other method to get the integer value you want will be simpler.
 
Last edited:

Similar Topics

HI i would like to know how to get a variable that will store the amount of times a program has been executed. The issue is I have 3 DBs for 1 FB...
Replies
2
Views
99
I've ready through the the previous posts, and we've worked with safety design for a long time. In the past, we worked with Pilz directly, and...
Replies
9
Views
606
Everyone, i am in the process of purchasing the Slc 500 version of software to support what we have and i have a question. Several of our...
Replies
9
Views
788
I know this can be done, but I can't get the router config right. My goal is to physically connect(using an ethernet cable) a device(PLC, RTU...
Replies
9
Views
1,040
Hello. Was just curious, if it is possible to load an image from an SD card on to a Compactlogix PLC that came straight out of the box brand new...
Replies
4
Views
558
Back
Top Bottom