LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can you trigger data acquisition through Modbus TCP/IP PLC communication without using a for loop?

Solved!
Go to solution

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?

0 Kudos
Message 1 of 5
(3,178 Views)

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

0 Kudos
Message 2 of 5
(3,155 Views)

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

0 Kudos
Message 3 of 5
(3,139 Views)
Solution
Accepted by topic author Joaquin.88

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

 

0 Kudos
Message 4 of 5
(3,114 Views)

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.

0 Kudos
Message 5 of 5
(3,104 Views)