LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reading hex commands from file & parsing to visa write

I have this working but not in the way I wanted to.  I had a spreadsheet parsed down to each hex command for a sainsmart usb relay.  Any time I put the hex values through a case structure, they would revert to..something else.  "normal view" would show hex, "hex view" would show these strange values.  I ended up keeping the whole array as a constant, not the smartest method.  What am I doing wrong here?

 

Oh...the simple comparison also doesn't work, even though they look exactly the same in a probe.  Ugh!

 

Thanks,
Jim

Download All
0 Kudos
Message 1 of 3
(706 Views)

The missing piece of the puzzle that is causing all this confusion is the ASCII equivalents and HEX values.

 

For example,

"3A46" = 0x33, 0x41, 0x34, 0x36

 

santo_13_0-1634588925462.png

 

You intend to send 0x3A46 to VISA but instead, you're writing 0x33413436 to VISA because you're treating the value as a string instead of an integer.

 

Solution - convert the string to an equivalent integer, then covert them to string (of course not readable and gibberish) then pass it to VISA write

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 3
(698 Views)

Where to begin:

  1. Your structure in the upper left corner is working on a 2-D Array of Strings when you have below a 1D Array of strings
  2. Uncertain how you entered the data in the file, but it is looking for a "," {Comma} as the delimiter for how the entries are separated for each row in the 2-D output and I do not see any commas in your entries.
  3. Each line in your table contains a carriage return and line feed which allows for the correct use of the VISA Write.  It is just coincidence that all of your entries, except the last two are 17 characters long (15 + <CR> & <LF>).  Based upon how you read the data (Communication settings) will determine if you are to acquire the <CR> & <LF> characters if you were to increase the #15 to something large enough to handle all messages like #200 you might get a successful return.
Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
0 Kudos
Message 3 of 3
(688 Views)