mov and compare

Marcus Downie

Member
Join Date
Jun 2017
Location
corby
Posts
4
hi I'm trying my first program, I kind of know what I need to do but little help would be great.

I have 16 bits of or a word I would like to monitor, is the best way to put the 16 bits into a data memory. use the move function to move this data memory and then use a compare function with a equals or less than 0 so if any of these bit change at all I will be aware

cheers
 
What is it you are trying to do?

If you are trying to see if any of the bits change keep in mind that you would have to store what the bits were, and what the bits are now. Then compare to see if they are the same or different.

OG
 
Welcome to the forum!

The easiest way to see if any bit changes is to look at the 16 bits as an integer.

Each bit that turns on or off will change the value of your integer. So, compare the value of your integer this scan, to it's value last scan. If it's different, a bit has changed, so set your "alarm detected" bit and then copy the new value into your "last scan" value for the next check.

Of course, there's a gotcha here - if all of your individual bits are "1=alarm", then it's not enough to just detect that one has changed. To detect that you have a new alarm, you need to detect that a bit has changed from zero to one, but not from one to zero.

One way around this is to detect if your integer is larger than on the last scan - so you would use the same logic, only use a "greater than" comparator, instead of a "not equal to" comparator.

Of course, there's a gotcha in that method too, in that if you have one alarm turn on and one alarm turn off in the same scan, this logic will only detect it if the alarm that just turned on is assigned to a more significant bit than the alarm that just turned off. You'll have to decide how likely that is in your application, and whether it's a problem if it does occur.

Alarming is just one of those things - everyone has their own way of doing it, and probably none of them are perfect (except mine, of course :p ). Search the forum for threads on the topic and you'll find dozens of ideas on how to do it - try them all out and see which one works best for you!
 
A = alarm word this scan
B = alarm word last scan
C = A xor B. (C = bits which changed)
D = C and A ( D = bits which changed going high)
B = A ( save current for next scan)
 
Note: if you do use these word based logic manipulations be sure to document them well. It may not be apparent to a tech (or even you in a few months) what is going on.
 

Similar Topics

Hello experts. Anyone has any idea how to make BLKMOV execute only once? I have tried with R_TRIG and (P) but it wont write to my location.
Replies
3
Views
194
I've used AOI and User Defined Data Types, but I haven't created one yet. I have a lot of repetitive MOV commands to take a select number of...
Replies
4
Views
374
I'm having to make an AOI to use with a generic ethernet device because the manufacturer does not provide an AOP. I just want to do a sanity check...
Replies
13
Views
1,251
Hello, I'm trying to copy the entire value of a UDT base tag to an element of an array of another UDT containing an element of the first UDT...
Replies
7
Views
1,660
Hi, I would like to move a word to display wind direction. For example: NW, or SE, or ESE in RSLogix 5000, not panelview. I have a wind speed...
Replies
18
Views
5,541
Back
Top Bottom