Word changing... bit 3s up

Hi

So, I understand that this code:

L #DW_1

L #PREV_CY_1

XOD

L #DW_1

T #PREV_CY_1

AD

L 0

<>D

S #AL_1


Wil Set AL_1 when 0->1 and 1->0, but, it's indeed important that it may only Set when a change form 0 to 1 happens. So I should use something what Peter Says. This code is running allready btw, and indeed, when I had 2 Alarms and one dissapears, the Alarm is triggered again, this is not good.

The code u give me Sparkz, I understand parts of it, but not all. I'm a Lad programmer who recently made the step to STL.

SLD is something I asked before but still don't understand for example.
 
That code above should be OK as the XOD sets only the bits that have changed, that is then AND'd with the actual set alarms, therefore you should find it only turns on the alarm when the fault goes from 0 -> 1.
 
The F1 help explains the SLD

Examples
Contents ACCU1-H ACCU1-L
Bit 31 . . . . . . . . . . 16 15 . . . . . . . . . . 0
before execution of SLD 5 0101 1111 0110 0100 0101 1101 0011 1011
after execution of SLD 5 1110 1100 1000 1011 1010 0111 0110 0000


remember though that the bytes travel from left to right, i.e. MD10 would be MB10 (left byte), MB11 (left centre byte), MB12 (right centre byte) and MB13 (right byte).
 
hi

I think I had the impression today that it triggered the alarm when one alarm came good...

0000 0000 0000 0000 0100 0000 0000 0000 0000 (alarm act)
0000 0000 0000 0010 0000 0100 0000 0000 0000 (prev cycle)
XOD
0000 0000 0000 0010 0100 0100 0000 0000 0000
0000 0000 0000 0000 0100 0000 0000 0000 0000 (alarm act)
AD
0000 0000 0000 0000 0100 0000 0000 0000 0000

L 0
<>D

So U are right
Weird what happened then, wil do some extra tests right away

Tnx Peter for the help
 
I understand

I understand what a Shift Left Double xxplaces does,

But, why SLD 3, that's something I don't understand and that I see a lot when they use pointers
 
Sorry guys, I messed up...

...I forgot to AND the XOD result with the present alarm value (probably the extra mask DB that had me fooled...)

This should do it:

Check_ALM_w_mask_update.gif


BTW Combo, your routine is correct. It will only detect rising edges (so only new activated alarms).
 
The address in pointer format is byte address.bit address in a double word. The last 3 bits make up the bit address from 000=0 to 111=7. The pointers usually start at bit 0.


pointer1.JPG



The above pointer format shows that.






EDIT:

So in other words, if you want your pointer to start at word 6, you would load 6, then shift left double 3, to place it in the correct location for the pointer.
 
Last edited:
Oh man, this is really getting out of hand!

The alarm bit has to be set when the new alarm value differs from 0, so insert 'L 0' between the 'AD' and '<>D' instructions in my example, like this:

...
AD
L 0
<>D
S #ALARM_ACTIVE
...

Again, my apologies...
 
Hehey

I tested again, and

L #DW_1
L #PREV_CY_1

XOD
L #DW_1
T #PREV_CY_1
AD
L 0
<>D
S #AL_1

Works fine, maybe I had a rising alarm jut on the moment that I was solving one, I did many tests, and it's all good.

The code from Sparkz and about the pointer, that's something I will study on tomorow.

Thanks guys
 
Hey guys

I don't see the light of the pointer..

So u have 3 bits in a pointer and you need to shift three places away from this bit area to have the byte area... but, I don't understand where u declare the pointer format, why he uses it and so on...

Why is Sparkz doing it in that way..., what's the advantage of a pointer, ...
 
The advantage of using a pointer is that you reduce the amount of code. In Sparkz example, he indirectly addresses the alarm bytes and jumps back in the loop the amount of times required.

Imagine you had x amount of bytes to check, you can either write the code for one and then repeat that code x times or write it once and loop x times, the amount of memory used can be greatly reduced.

You don't declare the pointer format, the pointer format is a shown in message 38, and if you use a pointer to point to an address it must be stored in double word format.
 
To sparkz -kind of see you point but - with my separate DB's , they are only as big as they need to be - so the number of loop iterations is always optimal - if you use one DB - then you need you leave spaces for alarms - causing unnecessary looping - I'll take a look on the effect of cycle time - whilst of course optimization of programming is important - if code becomes unreasonable to debug at the gain of a millisecond - I prefer to have the readable code first .
 
Hi 10BaseT.,

Three identical DB's are definitely a lot easier to expand than one DB containing all data.

But actually I suggested to use one instance DB and two global DB's, all three of the same size. Since both the ALARM_DB and the PREV_SCAN_DB are opened twice per loop, you could really pinch off quite a few µs per loop.

But you also are right about this: Readability should come first.
 
TWControls said:
Make a tag for Previous Alarm.

If Current Alarm value is greater than Previous Alarm value then trigger horn and move Current Alarm to Previous Alarm. This will cover new alarms being triggered because each additional alarm will increase the value of the word

If Current Alarm value is less than Previous Alarm value then move Current Alarm to Previous Alarm. This will cover alarms being turned off and will ignore them

You didn't mention the PLC so can't give a specific example but this should work for pretty much any PLC
This approach will not detect new alarm if it appears at the same cycle with dessapearing one of existing alarms...
 

Similar Topics

Hi all, i have a panelview plus terminal 2711P-T12W22D9P terminal with different user names and passwords. Everyone seems to know the maintenance...
Replies
3
Views
809
I have been asked to find out if there is a way to change the different user passwords for the HMI through the PLC. We use FactoryTalk View Studio...
Replies
12
Views
3,607
Hello. I have not found any documentation on this matter. I want the user to be able to change their password back to a previously used...
Replies
3
Views
1,893
hi, Is there a way to choose with %MW you use depending on the value of %SW49? For example, i have 7 %MW: -%MW4 that needs to be active when %SW49...
Replies
0
Views
1,204
Hi, I am using FactoryTalk View v6.10 and I am updating from an old PV1000 (with panel builder 32) to a new PV Plus 1250. The old project had a...
Replies
3
Views
1,605
Back
Top Bottom