Step 7 time value

Rack Failure

Member
Join Date
Jun 2003
Posts
44
Hi
We have a S7 315 2DP with a TP 270 connected via MPI. I have set up a box on the TP to accept a number which will represent the number of minutes I want to write to a timer.
If I use a data block the max time written to the timer is approx 1.5 mins.

Can some body tell me how I can do this? ie if I enter the number 5 at the TP then 5 minutes will be entered to that timer.

Homer
 
Is it an S5 timer, or an IEC timer ?


If I use a data block the max time written to the timer is approx 1.5 mins.
Why is that ?

edit:
Oh maybe I can guess it.
Is the max time actually 99.9 seconds ?
Then it is because you are using S5 timers, and it is set to 0.1 second resolution.
S5 timers use a strange BCD format and goes from 0 to max 999 of whatever resolution it is set to.

edit again:
If my above assumption is correct, then a quick fix would be to change the resolution of the timer from 0.1 seconds to whole seconds.
You then have a max time range of 999 seconds (more than 16 minutes).
 
Last edited:
I should load Simatic Manager on my new laptop but havent used it in so long I am not sure its worth the effort.

Since I dont have it installed I can not state specifics but technically it should not be much different than any plc but can vary depending on what type of timer.

The easiest method I can think of is let that box be capable of floating point entry and send the number entered to a multiplication instruction...ie you enter 5 it multiplies by 100 and places 500 in the pre-set for a .01 timer, which is 5 minutes. If you enter 1.5 then it would be 150 as preset for a .01 timer which is 1.5 secs

I see Jesper responded so maybe he can offer better details.
 
Jesper & Ron thanks for the replies. It is an S5 timer which accepts time in hours, minutes & seconds format. The problem is how to convert a number that represents whole minutes into a MW and transfer the MW into a timer that will recognise as a proper time value. These timers in S7 are different from the timers used in S5 where you loaded a number and changed the timer multiplier to get the right time value, ie 0.0, 0.1, 1 or 10.
 
In one of my applications, I allow the operator to enter a timer value in seconds (anywhere from 0 to 99.9 seconds) on a TP270. I only handle seconds down to a tenth; not hours, minutes, or milliseconds. The value goes to an S5 timer in the S7-314-2DP. This may not be the best way to do this, but I got it to work.

I use an input field for the time value entry. The operator enters a DINT in the format xx.x seconds (so, a tenth of a second). In the Protool tag, I enable linear conversion from 0-10 to 0-1000.

In my S7 program I use FC40 (Time to S5Time) to convert the entered value from type DINT to S5TIME. I programmed this in ladder so I also had an intermediate MOV instruction, so really I had MOV type DINT to type TIME and then FC40 convert type TIME to type S5TIME. I then used this value in my timer.

The Siemens Support site has some examples of entering time in ProTool to use in a S5Timer using scripts. Try these Entry ID numbers:
9125571
9123496
947095
5996891
 
Imi'kes suggestion should work.

However, I am pussled why it is working with 0.1 seconds resolution at the moment. All Rack Failure has to do is to get it to 1 second resolution.

If the setpoint from the HMI is formatted as an "INT" and limited to 0-999 then in the S7 he could add the timebase like this:

L "Timer_SP_HMI"
ITB // Convert to BCD
L W#16#2000 // "2" is for "seconds"
OW // Combine the two to make an S5TIME
T "Timer_SP" // This is the one that is used for the S5Timer

Actually it should be the same as the old S5 timer (hence the name).
 
The part I didn't make clear about the 0.1 second resolution is that my application needs to resolve 0.1 seconds. So I wrote about the logic for my application leaving it to Rack Failure to change it for his resolution. Sorry if this was confusing, hopefully this helps.

Jesper's logic is terrific; which makes me wonder why I used a DINT when I could have been using an INT. I'll have to work on that. Thanks.
 
Hi Guys,

