Using Indusoft VbSctript to insert a line into MySql once every five seconds

I have used the Siemens Snap7 driver with AdvancedHMI and it works great.

It's just with this project, I have to use Indusoft so I am going with the VbScript.

The project that I used AdvancedHMI had CompactLogix and FactoryTalk View SE for the HMI software.

In order to get the PLC data into MySql I had to go with AdvancedHMI which I really liked working with.
 
It's funny I have the exact same MySql database and data using AdvancedHMI and a CompactLogix PLC.
I use the timer tick function with a 5 second time, it will run for ten hours with no drift at all.

For this project I had to go with a S7-1200 PLC, so I couldn't use AdvancedHMI
Hence the learning curve I am having with the Indusoft and VbScript....
Was it the Timer.Tick call in the AdvancedHMI (Windows PC) or the CompactLogix? Because in that case it is set to autorepeat by default and simply issues an event at each timer expiry, which causes your callback to do something else.That is similar to using the free-running clock in the drift-free examples on Github. Also, the callback is probably creating the timestamp from the Windows clock i.e. that same clock that is issuing an event every 5000ms, so it is self-consistent i.e. no drift; whether it is drifting relative to atomic time, with or without NTP, is another question entirely.

The the callback does not restart the timer, which restart-during-the-callback would be where any drift would occur, analogous to a self-resetting TON in a PLC.

P.S. there is an Ultra-Stable Oscillator (USO) on the New Horizons (NH) spacecraft, used for the Radio Science Experiment to measure phase shift in GHz signals from earth as the line of sight passed through the atmosphere of Pluto. That clock loses about a millisecond per day relative to "real" (atomic) time and is also used for onboard timekeeping; the drift is less important than its stability. The interesting thing (to me) is that that millisecond or so per day is very close to the difference between the earth's rotation and orbit i.e. sidereal time, and atomic time. So since launch, the NH clock has been within a second of a constant offset from UTC, because UTC adds leapseconds every so often to stay within a second of the earth's rotation.
 
Last edited:
I still recommend having the PLC send the data to SQL. This ensures the correct values and very precise time stamps. Load a FIFO on whatever interval you choose. When there is data, you increment a counter, unload the FIFO to registers, use the counter value change in the SCADA to read the registers and send to SQL... rinse and repeat. This technique has a built in buffer. Depending on how big of a FIFO stack you can store data and then blast it to SQL when ready.

What is the purpose for every 5 seconds? Looking at your table, the only change was the timestamp. Why not use historian and store on change?
 
Thanks Phrog,
I have never done a fifo with a Siemens PLC so I will definitely give that a try.

As for the 5 seconds, you are correct nothing changes...... this is an aerospace company so all our processes are logged at 5 second intervals. We have a tank with a 1000 Gallons of chemical in it. We measure the temperature every 5 seconds.....
I asked if we could measure it every minute, the answer was something could happen in between. I asked like what? besides the timestamp
 
I asked if we could measure it every minute, the answer was something could happen in between.
But something could just as easily happen between 5 seconds. I would do the best of both worlds, log on an interval, say every minute, but then also log on change. Doesn't Indusoft have historian? Why not use it, instead of logging yourself?
 
The thermal inertia of 1000gal of a typical liquid ensures its temperature is not going to change much in 5s unless it is being actively heated or cooled and/or mixed. We could drop a bucket of ice cubes in and, unless they were dropped near the sensor, we would not see a measurable change for some time that we could attribute to the ice.



Someone is not exactly aware how the physical world works.
 
looking at the printout of the logging it appears only to change by 1 second, is the date/time stamp generated by the SQL insert or is it from the plc etc. 1 second could be the difference of a few ms assume the data was generated at 11:33:05.090 then due to the update time or OPC doing it's timeshare in all applications would be 11:33:06.000 for example is 1 second important as stated before, to change temperature in 5 seconds is probably unlikely in less than 1 second I doubt it.
 

Similar Topics

I am using VbScript in Indusoft to insert data into a MySql database. Immediately after inserting a row, I need to know what that row number is...
Replies
24
Views
5,288
I am working on a project where I need to accumulate the amout of Runtime of a machine. I am presently able to display the length of the "Current...
Replies
0
Views
3,176
I'm trying to control a device via MODBUS RTU and the ModbusRtuMasterV2_PcCOM in Twincat 3. I've configured a device with the right com port and...
Replies
6
Views
134
Hi, I'm trying to use the IO Device Library (Product Versions) which is configured to work with the 1756-EN4TR & 1756-EN2TR but my system uses...
Replies
0
Views
48
Hello, As part of our project, we are using an M241 controller. This controller interfaces with an industrial computer and a router via a switch...
Replies
2
Views
89
Back
Top Bottom