Numeric Text Field

Im trying to set a timer period in a Siemens program through a numeric text field.

Can ignition convert an input in say seconds into s5time format ?

What does s5time format look like?

The S5Time is a BCD word with a time unit in the highest byte, but in almost any case i know the OPC Server does this conversion for you (The Ignition Siemens driver definitely does so).

Do you know what settings have to be set or chosen, in regards to the tag settings and input box settings?

If you are using the Ignition OPC-UA server, this is in the manual here: inductiveautomation.com/supp … ssing2.htm.
Look for the ‘Timer’ description.
Your input box has to return the time in milliseconds (it is also possible to use scaling in the tag), the driver does the conversion to and from the S5Time format.

Sorry, i ckecked this again and realized i was wrong. The Ignition Siemens driver supports timer adresses but no timer data type. So you can read the value of a timer, but you can not write a S5Time value to a memory adress.
It is possible to convert the value using an expression tag and write it in word format, but it seems there is no built in way for this.
I was confused by the manual talking about ‘writing’ to a timer, what really makes no sense.

An expression tag with the following expression should work:

// Convert input value to BCD
floor( {[.]InputVal}/100) * 0x100 
+
floor( ({[.]InputVal}%100)/10) * 0x10 
+
floor({[.]InputVal}%10)
+
// 0x1000	// Time base 1/10s
0x2000 // Time base 1s
// 0x3000 // Time base 10s

In the expression tag, check the ‘write back to opc’ option to write the value to your plc. The InputVal referenced in the expression is an additional memory tag bound to the value of your numeric text field.

So the Operator can use HMI to change S5 Timer set point to a value that meets the process I use an FC Block: FC100 - INT to S5T#. This FC allows

you to enter an Integer and have it converted in the PLC to S5Time Format.

This FC was not included with the S7 Standard Libraries files. I found it in an application called Blokke.zip (Downloaded from internet).
Here is a link to the web site and page: plcman.co.uk/plcfiles/
This link will take you to A web page “PLC - Files” Click on link “SIEMENS S7”.
On the S7 FILES page download file: Blokke - Selection of useful FC’s & FB’s by Jan Steen Nielsen.

To be able to read S5Time data in Ignition we wrote a script in the Script Module under the Project Dropdown:

# This takes a Step5Time datatype and converts it into seconds
def StepFiveTime(StepFiveTimeTag):
	import system
	import time
	
	#Get the Step5Time Tag Value
	qv = system.tag.read(StepFiveTimeTag)
	
	#Convery Step5Time Integer to 14 bit binary representation
	binstring = ''.join(str(1 & int(qv.value) >> i) for i in range(14)[::-1])
	
	#Get the time base string
	base = binstring[:2]
	
	#Get the ones unit string
	intone = binstring[10:14]
	ones = int(intone[0])*8 + int(intone[1])*4 +int(intone[2])*2 +int(intone[3])
	
	#Get the tens unit string
	inttwo = binstring[6:10]
	tens = int(inttwo[0])*8 + int(inttwo[1])*4 +int(inttwo[2])*2 +int(inttwo[3])
	
	#Get the hundreds unit string
	intthree = binstring[2:6]
	hundreds= int(intthree[0])*8 + int(intthree[1])*4 +int(intthree[2])*2 +int(intthree[3])
	
	#Calculate the time integer value
	integervalue = ones + (tens*10) + hundreds*100
	
	#Convert time integer value to seconds
	if base == '11':
		integervalue = integervalue * 10
	elif base == '00':
		integervalue = integervalue / 100
	elif base == '01':
		integervalue = integervalue / 10
	
	
	#Convert Seconds to a time format			
	thetime = time.strftime('%H:%M:%S', time.gmtime(integervalue))
	
	
	#Return Time in normal format.
	#debugging string# return 'String is ' + binstring + ' Base is' + base + ' final int ' + intone + ' ' + str(ones) + ' ' + inttwo+ ' ' + str(tens) 

+ ' '+ intthree + ' ' + str(hundreds) + ' TADA ' + str(integervalue) + ' Time left ' + str(thetime)
	return thetime

Set up S5 Timer BCD accumulator linked to a DB Address STRUCT as WORD in the PLC (Example: DB11.DBW18).
Setup tag in Ignition as Data Type Int2. Leave Metadata/Format String blank.
Example Tag: PAE_HMI_TestT5_BCD_ACC is Data Type Int2 - [Power]DB11,W18

To Display the timer accumulator data in a “Label” in Ignition, setup this script in the label Text binding expression:
runScript(“app.Global.StepFiveTime(’[]Power/PAE_HMI_TestT5_BCD_ACC’)”,1000)

The script will run the global script displayed above with the timer accumulator tag and count down the timer ACC value.

Setup Label text as 00:00:00 - this will be displayed as hh:mm:ss

2 Likes