Save information every 6 seconds in the database

hello I have an expression tag and I need it to save the information every 6 seconds.

in my expression I have the following

getSecond(now(1000))

and in the tag event in value changed

I have the following

if currentValue.value != previousValue.value:
					INS = "INSERT INTO RF_HISTORY (DATE, RF_ID, NUM) VALUES (?, ?, ?)"
				
					Contador = system.tag.read("[.]contadorPorScript")
					Fecha = system.date.now()
				
					system.db.runPrepUpdate(INS,[Fecha,"Linea_Disco",Contador.value],"TOPY_MW")
				
					system.tag.write("[.]contadorPorScript",0)

The simpler solution is to turn on history with minimum time between samples of 6 seconds. Also possibly a transaction group set to a 6 second interval.

1 Like

I have not used this tool, do you have an example?

floor(getSecond(now())/6) would help your expression change every six seconds.

https://inductiveuniversity.com/courses/tag-historian-in-ignition/8.0

and

https://inductiveuniversity.com/courses/transaction-groups-in-ignition/8.0

can get you started. I recommend going through the whole catalog of courses at some point.

2 Likes