Could you help explain a Compare with Expression and Modulo

Coachman

Member
Join Date
Sep 2006
Location
Maryland
Posts
97
I understand this instruction a little bit , but could someone
explain it a little more. It is a compare instruction in a AB
ControlLogix. I will explain a little ,with some questions.
_______________________________________
CMP
Compare
Expression (PROD_COUNTER+1)MOD 5<>0)
_______________________________________

I have a turning device that turns 20 parts and indexs them, they
have gaps between the parts. This turning device is counting these parts ,that is the Prod_Counter. Mod means Modulo right?
and that is the remainder right? Is MOD an actual tag? In some
rungs I have an = instead of <>. This may help, I have 4 groups
of 5 parts in each group. Can you just give me a summary of what
you think is going on here. I may be able to put the rest together.

Thanks in advance,
 
MOD is the Modulus function, which returns the remainder after in integer divide.

In the case above, the compare is true for 4 out of 5 parts. Every 5th part, the modulus will be 0, and the expression will evaluate false.
 
first of all, your expression doesn’t look quite right ... doublecheck it ...



I’m GUESSING that this is what you meant to type:



(PROD_COUNTER.ACC + 1)MOD 5 <> 0


basically that means:


take the value from the counter’s accumulator ...

add 1 to it ...

now divide the sum by 5 ...

if there is a remainder, then the CMP will be TRUE ...

if I’m guessing correctly about your expression, then you should have a TRUE condition for the CMP whenever the counter’s accumulator is equal to ANY of the values:

0, 1, 2, 3,
5, 6, 7, 8,
10, 11, 12, 13,
15, 16, 17, 18,
20, and so on ...




you should have a FALSE condition for the CMP whenever the counter’s accumulator is equal to ANY of the values:

4, 9, 14, 19,
and so on ...




if my guess isn’t right, then post again - and watch your typing ...

PS Edit ...

and no, MOD is not a "tag" ... try typing in different numbers into TEST_VALUE and see what comes up for REMAINDER in this little experiment ...

MOD.JPG
 
Last edited:
In the ControlLogix program a name (PROD_COUNTER) can be an 'alias' pointing to another value. It is possible that the variable PROD_COUNTER may be such an alias pointed to the accumulated value of a counter. Though I would suspect that Ron's caution may be the correct one.
 
good point, Bernie ... I hadn't thought of that ... but since he didn't balance his opening and ending parentheses, I'm betting that he just left .ACC out by mistake ...
 

Similar Topics

Hi, I am new to PLC's and I have a program that I need a little help with an explanation of how it runs line by line. I understand the overview...
Replies
30
Views
6,957
OPN DB 36 L #IN0 // Constant number of drive L 12 *I + 8 SLD 3 LAR1 L...
Replies
3
Views
3,316
Could anyone explain the code for me please, Step by step Thank you , ----------------------------- FUNCTION FC 3 : VOID TITLE = VERSION ...
Replies
0
Views
1,537
Hi, I have old panelview 1200 the programme was writen using PDS . I need explaination on how to download programme into this panelview...
Replies
0
Views
3,943
Back
Top Bottom