Siemens Step 7 - SFB 4, SFB 5 - TON, TOF

bobby1234

Member
Join Date
Jun 2006
Location
houston
Posts
12
Hello everyone,

I am programming a Siemens CPU317-2 and I wanted to reset TON and TOR timers. In Allen Bradley world, there is actually a function called RES which resets a timer or counter given to the function. I tried searching the Siemens built-in and standard library but I could not find such a function. Is there any way I can reset the following timers:

SFB 4 - TON
SFB 5 - TOF

Thanking you all,

bobby1234
 
There is not a single "reset" instruction like there is for other types of timers. However, you can still reset an IEC timer in this way:
IEC_RESET.GIF


A collegue of mine has converted a large Allen Bradley program almost 100% straight from Ladder to Ladder.
We had to use an AB "compatible" reset method like in the above example.
 
Looking at the help files on SFB4 TON:
"Description:
SFB 4 "TON" delays a rising signal edge by the time PT. The timer runs only in the STARTUP and RUN modes.
A rising edge at the IN input causes a rising edge at output Q after the time PT has expired. Q then remains set until the IN input changes to 0 again. If the IN input changes to 0 before the time PT has expired, output Q remains set to 0.
The ET output provides the time that has passed since the last rising edge at the IN input. Its maximum value is the value of the PT input. ET is reset when the IN input changes to 0.
SFB 4 "TON" complies with the IEC 1131-3 standard.
The operating system resets the instances of SFB 4 "TON" during a cold restart. If you want instances of this SFB to be initialized following a warm restart, you must call SFB 4 with PT = 0 ms in OB100. If instances of this SFB are located within another block, you can reset these instances, for example, by initializing the higher-level block."

I haven't used this block personaly so I couldn't say if it resets or not.
 
What bobby1234 asks for is a "reset" instruction, like he is used to in AB.
That reset instruction can be placed anywhere in the program.
What I posted will achieve such a reset functionality.
 
Jesper - for the timer reset, why not just put a normally closed M1.1 contact in series with M1.0 in network 2 and connect M1.2 to the Q output of the timer call ?
 
Last edited:
He's talking about resetting at another point in the program.

As a rule I don't attempt to 'simulate' PLCx instructions in PLCy, I feel its a waste of time (no pun intended). You should use the instruction set as intended.

Having said that, when it comes to timers and counters in S7, I'm still stuck in S5 mode, I generally make my own, although I have modernised my approach by utilising the clock pulses generated by the CPU.

This way I can reset anywhere without the need to attempt to fool myself that I'm really using an AB PLC.
 
PeterW said:
He's talking about resetting at another point in the program.
Exactly. Notice that you also have a reset instruction for the S5 timers. It works in the same way. You can put the reset anywhere in the program.

PeterW said:
As a rule I don't attempt to 'simulate' PLCx instructions in PLCy, I feel its a waste of time (no pun intended). You should use the instruction set as intended.
In our case, we had a huge and complicated AB program that had to be converted to S7 in the shortest possible time. Also, radical changes to the "programming philosofy" were banned.
We decided to use IEC times in stead of S5 timers for a number of reasons. And then we had to create our own reset functionality, as resets were used extensively in the old AB program.

I have to say, that porting the program from AB ladder to S7 lad went surprisingly smooth. There was no need to make anything drastically different in the S7. Of course, this means that many S7 features are not used at all. But that the port should be as straight as possible was not up for discussion.
 
I started on AB PLC's, about 10 years worth before changing jobs to a company 100% Siemens.

They had just made a massive investment and included a couple of machines off a company called Demarco in New York. The PLC was a Siemens 150u and it just made me laugh when going through it.

They had created FB's that exactly mimiced the AB instructions that at the time I was so used to and had names such as GET, PUT etc.

They even left an AB cross reference in the panel ☯
 
Some time ago (yes, all right Peter, don't mention it) I created a large FB with many instances of TON. I used some logic similar to Jesper's to control the timers within the block. This FB was called permanently from OB1. Elsewhere in the programme I then controlled whether each timer would run or not by setting the appropriate bits and checked the status of the .Q as required. All of these were available from the big FB IDB. It actually worked very well. Whenever anyone had to adjust the duration of several timers together, they were all in the one FB rather than scattered around the code elsewhere. It was very neat and suited the application. I don't suppose it would suit everyone, and I'm not sure how well it would scale up if extremely large numbers of timers were involved.

Regards

Ken
 
Ken M said:
Some time ago (yes, all right Peter, don't mention it) I created a large FB with many instances of TON.

I've seen this done before, timers and counters all in their own blocks, nothiong wrong with it as far as I'm concerned but not something I do myself, I prefer the timer to be with the logic its controlling.
 

Similar Topics

Dear all, i tried to use the SFB 4 timer but it seems that the timer just refused to count and im not sure why. I understand that with an IN...
Replies
4
Views
4,039
Good Morning, Hoping someone with some Siemens experience can give me a hand with this one. Customer has a S7-200 cpu, which has a 6GK7...
Replies
0
Views
243
I'm just trying to figure out the right method of adding a DO card to an existing rack. It's not the *next* open slot, but I have to move the AO...
Replies
5
Views
544
Hi Siemens Experts, I am hoping someone can shed some light on my issue. I have uploaded the code from a S7-300 (317-2PN/DP) using Step 7...
Replies
9
Views
660
Hello, We monitor the temperature of a pipe via a 4-20mA temperature transducer. This goes into DB135(Read Analog Inputs). The issue I have is the...
Replies
0
Views
624
Back
Top Bottom