Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading TCP not blocking the program on myRIO

Hi, I need your help next time. I'm making ball balancing platform. So, I have a program running on PC, where camera observes the ball, finds his position and sends it via TCP to a myRIO, which read the messages and controls the engine using PID regulator. The problem is, that to read the message there is needed timeout in reading block, and it makes my system not stable. I need to run the program with regulator and not wait for coordinates. I need something like an interrupt but I've no idea how to do it on myRIO. 

 

On the photo below I show the part of program receiving the message. First block check if received coordinate "x" or "y" and second get the value.

danielll99_0-1636931512593.png

 

0 Kudos
Message 1 of 7
(2,273 Views)

Build a separate while loop in which you try a read tcpip.

If timeout occurs just remove the error and try again

In case of a real message send it via a queue to your program to handle the message.

Don't forget to close the while when the proram needs to finish.

So you need a few commands to your while, maybe do this in a functional global.

You can find info on functional globals in lava.org

 

greetings from the Netherlands
0 Kudos
Message 2 of 7
(2,251 Views)

Sorry, but I don't understand how it can help me. Building a separate loop you mean to do something like on the photo below and communicate these loops using interrupts? It's possible t have two loopd? The program shows error that the loop is not connected. 

danielll99_0-1637102151553.png

To precise I need to change PWM of engines in time of waiting for message with timeot, because just one second of delay make my system not stable.

I put also my VIs in attachment.

Download All
0 Kudos
Message 3 of 7
(2,223 Views)

The idea is indeed correct but you miss parts of the implementation.

First problem you say interrupts I said Queues.

 

Second problem. Your while loop has an unconnected condition terminal.

 

I will answer more tomorrow when I have looked at your vi's

greetings from the Netherlands
0 Kudos
Message 4 of 7
(2,212 Views)

Hi

Just to show you I did not forget you.

I have a first implementation ready for testing by you.

In fact a functional global, it is a vi that keeps information in its shift registers and should be called just like in my test example.

A few type definitions of enums accompany this functional global and the test vi.

 

No error handling yet. In case of a TCP timeout you have to decide what to do and fill that in in the functional global.

I can help you if you secify what to do in that case. close and reopen is a possibility.

 

 

greetings from the Netherlands
0 Kudos
Message 5 of 7
(2,200 Views)

Thaks. I've managed to communicate without delay on myRio when I start the transmission on microcontroller. The consequence is that on the PC I've timeout but that's not big problem so now I'm able to create stable system.

0 Kudos
Message 6 of 7
(2,182 Views)

Congratulations

and you have learned a for you new way of programming in LabVIEW.

greetings from the Netherlands
0 Kudos
Message 7 of 7
(2,178 Views)