Sign in to follow this  
Followers 0
Winall

Input interrupt problem on CPM2A

10 posts in this topic

I have the following application: I use a proximity sensor placed near a disc connected to spindle of a motor to measure the motor revolutions. The sensor is then connected to input 4 of CPM2A. I use input interrupt to increment the counter if Output 1 turned ON (to the forward contactor), and decrement the counter if Output 2 turned ON (to the backward contactor). - To allow for input interrupts #0 & 1 for inputs 3 & 4, I use INT instruction with 3rd parameter = #000C - And the code to increment /decrement the counter is shown in the attached screen shot. (this sub is placed at the end of program) However, when I tested it with a very low revolution rate, if Output 1 is OFF, the counter still increments or decrements at times. Can anybody help ?

Share this post


Link to post
Share on other sites
Before you do any further, you might want to look at the following code i did many moons ago.... CPM2A Interupt counter mode download

Share this post


Link to post
Share on other sites
Hi Sleepy I did see your code before. But my app requires retentive count data and must perform other calculations. Built-in counter does not offer such flexibility. Did you see any problem with my attached code? When testing, if one of the ouput is ON, the code works great. But if none of outputs is ON, sometimes the count still increments or decrements. This is very strange ! !

Share this post


Link to post
Share on other sites
Have you looked to make sure your prox switch is not causing a double pulse? This can happen faster than the status color change shows the outputs on or off and the counter will still count. This is similar to switch bounce.

Share this post


Link to post
Share on other sites
No, the problem is not double pulse ! If you look at the attached code (screenshot), U can see that the input condition for INC or DEC is an NO contact of an output. If that output is off, then INC or DEC cant increment or decrement. But in my test, it still increment or decrements even though none of the outputs turn ON. It's really weird !

Share this post


Link to post
Share on other sites
Are the outputs fired in a subroutine ??? If so they retain their state when exiting the subroutine and are held on.....

Share this post


Link to post
Share on other sites
No, no outputs are fired inside this sub. It's very strange to me

Share this post


Link to post
Share on other sites
Without seeing any more of your program than that I can only guess that something else is affecting HR16. Do you do any math functions on HR15 that requires a double word or has a carry?

Share this post


Link to post
Share on other sites
POINT 1: Here's another little test.... In parallel with your DEC's and INC's put another INC with two other Data Memory Locations A & B. Then also put an alway on bit to fire a INC with another Data Memory, C. C = A + B if every time time your sub is executed and the FWD , REV bits are on. POINT 2: Referring to my previos post....You can make the counter retentive by always moving the count value via a MOV instruction into a DM area..You can also upon First Cycle of the PLC use a MOV instruction to copy this DM value to the Counter. POINT 3. screech...........................................putting the breaks on and having a rethink...... Can you not use the standard HSC on inputs 0, 1, as a pulse and direction counter....I have attached the section of the manual that explains the different modes.

Share this post


Link to post
Share on other sites
You can lead a horse to water, but you can't make him drink....

Share this post


Link to post
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
Sign in to follow this  
Followers 0