How to prevent division by zero in ladder (PLC)?

1.3k Views Asked by At

I have to make a circuit to prevent dividing a number by zero. I tried to put a condition in front of the division block but it did not work. What could I do to solve that? Bellow is the non-functioning circuit that I tried. I am using the RSLogix Micro emulator 500 on my computer to simulate the Allen-Bradley PLCs. enter image description here

4

There are 4 best solutions below

0
On

Your original logic looks good. Just change the EQU comparison instruction, in rung #2 to a NEQ instruction. Should work like a champ.

Another preventative rung I add into all my RS Logix 500 programs, at the very last rung to be evaluated, is an OTU s:5/0. This will prevent Math Overflows from Faulting your PLC.

enter image description here

0
On

It appears you are testing N7:2 for EQUal to 0? Hence, it will only execute the DIV if N7:2 EQUals 0? Should it be a "NOT EQUAL" box?

0
On

You simply have to add some logic to avoid it. Personally when I divide by zero, I'd usually like to have my output from the function be zero. So you simply set up opposite cases. If you're divisor is equal to zero, move zero into the result. If your divisor is not zero, then perform the division.enter image description here

0
On

As franji1 stated. You must check N7:2 for NOT EQUal to 0!

You could set it up in only one rung this logic, as it's only execute the division if the conditions is satisfied. Just remember, the LAD from Rockwell controllers is read for left to right, top to down.

LADDER EXAMPLE IMAGE

Regards.