find bits in a array ??? how ???

userxyz

Member
Join Date
May 2002
Location
any
Posts
2,768
I need to find the low bits in an array:

example:

111111111011100111111101111111101111110011111111011

let's say an array of 40 bools for example.

I need to know if there are 2 zero's next to each other in this array, as you can see I should have a detection of 1 time 2 zero's.

Anyone has ideas how to write this in a PLC.

STL, IL, SCL, ST, on of these languages..
 
Combo said:
I need to find the low bits in an array:

example:

111111111011100111111101111111101111110011111111011

let's say an array of 40 bools for example.

I need to know if there are 2 zero's next to each other in this array, as you can see I should have a detection of 1 time 2 zero's.

Anyone has ideas how to write this in a PLC.

STL, IL, SCL, ST, on of these languages..

I see two, BTW.

Create a loop that does an OR of bit[x] and bit[x+1]. If the result is FALSE then you have a two zero pattern. You can even store the value of x at that point to indicate where the pattern is.
 
Last edited:
Do you need to count the number of double zero's or is detection of the first occurrence enough ?
 
How about a shift register either BSR or BSL, save the output bit in a place and then compare the next output bit with the last one if both are zero you got it.
 
Last edited:
Here's a canned FC that will do the job:

Example call:

Code:
	  CALL  FC	 1
	   Data		  :=P#DB1.DBX 0.0 BOOL 40
	   bFoundTwoZeros:=M10.0


Code:
FUNCTION FC 1 : VOID
TITLE =
VERSION : 0.1

VAR_INPUT
  Data : ANY ; 
END_VAR
VAR_OUTPUT
  bFoundTwoZeros : BOOL ; 
END_VAR
VAR_TEMP
  iDB : INT ; 
  iCount : INT ; 
END_VAR
BEGIN
NETWORK
TITLE =
	  L	 P##Data; 
	  LAR1  ; 
	  L	 W [AR1,P#2.0]; 
	  T	 #iCount; 
	  L	 W [AR1,P#4.0]; 
	  T	 #iDB; 
	  L	 D [AR1,P#6.0]; 
	  LAR1  ; 
	  OPN   DB [#iDB]; 
	  L	 #iCount; 
	  +	 -1; 
loop: T	 #iCount; 
	  AN	 [AR1,P#0.0]; 
	  AN	 [AR1,P#0.1]; 
	  +AR1  P#0.1; 
	  JC	two; 
	  L	 #iCount; 
	  LOOP  loop; 
	  SET   ; 
	  R	 #bFoundTwoZeros; 
	  JU	Exit; 
two:  SET   ; 
	  S	 #bFoundTwoZeros; 
Exit: SET   ; 
	  SAVE  ; 
END_FUNCTION
 
yes

yes

As you can see, a robot has to place finished products in a box. On the left and the right side we will place MLG light curtains that have 90 beams, 20mm between each beam, heigth = 1780mm.

Scaling the whole thing was no problem. Sending the actual_top_level to the bot is no problem.

But, when the products are not placed well, then we can see this because 1 or more beams are 0 between in the detected zone.

DSCN0287.JPG


cjd1965 said:
Is this your light curtain again?
 
scl

L D[AR2 said:
Here's a canned FC that will do the job:

Example call:

Code:
	 CALL FC	 1
	 Data		 :=P#DB1.DBX 0.0 BOOL 40
	 bFoundTwoZeros:=M10.0


Code:
FUNCTION FC 1 : VOID
TITLE =
VERSION : 0.1
 
VAR_INPUT
Data : ANY ; 
END_VAR
VAR_OUTPUT
bFoundTwoZeros : BOOL ; 
END_VAR
VAR_TEMP
iDB : INT ; 
iCount : INT ; 
END_VAR
BEGIN
NETWORK
TITLE =
	 L	 P##Data; 
	 LAR1 ; 
	 L	 W [AR1,P#2.0]; 
	 T	 #iCount; 
	 L	 W [AR1,P#4.0]; 
	 T	 #iDB; 
	 L	 D [AR1,P#6.0]; 
	 LAR1 ; 
	 OPN DB [#iDB]; 
	 L	 #iCount; 
	 +	 -1; 
loop: T	 #iCount; 
	 AN	 [AR1,P#0.0]; 
	 AN	 [AR1,P#0.1]; 
	 +AR1 P#0.1; 
	 JC	two; 
	 L	 #iCount; 
	 LOOP loop; 
	 SET ; 
	 R	 #bFoundTwoZeros; 
	 JU	Exit; 
two: SET ; 
	 S	 #bFoundTwoZeros; 
Exit: SET ; 
	 SAVE ; 
END_FUNCTION

Thanks

DO you have it in SCL also ?
 
Peter Nachtwey said:
LD should be charging for his services.

My thoughts exactly.

As a contract S7 programmer, I die a little bit inside every time I see Simon post one of his neat canned functions FOR FREE. :D

hmmm....I wonder if Combo's boss knows the source (pun intended) of some of his cleverer programming stuff?
 
Combo said:
DO you have it in SCL also ?

Anyone has ideas how to write this in a PLC.

STL, IL, SCL, ST, on of these languages..

Why not ask for SCL in the first place ?
 
stl scl

The reason for asking it in scl is because I didn't like the stl code, I first analyse and try to learn something that could be useful for my question.

nevermind, i'll convert it myself to scl, I was just wondering if it came from an SCL source because there are loops in it...

thansk for the stl source
L D[AR2 said:
Why not ask for SCL in the first place ?
 
...

How stupid can you be to say such thing...

If u read posts of me, you will see that I don't use code just like that, most of the time I have a solution myself, but I try to learn to have better code, learning from other people via PLCS.NET.

I helped other people too on PLCS if you read my posts.

And if I find a better solution then the one someone gave me, then I don't refuse to post this as well and know some opinions about the way I went.

If the forum is about helping eacdh other for money, then why is it still on the net.


PS KRK: my boss knows about PLCS, I let him read my posts, it's not like I'm earning credits. It's a shame that you (KRK!!) are on this forum, if you intend to help others for money, then you shoukd leave, I like to get help, and I help others for FREE, that's the basic principe of a forum

krk said:
My thoughts exactly.

As a contract S7 programmer, I die a little bit inside every time I see Simon post one of his neat canned functions FOR FREE. :D

hmmm....I wonder if Combo's boss knows the source (pun intended) of some of his cleverer programming stuff?
 

Similar Topics

Hey. I have an fault signal from a steamgenarator. This signal goes to an Input(I:2/2) on my slc5/5. The Input goes in conection with a...
Replies
2
Views
1,579
Hi All, Wondering if anyone has a source for information about products with problematic production runs from allen bradley/rockwell. Ive seen...
Replies
2
Views
139
Hi , Where i can find Mitsubishi PLC Card end of line & replacement model details. i am looking for Q02CPU replacement model. Please advice. thanks
Replies
2
Views
175
I have tested every screen and no single screen individually has this fault pop up, but when I compile and send to the PanelView it comes up. If I...
Replies
4
Views
195
Hi, One of my customers has an old fabric tensile testing machine. The IC # AD7501KN of its controller has malfunctioned. This IC is related to...
Replies
1
Views
90
Back
Top Bottom