Step7 How to Compare bytes (8bits)

apmcs1

Lifetime Supporting Member
Join Date
Feb 2005
Location
California
Posts
3
Hi All

First post.
I have 40 bytes in a database that are displayed as ascii text on a Lauer PCS 095 display, if any of the bytes arent valid ascii (such as 00hex) the whole 16 characters on the display turn to filled in circles.
I need to check each byte and if its value is not between 20 and 7F hex, I want to replace the contents with a 20 hex.
this is the current code:
// Copy ErrorString to Display
CALL "BLKMOV"
SRCBLK :=P#DB181.DBX56.0 BYTE 40
RET_VAL:=MW250
DSTBLK :=P#DB50.DBX420.0 BYTE 40

I need to check the 40 bytes in DB50.DBX420 to 459 and change them to 20's if they are not within 20 and 7F hex.

Do the math or compare functions only work with 16 bits or higher?

I'm using Siemens Step7 V5.3 sp2

thanks
Dave Welch
Autoliv
 
No, you can use the integer comparison to evaluate bytes. You can do this easily in STL (STL has no limitations at all), but I think in ladder there is a setting in the properties where you can force the "type checking" to be turned off.


Other than that, this is a pretty straight-forward task. If it were me, I would just create a 40 step loop starting at the first byte and index a pointer to step to the next byte. Or, if you absolutely have to do it in ladder, you could make 40 rungs of logic and use the absolute addresses instead. That would work too.
 
Hey thanks S7Guy for the reply, Hmm so the functions will work on just a byte as long as I address it that way? because an integer is 16bits and I thought I would have to shift 8 bits left or right to just get the 8 bits I wanted to compare.
 
Yes, it doesn't matter. I can do something like this, and it will work fine:

Code:
	 L	 W#16#20
	 L	 MB	10
	 >=I 
	 =	 M	 20.0

Add some clamping logic to test for the min/max, and you'll be all set.
 

Similar Topics

Hi all We are starting a new project and have to decide on either a 400H or 1500R/H. Hardware wise both PLC's should be fine, but I'd like to...
Replies
22
Views
6,493
I'm probably going to need to modify the ProTool program for a TP170B in the near future. Looking at the program as stored in the copy of the...
Replies
6
Views
7,091
when i compare the program from the plc with the one in step 7 i receive several differencies.Cause?
Replies
0
Views
4,202
U
Hi, does anyone know what means "Compare Blocks" in STEP7? I was triying to go online and monitor with a S7-300 when a message was displayed. It...
Replies
1
Views
3,898
ok now I am confused I cant even do a simple compare in step7..
Replies
3
Views
3,265
Back
Top Bottom