S7 Word Compare

kemppioy

Member
Join Date
Oct 2005
Location
Dallas
Posts
72
Hei,

I am trying to look at a 16 bit word and see if any bit has changed from 0 to 1 and then trigger a bit to show that a new alarm has arrived. In Allen Bradley I used a word compare instruction for this. I would move the word into a memory area and then compare it to see if the bits have changed from 0-1. How do I do this with Siemens S7? Is there a word compare somewhere?

Also, Allen Bradley has a nice cd that explains all of the instructions and even the calculations behind them in some cases. Does anyone know where I can find this for S7? There is quite good help in the help system of S7 manager but I am looking for a cd or reference manual just for the instructions.

Thanks!
 
in S5 you had to make a positive flankdetection on bitlevel like this

AN M0.0
A I 0.0
= flank_pos

A I 0.0
= M0.0
//to remember the momentary state of I 0.0 in the next cycle

If you really need a positive flank detection, you can do the same on wordlevel in S7. At this moment I only do not know the instruction to invert a complete word. If I remember this correct in german it is KEW ('ones'-complement of a word), like I said, I do not know the englisch version.

So it should be something like this:

L MW 0
'kew'
L IW 0
AW //and-word
T flank_word //pos. flank of every bit

L IW 0
T MW 0
 
If you just want to set a common alarm bit for any new alarm then you could do something like the code below.

If you want to generate a rising edge of each new alarm, modify this code by replacing the last 3 lines with 'T #AlarmWordRisingEdges'



Code:
L #AlarmWordMemory	 //Load alarm word memory from previous scan
L #AlarmWord		 //Load alarm word
T #AlarmWordMemory	 //Update alarm word memory
XOW			 //Check for difference
L #AlarmWord		 //
AW			 //Inhibit operation for falling edge.
L 0			 //Load 0
<>I			 //Test for new rising edge
S #NewAlarmFlag		 //Set new alarm detected flag


Kevin
 
Last edited:
Multiple word compare

Hei Kevin,

Thanks,

That worked perfectly. Now I have another question since I am still struggling a bit with STL. Because I have a lot of alarms I have them in many words. How can I compare all of the words to see if any of them have a rising edge (new alarm). Can I OR somehow all of the results so that if any of the words have a rising edge, I set the new alarm flag?

Thanks again,

PK
 
Hi,

It's easy to adapt the code I posted to check double words for a new bit on...just replace XOW & AW with XOD & AD

You have a few options to expand this across a range of alarm words, including...

- Repeat the code for each alarm word or double word but using the same result flag with each instance.

- Repeat the code for each alarm word or double word with the AlarmWordRisingEdges modification I mentioned, OR the words together at the end and then check for a new alarm.

- A more complex but elegant solution would be to use a loop & indirect addressing to check each bit/byte/word/double word in turn. Your alarm words being consecutive would help here.

There may be better solutions to your problem than I posted here but I can't think of anything else at the moment with this hangover.

Maybe Simon G will have a suggestion?

Kevin

**p.s edit**
How many alarm words do you have in total?
Are they in data or flag memory?
 
Last edited:

Similar Topics

Hello I am currently learning on my own how to program a Siemens S7-300, and I have hit a bit of a snag with a FB I am making that will compare...
Replies
5
Views
5,442
I am having a bit of trouble getting my head around this. I am using Step 7. I want to set a memory bit [Alarm_Active] when a random bit in a word...
Replies
3
Views
2,388
dear friends i m students and trying some design work in my home i have RSLogics500 software.and slc 5/02 processor. if some can help me...
Replies
2
Views
3,770
Hi All, How do I set a password to PLC using Proficy machine software 9.5-9.8 or some other way? I as using Emerson CPE305 CPU. Thanks.
Replies
2
Views
378
I have an AB micro820 analog inputs takes word datatype to scale my input to 0-100% , i need to know the word datatype range does anyone knows...
Replies
3
Views
162
Back
Top Bottom