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,543 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,532 Views)

Hi mkossman

 

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

0 Kudos
Message 3 of 5
(3,525 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,515 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,499 Views)