Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

read and write

Hey guys,

 

I am fairly new to LabVIEW so bear with me. I am trying to communicate with a scale (http://us.ohaus.com/us/en/home/products/product-families/EX-US.aspx), I send a command to the scale and want a response. I have tried two different methods; I used VISA's where I configured -> write -> read -> close VISA, and also used the Instrument I/O function. So far I am only able to write a tare command to the scale using the Instrument I/O function. I am unable to read anything from the scale, or write anything with VISA's. Also, the scale has drivers that use VISA's that should be able to read and write, however when I run the program nothing happens, not even an error message.

 

All of the settings for baud rate, etc. are correct for both the PC and scale. MAX tells me that the device is working properly. The correct COM ports are being used. I do not understand why the instrument I/O will write (do not know how to read from this) but the vi's with the VISA (including the driver) will not read or write.

 

Thanks for the help

0 Kudos
Message 1 of 10
(4,950 Views)
Do you mean the Instrument Assistant? That uses the VISA functions so your code must be doing something different. Are you sending the correct termination character?

MAX tells you nothing about your device or the connection
0 Kudos
Message 2 of 10
(4,948 Views)

Yea sorry the Instrument Assistant, and yes I am putting in the correct termination key. When I try to send a command using VISA Write, it does not do anything. When I try and send a print command and use VISA read to get a response, the VI times out.

 

Thanks

0 Kudos
Message 3 of 10
(4,922 Views)

You should attach what you have written. A common mistake made is not turning on '\' Code Display when you use a \n or \r for a termination character. If you were to use the simple serial example, the string control is set correctly for \ codes.

Message 4 of 10
(4,920 Views)

So I have tried a few other things to get the scale to talk to LabVIEW. The manufacturer gave me some pre-made VI's that I have attached. When i ask for a measurement reading (with ohepvp Read Measurement) it gives a value the first time, but the second time it gives a 0.00 value with "enter" displayed in the units field, then a reading the third time, etc.. Also, the reading is not correct it gives a reading for a previous weight value, as if it is reading from a stored data set. I am using the correct cables with a virtual serial port and the correct settings. Also, sometimes it gives me an error code for certain VI's and sometimes it does not. I have attached all the VI's I have. I do not understand why sometimes I can get it to work and other times it will not

Download All
0 Kudos
Message 5 of 10
(4,870 Views)

Also, on the last attachment OHAUS.vi, I made my own code by modeling the code that was given to me by the manufacturer. You can see which is mine and which is the manufacturers in the block diagram. For some reason the manufacturers code works and mine does not, even though it looks the same. Except now I switched cables and the measurement VI works but now the OHAUS.vi will not work at all

0 Kudos
Message 6 of 10
(4,867 Views)

Greetings;

 

When you say the measurement VI works, does it give you data every time now and no errors? In addition, when you say you switched cables, what do you mean? Did you switch the way things were wired, or simply used a different cable this time?

 

Finally, did it give a real value the first time, then zero, and then it proceeded to give you incorrect values every time?

 

Simon Perez

Applications Engineer

National Instruments

National Instruments
Applications Engineer
0 Kudos
Message 7 of 10
(4,823 Views)

So I realized my last response was pretty vague and unorganized, I will clear some things up. All I want to do is to be able to zero a scale and get real time mass values from it. The main issue I am having is getting the VISA commands to consistently work with the scale. It seems that when I use the Instrument I/O Assistant (if I first use a VISA Close command so the instrument is not "busy") and then send a zero command in the add parameter field, it will not work the first time, but every time after that I am able to consistently zero the scale. With the VISA commands however, once I get it working and then leave or work on another VI and go back, sometimes it stops working. Sometimes if I cannot get the VISA commands to work, I can use an Instr I/O Asst (in the same VI) and once that works sometimes my VISA commands will start working. I have read a lot of literature and am having a tough time understanding why sometimes I can get VISA's to work, and sometimes they will not work. I have attached 2 VI's that I made to zero and take measurements. During these problems I have been using the same cable as well as instrument/computer settings

 

Thanks in advance

Download All
0 Kudos
Message 8 of 10
(4,817 Views)

Why are you sending a LF and then a CR after each command? In the assistant, you are only appending a LF.

0 Kudos
Message 9 of 10
(4,791 Views)

one of the examples VI's had a carraige return, but I had never included it. I modeled the same example that they had for the OHAUS vi. I just tested it and it works both ways

0 Kudos
Message 10 of 10
(4,786 Views)