Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Using VISA Write to input a hex shortcut

Hi,
I am communicating over a serial port with another device.
This device requires hex shortcuts where the most significan byte has been set.
Example: 0xA6 10100110
 
I want to use VISA Write to send this to my device. VISA Write takes a string, but if I try to write in A6 (in hex display for instance) this is not understood by my device.
 
Any ideas what I may be doing wrong?
0 Kudos
Message 1 of 7
(3,757 Views)
I suppose your are sending order to your device with a string mode as follow :
    viPrintf (GPIB_ID, command);
where command is your string.


You should write directly on the GPIB bus the byte in binary mode :
    viWrite(GPIB_ID, (ViBuf) buffer, lSize, &actual);
buffer is your byte array,, lsize the number of bytr you are goind to send on the bus.
0 Kudos
Message 2 of 7
(3,740 Views)
If you are using C language, type \xA6 in the string to send.  This is control char expression of standard C languages.
0 Kudos
Message 3 of 7
(3,730 Views)
I don't nd messages to the device in a c environment, I am using LabVIEW's VISA Write vi.
The problem is that this vi takes an input string, and I have not found a way of manipulating this string so that it sends over the command I would like it to.
 
As it is a case of putting the right data into the buffer, this should be possible (?)
0 Kudos
Message 4 of 7
(3,719 Views)
In LabVIEW You can change the string control (right mouse click) to show hex or pasword setting or /codes and even normal view.
In this mode you also can type in HEX.

Remember
 Instruments that want hex strings normally don't want what is in the manual but a binary value that in the manual is typed in hex representation.

So put your control in hex mode and try it with your instrument.



greetings from the Netherlands
Message 5 of 7
(3,706 Views)

I have tried putting the input string into hex mode and writing my code there (in HEX). This doesn't work.

As far as I know, I cannot change VISA Write to work in another mode, som I'm still stuck.

0 Kudos
Message 6 of 7
(3,668 Views)
Setting the string control for hex display or using the Byte Array to String is the correct method and does work. Could you perhaps post the manual for the device your are trying to communicate to and the code you've written. With the two of them, it's possible that someone can see what is wrong. Do you have any code from the vendor to verify that communication is working at all? There could also be a problem with the com settings or you could have the wrong type of serial cable.
0 Kudos
Message 7 of 7
(3,664 Views)