03-06-2024 03:55 PM
ok, attached a vi, for the interested reader.
03-06-2024 03:56 PM - edited 03-06-2024 04:01 PM
like so, works as a concept. I did 2 options, keep for 10 iterations and timestamp. If someone wants to use the snippet
03-06-2024 08:07 PM
Ah, what a mess. You certainly don't need a stack of loops for any of this. See if this can give you some ideas....
(What if there is a new value and it is the same as the previous value? Wouldn't that require a time update?)
03-06-2024 09:10 PM - edited 03-06-2024 09:12 PM
thanks!
(What if there is a new value and it is the same as the previous value? Wouldn't that require a time update?)
this is why I want to keep it for 1 s only. Sometime the master does not send a write for a few seconds and then continues again. This way I recorded that behavior as well.
This is why I put 2 things to try, timer and just count 10 iterations since last value change, then reset the latch. 1s will be enough, anything we log is in 1 s steps, so can reference things nicely. PLC and everything else in the line only cycles about 1 s or so anyway. Some of the read registers change, the response is 1 cycle later only anyway.
03-07-2024 09:52 AM
Why not write the Read and Writes to separate tables? The Write should just have the Timestamp and Value.
03-07-2024 02:27 PM
because then I have to merge 3 tables. Its much easier if they all run at the same frequency. I made it so the timestamp in SQL does not have milliseconds. Then I can align all the tables at full seconds. I just need to know what events are happening when. Can be hours worth of logs in 1 s intervals. And on top of it there could be the modbus log, which is endless as well
03-14-2024 01:32 AM
ok, did this
-if nothing is read, then set to 65535
-if something is read, put into shift register and send to SQL
-for 1.1s check if next array is empty, send content of shift register to SQL
-for 1.1s if some new value is read, populate shift register and send this to SQL
getting the result I wanted. Timestamp matches
time to go home.
03-14-2024 08:39 AM
@Steffen01 wrote:
getting the result I wanted. Timestamp matches
It is is hard to judge a highly truncated image, but...
03-14-2024 02:59 PM
-coercion dots because anything modbus is 16 bit unsigned
-the array is sometimes empty and sometimes its not. Because the modbus read happens at least once per second but the write just at random
-the 65535 is in the false statement. The first few lines in the SQL do not matter anyway, have to start the vi first and then start the modbus sniffer
thanks for all the help!