Peter Nachtwey
Member
OKLOL. Don't hold back, tell us what you REALLY think Peter!
NEXT TIME BUY A CONTROLLER SUITABLE FOR THE JOB!!!!!
That is how I really feel.
I know that changing how a product works can lead to all sorts of problems. Let's face it. Rockwell crippled the ML1100 so you need to buy a more expensive PLC. It is understandable except that people don't always do what was intended and the buy the cheaper product and waste much more time than they should programming around the weaknesses of the product.There is no MOD instruction in Logix 500. This is probably because the math registers give you one directly, and I've used them for years to do just what the OP is asking about.
I would solve the problem like this:
mod(a,b) = a-int(a/b)*b
However if I remember right Rockwell gets trick and rounds the answer to 14/5 to 3. In this case 14-(14/5)*4=-1
So if the result is negative the divisor,5, must be added back in so the result would be 4.
Some RISC controllers don't have a mod instruction either so they must do the divide, multiply and subtract trick.