Checking status of certain number of inputs

dajody

Member
Join Date
Oct 2004
Location
Winnipeg, Canada
Posts
2
Hi. I'm relatively new to PLC programming so this may be a simple question and I'm just overlooking the easy way to do things.

The machine I'm dealing with uses an OMRON CJ1M CPU12 plc (using CX-Programmer 4.0 software).

I'm trying to figure out a way to monitor 8 separate proximity sensor inputs and set an output work bit high when ANY 5 of these inputs is on. Based on mathematical combination there are a total of 56 possible combinations. I could use 56 lines and write out all 56 possible combinations, but it seems like there must be an easier way. As I mentioned I'm fairly new to PLC programming (I've read a few books and basically learned on the fly with some new equipment we purchased at work), so there may be some functions I just haven't been exposed to yet.

Anyway, I'd appreciate any help. Let me know if more information is required. Thanks.

Dave
 
Inputs

I don't know the Omron commands but you might be able to do it this way.

For each input, if you have if true move a 1 into an unique integer, if not move a zero. (2 rungs for each or use a branch and combine to 1 rung).

Add the totals of all integers together, if greater than 4, turn on the output. With A-B we could use a compute function to add them together.

This logic could use up to 18 rungs of logic.

Good luck
 

On every scan, begin by resetting TOTAL to "0".
+-----------+
-----------------+ TOTAL = 0 +---
+-----------+

If Prox-1 is ON then Increment TOTAL, else don't Increment TOTAL.
PROX-1 +-----------------------+
----| |----------+ ADD TOTAL + 1 = TOTAL +---
+-----------------------+

If Prox-2 is ON then Increment TOTAL, else don't Increment TOTAL.
PROX-2 +-----------------------+
----| |----------+ ADD TOTAL + 1 = TOTAL +---
+-----------------------+

If Prox-3 is ON then Increment TOTAL, else don't Increment TOTAL.
PROX-3 +-----------------------+
----| |----------+ ADD TOTAL + 1 = TOTAL +---
+-----------------------+

If Prox-4 is ON then Increment TOTAL, else don't Increment TOTAL.
PROX-4 +-----------------------+
----| |----------+ ADD TOTAL + 1 = TOTAL +---
+-----------------------+

If Prox-5 is ON then Increment TOTAL, else don't Increment TOTAL.
PROX-5 +-----------------------+
----| |----------+ ADD TOTAL + 1 = TOTAL +---
+-----------------------+

If Prox-6 is ON then Increment TOTAL, else don't Increment TOTAL.
PROX-6 +-----------------------+
----| |----------+ ADD TOTAL + 1 = TOTAL +---
+-----------------------+

If Prox-7 is ON then Increment TOTAL, else don't Increment TOTAL.
PROX-7 +-----------------------+
----| |----------+ ADD TOTAL + 1 = TOTAL +---
+-----------------------+

If Prox-8 is ON then Increment TOTAL, else don't Increment TOTAL.
PROX-8 +-----------------------+
----| |----------+ ADD TOTAL + 1 = TOTAL +---
+-----------------------+



BTW, there are 56 combinations where ONLY 5 inputs are on... however, there are actually 93 combinations where AT LEAST five inputs are on.

Depending on what you really need, the next line in the code will one of the following...



TOTAL 5
--------| = |--------------------------------( ) Output Work Bit




TOTAL 5
--------| > = |------------------------------( ) Output Work Bit


 
Now... what if a particular combination indicated a particular fault condition?

The previous answers only indicate that a combination of 5 (or more?) sensors are on. They do not indicate the particular combination.

Of course, if the output bit is on then you could simply look at the inputs and see which are on. However, if each combination indicates a particular fault condition then one would have to look at some kind of listing to determine the particular fault. If there are 93 possible combinations then one would need a listing of those 93 fault conditions.

You would have to identify each condition by the particular input combination... I'm not going to bother trying to create a sample of what that list would look like... it would be painful.

Is there an easier way to determine the nature of the fault condition?

Yes, there is.

You would still have to do the ADD/Increment routine to determine if a 5-sensor (or more) fault condition exists.

At the same time that the sensor count is being modified, use the status of the particular sensor to set a corresponding bit in an Integer. Sensor-1 corresponds to Bit-1, Sensor-2 corresponds to Bit-2,... etc. This will work, of course, only if your particular PLC has the capability to directly access bits in an Integer.

There are other ways as well... such as using Word-wise "OR" functions or a "mapping" function.

Some PLC's provide a means to "map" a sequence of Inputs, Outputs or Control Relays to a word.

In some cases the sequence is defined by a starting point and then a count indicating the number of elements to map. In that case, the Sensors should use 8 sequential Input numbers.

In other cases, the mapping function allows you to specifically identify the elements of interest in the order of your choosing.

You need to read your manual to determine the capabilities of your particular PLC.

Regardless of the method you finally manage to employ, when the ADD/Increment routine is done, and if TOTAL is greater than or equal to 5, then display the Interger value somewhere.

If you are working with a hard-copy list of fault conditions then the displayed Integer value will identify the particular Fault ID.

Alternatively, or additionally, you could have your code "pay attention" to the Fault ID and respond accordingly.

You could go as extreme as having your code respond to each particular Fault ID in a particular way or you could simplify the response by grouping particular Fault ID's together.

You could watch for and warn of "near-fault" conditions (Total = 4).
You could count particular "near-fault" conditions by Fault ID number.

Let your imagination go wild!
 
Omron offering great tool for that problem.

You can count the numbur of bits which is on in word.
Then if the No grater then 5 set your output to on.
First you have to move your inputs to word in my case it was H0
you need to set number of word and destination word I used DM24.
Then compare DM24 to 5 if its grater then set your output to ON.
Only 4 rungs.

P.S dont forget to set HO D24 to zero in first scan.(5 rungs).

If you geting any problem with that PM me your E-mail I will send you all the program.

bit count.jpg
 
Last edited:
Wow, thanks for all the suggestions!

Terry...I'm looking for the combination when ONLY 5 inputs are on (and the particular combination does not matter). If more than 5 inputs are on, something is seriously wrong with the machine (which I guess I could use as another error check).

ArikBY...a bitcounter sounds exaclty like what I think I've been looking for. I'll have to check but I think my inputs are already in a word. I was thinking of doing something like this but wasn't sure how to completely execute it (I was thinking of comparing the value of the word to all the possible hex values where 5 inputs are on...but this bitcounter method is much easier). I'll look into it tonight and see if it works out.

Thanks again everyone! I'll definitely be back here more often.

Dave
 

Similar Topics

Processor: Modicon 140 CPU 652 60 Ethernet Card: 140 NOC 771 01 Device: Eaton C441R I have set up a starter using the Eaton C441R attached to...
Replies
1
Views
1,391
Giving myself a headache here! I have worked with plc's for a few years, but new to programming. Basically I am wanting to check the status of 8...
Replies
11
Views
7,029
Hello, can someone share/explain How to check comms between PC and PLC via TeamViewer? TIA
Replies
14
Views
386
Hello, I have a question on an OCR application I am doing. I am reading in 16 characters that come from a camera into the plc in its input words...
Replies
4
Views
1,269
I have some questions about MSG Type checking Does a MSG instruction care if the name of the UDT type are different on each PLC as long as...
Replies
6
Views
3,454
Back
Top Bottom