Is a bit high????

JeffKiper

Lifetime Supporting Member + Moderator
Join Date
Jun 2006
Location
Indiana
Posts
2,460
I'm looking for a simple and clean way to evaluate a the status of a bit within an Array of 1048 long. Below is a small snapshot of the logic. It worked fine when we only had 20 bits to look at.

BST XIC DS[1].Advancing NXB XIC DS[2].Advancing NXB XIC DS[3].Advancing NXB XIC DS[4].Advancing NXB XIC DS[5].Advancing BND OTE System.In_Motion

I can make it in excel but who wants a line of logic with 1048 branches in it, if the software would even allow it. I'm probably overlooking the simple and effective way to do this.
 
What I do is when I start the procedure at a OneShot I MOV 1 to StepToCheck DINT & OTL TEST

Then on the next rung I check XIC TEST then I check DS[StepToCheck].Advancing OTL FoundOneHigh, then ADD StepToCheck 1 StepToCheck on a branch.

On the next rung I check GEQ StepToCheck (Highest value allowed) OTU TEST OTU System.InMotion

Then XIC FoundOneHigh OTL System.InMotion OTU FoundOneHigh
 
I've had to do this before. What I do is make a loop using JMP and LBL instructions. You call the loop as many times as yoi have array elements. We'll call the iteration if the loop "x".

Inside the loop, make an XIC with the Array[x] as the address to drive an OTE or whatever you want to trigger.

It ends up being just a couple of rungs. It's basically a ladder version of the "for x = 1 to 99" loop.
 
Last edited:
Stepping back a bit, if your logic is also setting or clearing those bits somewhere, then keep a running total of the number of bits that are set.: increment the total for every rising edge; decrement the total for every falling edge.


Then doesn't the logic for SYSTEM_IN_MOTION become this:

Code:
GRT RUNNING_TOTAL 0 OTE SYSTEM.IN_MOTION

?
 
Why not do a mask move against the bit you need and then compare the whole result >0
 
My logic else where in the system controls the advancing bit. The System.In_Motion is just for a HMI. We are doing a huge system and the system may be stationary for hours at a time. The control room will never pay attention. When each operator can start their little part of the system.
 
Are you trying to know which bits are high or just if any bits are high
are you trying to do this is a PLC if so what PLC
Either way a for next loop is the best way to handle it
 
If you are trying to implement an OR of 1048 bits (1047 ORs), why not put the bits into 33 DINTs (1056 bits; set the last 8 to 0 and ignore them)?


Then you only have to do 32 bit-wise ORs (or 33 NEQs) and test for non-zero of the result. You could also put it into a loop, or even a FAL if you have that.
 
I'm trying to see if any of these are high in a Compactlogix.
I have a UDT already setup for each machine station. So when any station moves I need to know that a station did. They don't care which station moved just that 1 did
 
If time is not too relevant do a indirect once every scan so you set a variable to 0, indirectly point to the location in the array if true then do what you need to do, increment the pointer compare for the max i.e. 1048 if = or greater than reset pointer back to 0 it would take 1048 scans but if that timing was too long (depends on scan time) then do more iterations per scan. If a bit is detected as true stick this in a register to point to the machine cell that is active, and force the pointer to 0 if needed to reduce time. You could also check if the register has a number in it and it compares to the last iteration then continue to see if another station has started. or count the number of trues to give an indication of how may stations are running.
 
The FSC doesn't work with a BOOL in an expression


But it will work with an INT or a DINT, so if you store the bits in an array of INTs or DINTs you have a shorter loop.


I still think you need to only keep track of the count of bits that are set to 1; if that count is not 0 then SYSTEM_IN_MOTION is 1; else SYSTEM_IN_MOTION is 0.


Presumably you are handling each UDT in in an AOI or a subroutine, so adding or subtracting 1 for rising or falling edges of that bit need be written only once.
 
I still think you need to only keep track of the count of bits that are set to 1; if that count is not 0 then SYSTEM_IN_MOTION is 1; else SYSTEM_IN_MOTION is 0.


Presumably you are handling each UDT in in an AOI or a subroutine, so adding or subtracting 1 for rising or falling edges of that bit need be written only once.

What if it changes when the plc is in stop?
The FSC doesn't work with a BOOL in an expression
Try "AlwaysTrue=DS[fsc_00.POS].Advancing" as the expression
 

Similar Topics

If any of you wizards can help in this I would be ever more grateful. We have this device that generates 9 second pulses coming into a DI module...
Replies
31
Views
3,592
After watching The Universe is Hostile to Computers from Veritasium, I suddenly remembered a lost weekend years ago trying to reproduce the same...
Replies
12
Views
4,380
I don't know what to think about this... When a "finger car" travels over a bump, there is a spike in the output Q1.3 (24 vdc output). I've...
Replies
9
Views
3,046
Hello, I am creating some local messages of faults in View Studio ME. I would like to setup the compactlogix processor to only rotate through...
Replies
8
Views
1,876
Hi Gents I need some help, Keyence UK is not supporting Keyence PLCs in the UK anymore, I have programmed an operation in Ladder with a 24 bit...
Replies
0
Views
1,897
Back
Top Bottom