Jump to content

How to compare previous value with the next received from input


Recommended Posts

Hi and Happy New 2018 all!

Maybe this will sound like a dumb question, I am beginner in programming in VisiLogic, so is there any way to compare current value received from an analog input with a previous value received from the same input. I have tried to use the 'Store Direct' with MI0(analog input operand) value to be stored in MI1 and tried compare MI0(A) with MI1(B), but it always gives me the same value.  How to memorize previous value and be compared with the current? How to make MI1 hold the previous value, MI0 to hold the current, and untile they are compared MI1 is not overwritten by the current value?

 

Thank you in advance.

Link to comment
Share on other sites

  • MVP 2023

We're all beginners at some stage.  That is the trick with PLCs....you're always learning something.

You need to set up your storage into MI1 based on whatever interval you want to work with.  Lets say one second.

1).  Use SB13 (ON at rising edge of SB3 which is a 1 sec pulse) as the trigger to store your reading at MI0 into MI1.

2).  Next time SB13 comes on, compare MI0 to MI1, and get whatever output (MB?) you want turned on if they are different.  Once you have done the compare, again store MI0 into MI1.  This will then be a loop, and once you write this into the ladder you will see that it takes only a few lines once you combine it all properly in the correct order.

If you have got your inputs in the View/HW Configuration set as progressive numbering, MI1 may perhaps be assigned to the next physical input.  You may need to alter MI numbers to suit.  ie/eg  your MI1 might in fact need to be MI20 to avoid conflict.

cheers,

Aus

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.