Siemens S7 SFB4 problem

cjd1965

Lifetime Supporting Member
Join Date
Apr 2007
Location
UK
Posts
1,659
Hi
I have used a lot of these in a multi instance function block for alarm debouncing. However if the customer does not wish to use a debounce, my intention was they just set 0 as a preset. However I have found that if a value of 0 is used the timer output does not turn on. All the presets come from a MP370 WinCC Flex.

What is a preferred way of turning on the 'timer done' bit in this situation?

I am considering checking if 0 is entered and overwriting it with 0.1 in the PLC or modifying the HMI to use scripts to do the same thing

Cheers
 
Hello,

At the place you don't use the time you can fill it in the DB at minimum time ?? ( =1 ms) or define it in MP370 as minimum/maximum time (1 - 999ms)
 
Last edited:
An alternative would be use your owm FB which acts as an interface to SFB4. The code attached will use SFB4 if the time is non zero, else the output follows the input. You would replace all calls to SFB4 with a call to FB4. You could also check the time values are sensible if you wanted to.

Code:
FUNCTION_BLOCK FB 4
TITLE =
VERSION : 0.1

VAR_INPUT
  IN : BOOL ; 
  PT : TIME ; 
END_VAR
VAR_OUTPUT
  Q : BOOL ; 
  ET : TIME ; 
END_VAR
VAR
  sfbTimer : SFB4; 
END_VAR
BEGIN
NETWORK
TITLE =use sfb4 but if PT=0 then output=input
	  CALL #sfbTimer (
		   IN					   := #IN,
		   PT					   := #PT,
		   Q						:= #Q,
		   ET					   := #ET);
	  L	 #PT; 
	  L	 0; 
	  <>D   ; 
	  BEC   ; 
	  A	 #IN; 
	  =	 #Q; 
END_FUNCTION_BLOCK
 
Thanks for the replies. I cannot do much in the HMI because they enter the data in seconds and i use linear scaling to convert to mSecs for the SFB4 preset.

I think that i will use the suggestion of L D[AR2,P#0.0] and will play with tomorrow on the hardware.

Thanks again.
 
Last edited:

Similar Topics

I have modified an existing program on an S7-400 and download just the FC that had the change made to it while the PLC continued in RUN mode...
Replies
2
Views
1,565
Hi Guys, Please help on this: I called an SFB4 (TON)in a FB, Do you know how to calculate how much time left? On the picture, I want the...
Replies
6
Views
4,363
Hi, Is it possible to manipulate the standard SFB4-TON timer from Siemens in a VAT table? I need to do some qualification tests on a system with...
Replies
5
Views
4,583
Hi I am trying out SCL and wish to use a stat SFB4 with a preset from a DB, Say Stuff, T1 where T1 is type TIME Compiles FUNCTION_BLOCK FB20...
Replies
2
Views
3,582
I want to use 'SFB4: TON' because I want the code to be self contained, I don't have to assign a timer in the symbol list. I want to use the...
Replies
1
Views
8,516
Back
Top Bottom