Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

ASCII commands through USB

Solved!
Go to solution

Hello,

 

I am currently trying to communicate to a load cell indicator (Omega DFG-RS3) using Labview to continuously stream data. I am new to using the VISA functions within Labview as well as trying to communicate with other devices that are not NI devices.

 

Through reading the documentation of the load cell indicator, it reads, "For continuous output, the indicator also responds to the ASCII command '?' (no quotes), terminated with a Carriage Return character or with a Carriage Return/Line Feed combination. The indicator's responses are always terminated with a Carriage Return/Line Feed. Any detected errors are reported back by means of error code *10 (illegal command)."

 

I have been able to communicate with the device through terminal emulators and outputted values and know that I am currently communicating the the device in Labview.  I think I am getting hung up on code being sent to the device. Any direction would be much appreciated. Thanks!

 

Nick

 

0 Kudos
Message 1 of 5
(7,144 Views)

First of all, that outer While loop just makes your VI run forever.  Get rid of it.

 

Secondly, you should not open and close your serial port with every transaction.  You don't even need the VISA Open since the Configure Serial Port does all of that for you.  Then move the Close VISA Session out of the loop.

 

Now for the important thing.  That output of the VISA Write is how many characters you wrote.  I seriously doubt you only want to read 2 or 3 characters.  So it makes no sense to wire the number of character written to the number of characters to write.  But you are using the termination character.  So what you do it set the number of bytes to read to something way more than you expect back from your instrument.  The VISA Read will read and return up to the number of characters you asked for, the termination character is found, or a timeout happened.

 

Here's how I would have set this up.

 


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 2 of 5
(7,139 Views)

Thank you for the suggestions and tips! I have modified my program with your suggestions. It runs with no erros, but I am still getting nothing in the output. I have tried different strings to write to the device including: ?\r, ?\r\n, and ?\n.  I will get a *51 in the output every once in a while.... The load cell indicator is also set up to send a the current reading (not continuously) if you press a specified button. While I am running the program, if I press this button, the correct reading does show up in Labview. The only thing I can think of is that my input I am writing to the device is incorrect? Thanks again for the program structuring pointers!

 

Nick

0 Kudos
Message 3 of 5
(7,132 Views)

I am starting to think the string I am sending it is correct. I opened the serial port in the measurement & Automation Explorer. When I am in the viWrite tab, I wrote ?\r\n in the buffer line and executed it. I then went to the viRead tab and executed that and recieved the correct output in buffer... Would this now be a function of time? or does the VISA read block wait for a signal from the serial port to be recieved?

 

Thanks, Nick

0 Kudos
Message 4 of 5
(7,124 Views)
Solution
Accepted by topic author archimedes

I found my problem. I needed to change the write buffer to '\' codes display. It seems to be working well.  Thanks for the help again.

 

Nick

0 Kudos
Message 5 of 5
(7,117 Views)