about decimal to s5time

necyil

Member
Join Date
Nov 2004
Location
Turkey
Posts
102
Hello..

I need help.I make program with simatic7 300cpu.I use op5 and send from op to plc a data.This data must be decimal.But in plc must be input of a timer. How i convert s5time. Thanks for help.
necyil
 
OP to s5time: [FC1]
===========
L #REAL_IN //second
L 1.000000e+003
*R
RND //R-D
T #TMP_TIM //temp time
CALL FC40 //time to s5ti [FC40]
IN :=#TMP_TIM
RET_VAL:=#RET_VAL //OUT
==================
IEC TIME to s5time:[FC40]
===========
SET
SAVE
L 0
T #y_Base
L #IN
T #d_Temp
L 0
<D
JC FEHL
TAK
L L#9990000
<=D
JC LOP
L W#16#3999
JC FEHL
LOP: L #d_Temp
L L#10
/D
T #d_Temp
L L#999
<=D
JC FERT
L #y_Base
INC 1
T #y_Base
JU LOP
FERT: TAK
DTB
L #y_Base
SLW 12
OW
JU RET
FEHL: CLR
SAVE
RET: T #RET_VAL
BE
=======================
 
seconds to S5Time

Hi,

You can use the following:

1)Write with the OP the time (in seconds) in a PLC word.
2)Convert the word to double int.
3)Multiply by 1000 (if the time was in seconds). You get the time in ms.
4)Convert from TIME to S5Time using a function called TIM_S5TI FC40 that you can find in the library under IEC function blocks.

Best regards,
Kelkoon
 
the s5time is composed of 4 bits containing the time base and the time in bcd

u can do so :

can convet the the iw to bcd then set the bits of the time base according to the value
 
here u are

this is a program to convert minutes in integer to s5t format


L #minutes
L 15
>=I
= L 0.0


L #minutes
L 60
*I

A L 0.0
JCN x452
L 10
/I



x452: NOP 0

ITB
T #result


AN L 0.0
JCN x450
L #result
L W#16#2000
OW
T #result


x450: NOP 0

A L 0.0
JCN x451
L #result

L W#16#3000
OW
T #result


x451: NOP 0


if u need seconds or hours u will just need some small modifications on that
 

Similar Topics

In S7/TIA Portal, is there a function to round a real to a specified number of decimal places? e.g. If I have 22.519432 and I want to round it to...
Replies
16
Views
1,823
I am using a Micro 850E PLC (the new one with implicit messaging capability) to drive a Kinetix 5100 servo drive. The error code number on the...
Replies
7
Views
1,691
I'm using numeric input enable link tag to PLC DINT type. What I want is for the example in the panel view user will input 350.568 (and shown on...
Replies
1
Views
1,135
Hello, I have a SINT array I am receiving and one of the positions of this array contains the direction of the product. Inside the ladder...
Replies
4
Views
1,116
Hi, how do i include the fractional part of the position I set for encoder? I have an Omron PLC and using cx programmer. I need to command my...
Replies
16
Views
3,936
Back
Top Bottom