Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

USB RAW Driver help with hexadecimal input

I need to write a driver for a controller that uses usb as interface. i was
able to use NI_VISA to make the device show in lab labview .

I need now to use VISA vi's in ordor to write and read from the controller.
However the instructions that came with the device are in hexadecimal . so
I'm not sure what the best to use . below are some instruction from the
company who made the controller :



General instructions in the sheet :

"All packets are 19 bytes long in both directions.

Byte 0

Byte 1 Command code

Byte 2 Receive number of reply data bytes + 2 (1 command echo, 1 length
byte) bytes.

Byte 3 through 18 Are command optional data bytes. Unused bytes are
undefined"



some commands in the sheet

"

1.

  Send 0x00 0x00 0x00

  Receive 0x00 0x00 0x02

 
4. 

  Send 0x00 0x02 0x02

  Receive 0x00 0x02 0x04 R3 R4

  // Reports the current focus

  R3 LS byte

  R4 MS byte

"

any idea how this can be done , or if you can tell me what are the right Vi's to use ?

Thanks

0 Kudos
Message 1 of 6
(3,750 Views)

Hi

Hex is just another way to display characters. In labview you can show in hex, or normal or password, or / codes. The string remains internally the same but displays different. Anyhow internaly it stays binary.

 

In your case use a string and build it up according the command. Don't bother about the representation but only about the content.

You also could built a command in 8 bit values and then convert the U8 array into a string.

greetings from the Netherlands
0 Kudos
Message 2 of 6
(3,733 Views)

do mean i should use a string constant and make it display as HEX and then put what i should send ?

for example in the first function above : send 0000 00 ? 

here is other problem i'm not sure about , when i change to hex dispaly, the string starts clustering numbers in 4 digit numbers , so i'm not sure if the four digits means 1 byte ot 2 ?

 

could u help in this ?

0 Kudos
Message 3 of 6
(3,725 Views)

Either use a string constant or an array of U8's.

 

If you have 4 digits, then that represents 2 bytes. Have you studied hex representation? A single byte in binary can be anything between 00000000 and 11111111. In hex, that is anything between 00 and FF.

 

What function are you planning on using to do the writes and reads. For USB RAW, besides the VISA and VISA Read, you have the control pipe functions. What does the manual say that you are supposed to use for a transfer protocol?

0 Kudos
Message 4 of 6
(3,722 Views)

i'm trying to use Visa write to write and use the interupt vi to read events ?

 

the manual doesnot say antything about what to use , it is a list of functions (send/receive ) , and it also says it is HID class functions .

 

I'm trying to do same in this thread

http://forums.ni.com/t5/LabVIEW/USB-Raw-interrupt-Data-Rate-between-USB-Raw-Device-and-Labview/m-p/9...

 

 

do think i'm going in the right direction ?

 

 

0 Kudos
Message 5 of 6
(3,719 Views)

If it uses HID classes, then you should probably be using the HID.dll instead of trying to create your own driver. I would suggest the series of USB Nuggets by Intaris.

0 Kudos
Message 6 of 6
(3,717 Views)