What about the other way? I mean you just wanna display seconds of a s5timer on a hmi using an Integer Tag. If you just Load and transfer you would get a figure in the hundreds maybe?

L "Timer_SP_HMI"
ITB // Convert to BCD
L W#16#2000 // "2" is for "seconds"
OW // Combine the two to make an S5TIME
T "Timer_SP" // This is the one that is used for the S5Timer


//The other way?


L T1 //Example timer
BTI // BCD to Integer
L W#16#2000
OW
T HMI_TAG //Integer



I dont have PLCSim at the mo or a CPU to try this on but would it work?

Thanks STL
 
Hi STL,
I think that you dont have to use the L W#16#2000 and OW lines in your example.
There are two outputs from an S5Timer that reports the remaining time, BI and BCD (if you view the timer in LAD or FBD you can see it).
BI reports the remaining time as an integer (though the output is formatted as a WORD, typical Siemens).
BCD reports the remaining time as a BCD.
If you use the BI output directly, you dont have to do anything else.
In the HMI program you can add some decimal points in the display of the variable to match what it is formatted to in the S7 program.
 
Hi Jesper,

Wow Thanks for the rapid response, As per usual i never thought of that (BI Output!) I give it a try later when i'm back on site.

Thanks again

STL
 
I convert S5Timer preset values for display on the HMI. In my application, I display some of the S5timer presets on the HMI and allow the operator to change those values.

So, if you want to display the preset value, I think you will need to convert the value using some method. I use FC 33 (S5Time to Time) to convert the value from type S5TIME to TIME and MOVE that TIME to a DINT. In Protool, I enable the linear conversion of 0-10 to 0-1000 for that tag and then display that tag in an output field. The conversion allows me to display the time in seconds with resolution of 0.1 seconds. For different time resolutions and base, you'll need to adjust the conversion and display. Using FC 33 and FC 40 may be a little more convoluted than what Jesper has suggested.

If you just want to display the elapse time, then take Jesper's advice; it's simpler.
 
Imi'ike & JesperMP
Many thanks for the info you gave. I've managed to get a programme working where I can enter a a value of whole minutes eg 1 to 10. I have attached the file for your interest.
P.S. FC40 came in handy.
 
Anyone tryed the script from Siemens? I just did, but I get an error message. Apperently I can only enter 20 lines in one script.
 
Werner:
Yes, I ran into the script line limit along time ago and have since tried to stay away from that limit. Search the ProTool online help for "System limits for Windows-based Systems" and there is a table of all kinds of limits. The MP 270, OP270, TP270, and MP 270B are limited to 50 scripts and 20 lines per script.

I got around the line limit by writing more logic in a single line. For example, instead of this logic taking two lines

Code:
If PartData_Page > 4 Then
PartData_Page = 0
make it one line
Code:
If PartData_Page > 4 Then PartData_Page = 0
It might be little less readable, but I can get more logic in fewer lines.

As for trying the Siemens scripts that I referenced in an earlier post; no, I have not tried them. I finished my time logic before I found those.

Rack Failure:
I am pleased to hear you got something to work.
 

Similar Topics

Hi , I am working on Siemens CPU 315-2DP(6es7315-2af03-0ab0) while working online i try to modify bool value memory address M33.3,M34.0 but it is...
Replies
1
Views
2,340
So I know that in RSLogix 5000 you can use a tag in place of a static number in an argument of any instruction. For example... If I wanted to...
Replies
14
Views
3,480
Dear all, I'm trying to figure out the following situation: A PT-100 temperature sensor is measuring water. When I measure the water temperature...
Replies
17
Views
6,245
Dear All, I’m using S7-300. I need to scale an output value for a valve open control. I have an I/O field on my SCADA (WinCC v6.0) where an...
Replies
1
Views
2,058
I am try to do this task: write FC1 that would read from analog input (analog input = tw). The output of the FC1 will be downloaded/read/recorded...
Replies
5
Views
2,871
Back
Top Bottom