From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

GPIB 16 bit signed integer conversion

Hi

 

I'm writing a program to acquire data from a SR 830 lock-in amp. I'm using its "fast 2" mode which transfers data in the following way, according to the manual :

 

"The values of X and Y are transferred as signed integers, 2 bytes long (16 bits). X is
sent first followed by Y for a total of 4 bytes per sample. The values range from -32768
to 32767. The value ±30000 represents ±full scale (i.e. the sensitivity)."

 

To read the data I use the "Visa read" VI, which outputs the data in a string. When I display the string as is, I get all sorts of wierd characters.

 

So can anybody help me to convert this to useable data ?

 

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

One character is one byte. So you have to put two characters together and interpret them as one 16 bit integer. With Labwindows/CVI you can use Scan() for doing that ( there are examples in the help) .  If you are using another programming environment, please tell us , what you are using.   

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

Hi mkossman

 

Thanks for your answer. I'm using Labview 2009.

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

I searched for "scan", and found "scan value" and "scan from string". Which one should I use ?

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

none of those.

This is binary so you should convert by typecasting the string of two bytes to a I16.

 

greetings from the Netherlands
0 Kudos
Message 5 of 5
(3,486 Views)