How implement a timmer???

gutierrj

Member
Join Date
Jun 2005
Posts
12
Hi I'm working with S7-300 with STL, my problem is the next one: I am trying to delay a loop, just I want to spend time maybe 20s, then make a loop. Here is the structure of my program. I hope u can help with this.

Thanks.



Next: T #counter

Open a DB

Read data

Make operations

DELAY

L #counter

LOOP Next
 
I suggest you put the code into a function block and then call the function block at the required time interval. A function block will let you use static data so you can store your count in between calls. You can the separate the tasks of processing your data and generating the timing. You also have to provide the necessary logic to start your loop counter, if that's what you intend.

What is your previous S7 programming experience ?
 
Ok, but what your PLC must to do after finishing of the loop? Nothing? PLC executes it's scan cycle repeatedly. And it must to do something useful in this cycle. You cann't set PLC's watchdog time to 20 sec - try to do it in HW config. This means you must find an another way.
I suppose your task is to process one of identical data blocks every 20 sec. For this purpose you can use OB35. But you cann't use LOOP operator - it serves to realise an uninterrupted loop. OB35 structure:
O(
L #Counter
L 0
<=I
)
O(
L #Counter
L 10
>I
)
JCN lbl
L 10 //For example: you have 10 DBs or 10 iteration.
T #Counter
lbl: Open a DB
Read data
Make operations
L #Counter
L 1
-I
T #Counter
You can write this shorter.
 
The problem with put my code in different FBs is that they will do the same operations because just i need to read my DB(Global) sequencially, where data represents me instructions and arguments, for example if in my DB i have:

Adress Name Type Value
0.0 Inst1 Word 1
2.0 Arg1 Word 5
4.0 Arg2 Word 20
6.0 Arg3 Real 1.5

I need to read first the Inst1 then take a decision with his value, in this case Inst1 represents me a instruction with 3 arguments so i have to read the next 3 values, and then write this values in a MM420, after writting those values i need to wait a time before to read the next adress.

I am not sure if with FB i could use pointers because its the reason to use STL i would like prefer to use ladder diagrams =)

About my experiencie well always i work with Ladder Diagrams and also i didnt work with pointers.
 
First thanks for your help, second i have the plasure to know ur country specific Riga very nice city.

As i explained to SimonGoldsworthy the main objective of the program is read information from a global DB where i have data about instructions and arguments, the value of counter is the number of instructions that my DB contains. And u are right after my loop i dont cade nothing, in this case i can write BE just for block ends. Something that i forgot to tell u is that my code is in one FB not in OB1, from OB1 i call my FB.

I put my code, i hope with this u can get a better idea about my problem (So sorr if some parts are in spanish, but well here i speak spanish =) )

L P#0.0 // Pointer to the first value
LAR1
L #Contador // Counter
Sig: T #Cont_Temp

AUF #DBDatos // DBData, where i have insts&args
L DBW [AR1,P#0.0]
T #Inst_Num
L #Inst_Num
L 0
==I
SPB LSTR

L #Inst_Num
L 1
==I
SPB LMOV

LSTR: L W#16#47E
T #PKZ1
L W#16#0
T #PKZ2
CALL "DPWR_DAT" // Write value in MM420
LADDR :=W#16#108
RECORD :=P#DIX 14.0 BYTE 4 // Static Structure
RET_VAL:=#ErroPKZ
L P#2.0 // Increment my pointer as i need
+AR1
SPA Cont

Cont: HERE I NEED A DELAY BEFORE TO JUMP TO THE NEXT INSTRUCTION

PD. I have to one instruction to END the block
 
1. Set a bit when you have to wait.
2. Load your values into M retentive. ACC, AR, pointers other values you need to restart from the same point you left. (kinda stack)
3. Let the rest of the program execute and jump over you loop as long as the bit is set.
4. The time passes.
5. Reset the bit, load your M retentive and jump to where you need to be.

The PLC program loops anyway. Why don't you just jump over your loop (with a save of your pointer information)? If you have asyncronous (that don't execute in one scan) functions that you have to monitor things will complicate a bit since you will have to call them in a way outside the loop to monitor the done/error bits. I was reminded that the 200's don't have OB35.
 

Similar Topics

Hi I'm working with S7-300 with STL, my problem is the next one: I am trying to delay a loop, just I want to spend time maybe 20s, then make a...
Replies
1
Views
1,756
Let's say I have an inverter fed three phase induction motor drive where in the braking phase (when the motor operates in a generator mode) the...
Replies
2
Views
145
I want to improve a semi custom product I am delivering to a customer with implementation of safety relays. The system is fairly simple with just...
Replies
5
Views
589
I'm struggling to implement the test case which is highlighted. What ends up happening is the servo starts when I turn the cycle on, but it...
Replies
3
Views
1,075
I am trying to implement FIFO for filling tanks in the order it went empty in easysoft or some of you might know it by easydoft 7. I am trying to...
Replies
2
Views
2,318
Back
Top Bottom