From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA read

Solved!
Go to solution

Hello.

 

I've been working on a project where I deploy multiple nodes w/ Arduino and XBee. The nodes sends a string to the base station every 8 seconds. I am using the VISA function in LabVIEW. If the sent string is matched, a boolean indicator will turn on. This shows that the node is still connected on the network. However, I dont know how to implement such troubleshooting where if LabVIEW hasn't detect the string of the node after 8 seconds, it will automatically prompt the user to check the specific node.

 

I really need some help in this situation. Thank you so much!

0 Kudos
Message 1 of 8
(2,734 Views)

Do you mean that if LabVIEW didn't get string sent from node within 8sec, had LabVIEW fire an Error?

 

If so, you can set "Timeout" property on VISA.

VISA Read or Write Timeout Error -1073807339

 

 

Certified LabVIEW Developer
There are only two ways to tell somebody thanks: Kudos and Marked Solutions

GCentral
0 Kudos
Message 2 of 8
(2,729 Views)

Most probably.

There will be 16 nodes to be deployed. Each node sends a string of 1A0/1 ---> 1H0/1 and 2A0/1--->2H0/1. The string signifies the Zone address, Node address, and alarm state (0 for no alarm/connectivity check and viceversa).

LabVIEW acts as the base station. It receives all the strings asynchronously. Based on the image below, the (SD) is a subvi that matches the string received from the different nodes. The 1A1 boolean is for 1A1 string and below is for 1A0 and it goes on. 

The nodes are programmed to send 1A0 every 8 seconds therefore the boolean turns on every 8 seconds depending on the string the comes first. However, my problem is what if a node didn't send the string or LabVIEW haven't received the expected string to the corresponding node after 8 sec. LabVIEW should notify the user that there might be a problem to the node that was unable to send the string. 

0 Kudos
Message 3 of 8
(2,713 Views)

1. DO NOT USE THE ABORT BUTTON.  Add a way to properly shut down your application, including closing your VISA Session.

2. DO NOT USE THE BYTES AT PORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  You expect 3 bytes in a message.  So just always read 3 bytes or, if your device is sending one, use the termination character to stop the read (try to read more bytes than you ever expect in a message and let the VISA Read stop reading when it reads the termination character).

3. You might want to have a look at the Elaspsed Time Express VI.  It can add the delay time you need when when to turn off the LEDs.

4. You should also consider moving your serial interface into a parallel loop and use a Queue or User Event to send the data on to your main loop.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 8
(2,706 Views)

1. I have already added VISA close with Simple error handler.
2. How do you propose on reading the 3 bytes or  using the termination character?

3. Yes, I'm in the process of implementing the Elapsed Time Express VI.

4. If I'll use the Queue with a parallel loop, will it make the system more simpler? I haven't use the Queue function yet.

0 Kudos
Message 5 of 8
(2,682 Views)

@PJason wrote:

2. How do you propose on reading the 3 bytes or  using the termination character?


Just wire a constant to the VISA Read.  If there is no termination character, just wire a 3 to the number of bytes to read.  If there is a termination character, then use a number larger than any message you expect to read.

 


@PJason wrote:

4. If I'll use the Queue with a parallel loop, will it make the system more simpler? I haven't use the Queue function yet.


Yes, things will be simpler because of modularity.  It is a way of breaking down the problem into smaller problems that are much simpler to solve.  You might want to read up on the Producer/Consumer.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 8
(2,675 Views)

Just to avoid Queuing, what if I store the data in a 1D array then I have a process that searches the current element from the newly stored data. If it can't locate from the newly stored data then there will another process.

 

Would that work?

0 Kudos
Message 7 of 8
(2,640 Views)
Solution
Accepted by topic author PJason

@PJason wrote:

Just to avoid Queuing, what if I store the data in a 1D array then I have a process that searches the current element from the newly stored data. If it can't locate from the newly stored data then there will another process.

 

Would that work?


What you are describing sounds a lot like a queue.  Seriously, dig through the help files and examples.  You will want to be using a Queue.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 8
(2,632 Views)