Sign in to follow this  
Followers 0
SimarGill

Using the CNT function

14 posts in this topic

Good evening, I was wondering if any could give me some guidance on how to use a CNT function properly. The PLC I am using is: CJ2M - CPU31 What I have in my process is that an inductive sensor is in default OFF state then if a metal part is detected then it kicks off but when metal part is no longer in view then it is back OFF. Then if a plastic part is in front of inductive sensor then it still remains off. What I want to implement is that any time a metal part is detected (Inductive Sensor is ON) then it should add 1 to the counter and hold that value until the next time a metal part is detected which will make the counter now 2. The same thing should apply if the plastic part is detected (Inductive Sensor is OFF), add 1 to the plastic counter. The problem with this section is that there isn't a indication as to when a plastic part is detected therefore if inductive sensor remains OFF then the plastic counter will keep adding 1 recklessly. If anyone knows a way I could use internal bits or some other trick to this problem. Please reply and I highly appreciate it. Meanwhile, I'm going to look around in the lab if I can find a capacitive sensor lying around which I can mount to detect plastic parts and thus kick off the counter to add 1. Thanks for all the help.

Share this post


Link to post
Share on other sites
You must use a capacitive sensor (detects metal and plastic parts)

Share this post


Link to post
Share on other sites
CNT instruction is not the best way to do this. Try an Increment instruction instead, with the rising edge of your sensor input. Maybe you want something like this: (Edit: since the capacitive sensor see both metal and plastic part, you will notice that there is a NC contact of the inductive sensor in the 2nd rung) Edited by pfort

Share this post


Link to post
Share on other sites
OK. For reliable operation use a timer. Both sensors + time - metal part , only capacitive sensor + time- plastic part. Sorry I haven´t cx-programmer at home.

Share this post


Link to post
Share on other sites
Thanks for replies. I found a capactive sensor but with fixed sensitivity that kicks off for aboth metal and plastics parts..I could probably use this in conjection to the inductive sensor?? Such as if both inductive and capactive kick off then add to metal counter or if only capactive kick off then add one to plastic??? Thoughts?

Share this post


Link to post
Share on other sites
See post #3 Your info tell your are studying but did you begin? Edited by pfort

Share this post


Link to post
Share on other sites
Yes I am studying. What this topic is actually a small part in a bigger operation im doing. And yes I already made a program but so far I am able to seperate metal and plastic parts but not being able to keep track of them. Its the weekend here and lab is closed. Im going to try that suggestion tomorrow or maybe tuesday when I am in lab again. I will keep you poated. Thanks to all.

Share this post


Link to post
Share on other sites
Try an Effector capacitive sensor - they have one with a sensitivity adjustment but it stll may not work If the metal object is steel you may be better off with a magnetic sensor to detect that and and the results for metal.

Share this post


Link to post
Share on other sites
Ok I will have to ask my professor if he can order one. Can you give me an example on how I would use CNT function? Let's say I toggle a bit ON and counter adds 1. Something simple like that. If you can attach a picture of that logic that will be great. Thanks!

Share this post


Link to post
Share on other sites
Pfort provided a good example for what you are trying to do. The CNT (or CNTX) function counts down from a specific setpoint and then turns on a done bit. To keep a running count, not to a specific value, use the code above.

Share this post


Link to post
Share on other sites
I just tried that method but I am having a issue with the binary increment. Instead going up by 1 it keeps going up as long as the inductive sensor is on. I should mention here that as soon as metal is detected, Inductive sensor is on for at least 7 seconds.

Share this post


Link to post
Share on other sites
You must either use the differentiate up option on the inputs as shown in Mike's example or use an @++ instruction to increment the count. Either one of those will keep it from cycling more than once. Edited by Mendon Systems

Share this post


Link to post
Share on other sites
When I was new to Omron, the first thing I did was to read the programming manuals. There are very good hints there. And when I ask question on a forum, I read the answers before ask again. But usually I make my homeworks before asking. Edited by pfort

Share this post


Link to post
Share on other sites
Thanks for the tips Pfort. I'll do that but I did use the differentiate up instruction but pretty sure made an error. I will try again today when in lab again. Thanks!

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