s7 - 200, subroutines and timers

adfox

Member
Join Date
Jun 2006
Location
Poland
Posts
334
Hi, i've got a sbr that takes 2 input parameters - Time for low state and time for high state and it sets for example a flag for 5 sec. and keeps it reseted for another 5 sec...

Looks like this:

VAR_INPUT
T_Off:WORD;
T_On:WORD;
END_VAR
VAR_OUTPUT
Out:BOOL;
END_VAR
BEGIN

Network 2 // Flag 5 sec.

LD SM0.0
LPS
A M0.5
TON T38, LW0
LRD
A T38
TOF T37, LW2
LRD
A T38
A M0.5
R M0.5, 1
LPP
AN T38
AN T37
AN M0.5
S M0.5, 1

Network 3 // Put to output
LD M0.5
= L4.0


I want to use this subroutine more than once in my project but:
i can't pass specified timers names as an subroutine argument and i can't use the same timer twice, can anyone help me ?

I'm using s7-200 226 and step micro win v4.0 .
I'll be very grateful for Your help.
 
I'm more of an S7-300/400 user so have never used Microwin, but I assume it will be similar to, if some what cut down, the bigger systems.


The code you have reproduced show that the Timers are hard-coded in the block. therefore the block as it stands cannot be used as a multi-call block.

You'll need someone else to help with what you choices are to make it a multi-call block. Sorry can't be of better help.
 
I didn't use MicrowIN some years, but I think you must to use indirect addressing of timers if you want to use timer in multi-call subroutine.
 
Yes, that's right - timers are hard coded because i can't pass the value to the function, tried passing the timer name as string, as a word and it fails at the compile time.

At least i've made it in one network so using it as copy-paste-change timer values will work for me, but i'm looking for a way to make it as a small elastic function...
 
Gambrinus said:
It can be compiled
NETWORK 1
MOVD &VB30, VD0
MOVD &T1, AC1
NETWORK 2
TON *AC1, *VD0


Ok,it does compile... but sorry it will take time for me to get it to work, i'm new in plc programming and i don't know how to use what You wrote but thanks i'll try to make use of it.
Thanks!
 
Heh, it compiles but the download fails... i'm just reading about indirect addressing and try to make something similiar to Your example but why the plc doesn't want to download the program :/
 
Maybe &VB must be changed to &VW because preset is INT. But I amn't sure. Try to change direct to indirect step by step.
 
I can't tell it now because i'm home now, but within 12 hours i'll be back at work and will check it out, thanks!
 
Gambrinus said:
Maybe &VB must be changed to &VW because preset is INT. But I amn't sure. Try to change direct to indirect step by step.


&Vw doesn't compile, changing the first T1 in my case 37 the same, changing the second one make it works but it's still the same...
 
S7-200 dosen`t support indirect timer addressing like S7-300/400.
The attached library offers the required timers.
 

Similar Topics

May seem silly, but ive been trying to use subroutines in s7 microwin as I would in Step7, ie to create on subroutine (for example for analogue...
Replies
17
Views
4,454
Hi. I have a 222 CPU. I need to recover the program from the eeprom memory. Is it possible?
Replies
1
Views
78
Hi all, Currently having trouble getting a speed reference to write over modbus to an Omron M1... I can successfully write a run command and...
Replies
6
Views
249
HI i would like to know how to get a variable that will store the amount of times a program has been executed. The issue is I have 3 DBs for 1 FB...
Replies
2
Views
79
Hi folk, I would like to know what kind of Parameters should I setup for controlling with Profibus. My old Lenze 8200 motec 0.25kW have a busted...
Replies
0
Views
79
Back
Top Bottom