11 byte's, where are the FALSE bit's (S7)

userxyz

Member
Join Date
May 2002
Location
any
Posts
2,768
Hi,

I have 11 byte's with bits. It's from a light curtain.

When beams are interrupted, those bit's are high.

What I wanna detect is: gaps.

When 5 byte's have all TRU bit's, then we get 5 byte's with the value 255. If there are more then 2 bits False in Byte 3 for example, then I need an alarm. Anyone has an idea how to write this?
 
hmm

Well,

In a bunch of byte's all bit's are true. But, if there are more then 2 bit's False in all these byte's, an alarm needs to be generated.

L D[AR2 said:
An example is not good enough. Specify the functionality you require.
 
image

ytytryg.jpg


PIB256 = First Interrupted Beam
PIB257 = Last Interrupted Beam

So, I have this info.

You can seen the bit's that are interrupted in the byte's PIB263 264 265 in this VAT.

When more then 2 bit's between beam PIB256 and PIB257 are false, then an alarm needs to be generated..
 
crazy

This is crazy, more simple in SCL ?

I'll try to understand your SCL code, but it's kinda hard to understand (again)


L D[AR2 said:
Here you go. I'll leave the alarm processing for you to add.
 
Combo said:
This is crazy, more simple in SCL ?

I'll try to understand your SCL code, but it's kinda hard to understand (again)

Not really that hard.

Take some pen and paper, enter random values in variables and then work it out on paper.
Way easier to understand what he's doing.

Yes you can use the PLCSIM and online view, but with pen and paper you need to think about whats happening, not only see what happened.
 
Here you go in SCL:

Code:
FUNCTION FC888: int
VAR_INPUT
iOffset:INT;
END_VAR
VAR_TEMP
iLoop:INT;
iBitOffCount:INT;
byData:ARRAY[1..11] OF BYTE;
bData AT byData: ARRAY[1..88] OF BOOL;
byMore:BYTE;
END_VAR
  FOR iLoop:= 1 TO 11 BY 1 DO
	byData[iLoop]:=PIB[iOffset+iLoop-1];
  END_FOR;
  iBitOffCount:=0;
  FOR iLoop:= 1 TO 88 BY 1 DO
	IF NOT bData[iLoop] THEN iBitOffCount:=iBitOffCount + 1; END_IF; 
  END_FOR;
FC888:=iBitOffCount;
END_FUNCTION
 
bzzz

Tried that, don't understand, grmzz

Isn't it easier in SCL ?


Jeebs said:
Not really that hard.

Take some pen and paper, enter random values in variables and then work it out on paper.
Way easier to understand what he's doing.

Yes you can use the PLCSIM and online view, but with pen and paper you need to think about whats happening, not only see what happened.
 
I have something else in mind (maybe too basic for you guys):

For i:= 1 to 11 do
if byte < 255 then
if byte <> 254 and <> 253 and <> 251 and <> 247 and <> 239 and <> 223 and <> 191 and <> 127 then
Alarm:= TRUE;
end_if
end_if
end for
 
hmm

It's more understandable, but, still need to analyse

I dont understand this line:

FC888:=iBitOffCount;

L D[AR2 said:
Here you go in SCL:

Code:
FUNCTION FC888: int
VAR_INPUT
iOffset:INT;
END_VAR
VAR_TEMP
iLoop:INT;
iBitOffCount:INT;
byData:ARRAY[1..11] OF BYTE;
bData AT byData: ARRAY[1..88] OF BOOL;
byMore:BYTE;
END_VAR
FOR iLoop:= 1 TO 11 BY 1 DO
	byData[iLoop]:=PIB[iOffset+iLoop-1];
END_FOR;
iBitOffCount:=0;
FOR iLoop:= 1 TO 88 BY 1 DO
	IF NOT bData[iLoop] THEN iBitOffCount:=iBitOffCount + 1; END_IF; 
END_FOR;
FC888:=iBitOffCount;
END_FUNCTION
 
Okay

Okay,

I will give it a shot...

euhm:

Okay, you place all the PIB data in tempbyte's.

Then you reset the iBitOffCounter.

Then you do a loop, 88 bits, so, 88 shifts of 1 step, checking each bit if it's low. If low, then you count up by 1.

The last line = don't understand.



Okay, you count the bits, but...

What I need is, an alarm when 2 or 3 beams (let's call it a gap) next to each other are LOW/FALSE. So it's allmost correct, but not yet.
 
FC888 is a function that returns an INT, this is how you assign an INT to the return value.

Code:
FC888:=iBitOffCount;
 

Similar Topics

Our system utilises INPUT_BYTE to capture NMEA0183 ASCII stream which sends data to the NOM multiple times a second. The NOM module can either be...
Replies
0
Views
385
Hello everyone, friends. I need help with something. I want to read and change Bit and Byte numbers via HMI. I found a code snippet for this as...
Replies
18
Views
3,021
Hello everyone :) I just want to start with learning PLC programming, so I need advice. I have SIMATIC S7-1200, CPU with integrated memory...
Replies
5
Views
923
I have a C-More HMI that changes my PLC String from "Machine Status" to "aMhcni etStasu" . There is an option with other objects that have string...
Replies
15
Views
3,464
Hello I have got a problem with positive edge from "system clock memory byte" in Tia Portal. I would like to change byte"system clock memory"...
Replies
27
Views
3,579
Back
Top Bottom