08-07-2013 02:06 PM
Hello,
I am trying to communicate with a facility plc through Modbus TCP/IP communication. I am new to this method but the idea is that the facility will send logical (boolean) 1 bit values over ethernet to my workstation which read it and will then begin data acquisition. Essentially I just need a triger to come to my pc. I have placed my data acquisition vi inside a T/F case structure which will execute depending on the signal it receives. However, to have it constantly waiting, I put all of that into a for loop. The vi works but the reading of the signals sometimes lags due to the for loop. If I take the for loop out and just run labview continuously it works perfectly but I know that option is only for debugging and should not be used. So my question is, Is there a better way to wait for an incoming signal?
Solved! Go to Solution.
08-08-2013 01:07 AM
It's not clear to me how the data acquisition is triggered.
the PLC set a modbus register to a given value?
Or is it sending non-modbus data over the connection?
The for loop shouldn't slow down your code if properly timed
Can you send a snippet of your code?
Regards,
Marco
08-12-2013 12:03 PM
Hello,
I am using the modbus tcp/ip I/O library and the trigger is a boolean which is to be read from the plc. I have tried the communication within two computers (mine being the slave) and I think the problem there was that since both had a while loop they were out of sync. Also I have not put in a delay, do you think that is necessary and how much of a delay? I have attached a copy of my VI to this post. Thank you
Joaquin
08-19-2013 07:06 AM - edited 08-19-2013 07:06 AM
Hi!
Please note that the execution order of the write operations on the shared variable 000002 is not determined.
For instance nothing prevents this execution order:
1) Set 000002 to false
2) Set 000002 to true
3) Execute for loop
As for the delay, you could consider to place a wait vi in the "false" case, or the while loop will use 100% of CPU if I'm not mistaken...
Regards,
Marco
08-19-2013 09:42 AM
Ok. I think also the problem was that I was testing the communication using two computers and therefore I had two programs running in a for loop. I think that since they were out of sync, it caused a delay. Thank you for the feedback. I will also implement your suggested changes to improve my program.