Cycle time PEEK_BOOL

naturephoenix

Member
Join Date
Jan 2015
Location
Vienn
Posts
181
Code:
FOR #i := 0 TO #LoopSize BY 1 DO
    #Alarm := PEEK_BOOL(area := 16#84, dbNumber := #dbNo, byteOffset := #startByteAlarm_1, bitOffset := #startAlarmBit);
    #AlarmType := PEEK_BOOL(area := 16#84, dbNumber := #dbNo, byteOffset := #startByteAlarmType_1, bitOffset := #startTypeBit);
    IF #Alarm AND #AlarmType THEN
        #AlarmCount := #AlarmCount + 1;
        #AlarmNumber[#AlarmCount] := #i + 1;
    END_IF;
    #startByteAlarm_1 := #startByteAlarm_1 + W#16#2;
    #startByteAlarmType_1 := #startByteAlarmType_1 + W#16#2;
END_FOR;


This FB works fine but:
Size of FOR LOOP is 576. I need to call this FB 7 times with different inputs. I commented PEEK_BOOL inside FOR LOOP and

cycle time significantly decreased. Is there a way to make the same without PEEK_BOOL.
 
What if you do counter, increase counter every cycle and reset on 8 or 10.
Then call your alarm handlings depending of counter value, so your cycle time would be same than if you have only one FB call on program.
 
What if you do counter, increase counter every cycle and reset on 8 or 10.
Then call your alarm handlings depending of counter value, so your cycle time would be same than if you have only one FB call on program.

You mean, every cycle I call 1 out of 7 FBs.? Sounds good. I think I will do that
 
Exactly, if you don't need all data at same program scan.


Seperating calculations etc. to different scan cycles is old trick to have scan time faster.


Another way, which maybe would make your FB execution 16-times faster would be to look words instead of bits.


You would look words with And-command, and then count bit sum of result to alarm count.
Not sure if Siemens have block for bit sum, but it is easy to code FC or FB.



Word1: 1001 1100 1111 0011
word2: 1000 1100 1000 0000


After And
Active alarms: 1000 1100 1000 0000
Bit sum (alarm count): 4
 
Should be possibly also on word level, you need indirect to arrays thought


Problem is that between these two bits which I'm comparing there is 0.5 bytes offset.

So I can not do word operations.


Like this:


I said I got 7FBs.


For LOOP i := 0

In 1. of them: Alarm is DBX0.0 and AlarmType is DBX0.6 (FB No. 1)
In 2. of them: Alarm is DBX0.0 and AlarmType is DBX0.5 (FB No. 2)
In 3. of them: Alarm is DBX0.0 and AlarmType is DBX1.1 (FB No. 3)
....
...
For LOOP i := 1

In 1. of them: Alarm is DBX2.0 and AlarmType is DBX2.6 (FB No. 1)
In 2. of them: Alarm is DBX2.0 and AlarmType is DBX2.5 (FB No. 2)
In 3. of them: Alarm is DBX2.0 and AlarmType is DBX3.1 (FB No. 3)
....
...


Since Alarm is always starting at DBX0.0, maybe indirect addressing would be the best option, cuz I have to go through AlarmTypes
 
Last edited:
If bytes are allways with same offset, then copy alarms and types with SFC20 to different DBs with offset.
 
What is all this supposed to achieve ?
IMO, anything that involves absolute address manipulation should be avoided as far as it is possible.
Arrange the data to suit the code, rather than the other way round.
 

Similar Topics

Hello PLC friends. I've been going through a saga of diagnosing and fixing an old PLC setup that I inherited. I am learning as I go. Initial...
Replies
14
Views
330
Hi everyone. I have an issue with an Allen Bradley PLC model 1769-L30ER. This PLC had a previous program with a different IP address but when I...
Replies
4
Views
512
My Panelview plus 700 HMI stopped working and I replaced it with a new one. Moved the sd card from the previously installed panel to this one and...
Replies
16
Views
981
Hi everyone, I recently put in a 1769-AENTR, and where it is installed has had a couple power outages. Every time when the PLC comes back online...
Replies
3
Views
683
Hello Friends, I am looking for a way to take my PID Output( it is the result of my PI Algorithm in Real format) and generate a PWM Signal in...
Replies
16
Views
2,477
Back
Top Bottom