LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA writing/reading problems

Try this using the Hexadecimal String to Numbers function in the Strings palette.

 

hex to decimal conversion.png

 

 

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 11 of 18
(1,576 Views)

I have tried this method before, and it always seems to return just an empty string on the "number" terminal.

 

Attached is a zip archive with my main VI (Wavelength Finder) and the necessary subVIs. The two text files are just there to demonstrate the look-up table function.

---------------------------------------------------------------------
LabVIEW 2013, Windows 7

He who asks the question is a fool for five minutes; he who does not ask the question remains a fool forever.
0 Kudos
Message 12 of 18
(1,561 Views)

This external unit probably requires a termination character such as CRLF based on your written data string.  "\n" will not work.  You must append an End of Line constant (Strings palette) to your data using the concatenate function.

 

concat string.png

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 13 of 18
(1,554 Views)

@MoReese wrote:

{...} You must append an End of Line constant (Strings palette) to your data using the concatenate function.

 


 

Or \r\n (in codes display)

 

Richard






0 Kudos
Message 14 of 18
(1,551 Views)

I am using \n in codes display because that is the code for a line feed I assumed I could just use that as an end of line character, but if it's not the bestpractice, I'll change it to \r\n. Incidentally, if you look in the "finding" case, you should see that I already used the "concatenate" function to put line feeds at the end of each "set" command before it's sent. I have changed this in a later version, which I'll attach to a post in a few minutes. (Sorry it's taking me so long to reply to these, by the way, but the computer I'm coding on is in a separate room with no internet access.)

 

Now though, I have been able to access a different model external unit with the same purpose. The programming pages in the manuals for both machines are pretty much identical, but sending exactly the same commands to it in exactly the same way, it now responds in the way I'd expect. The problem of transmitting commands, therefore, seems to be solved (after a fashion). I still need to convert the string coming out of the machine into decimal though. I have tried using Hex string to number function and using type cast and scan string... none of them seem to achieve what I want. I'm wondering now if the device is outputting hex at all, as when I probe the values returned after I set a new piezo voltage, for example, the values it shows are ASCII. I just put the relevant indicators on hex so I could understand what's going on better.

 

If the values coming out are ASCII, how can I get them into decimal?

---------------------------------------------------------------------
LabVIEW 2013, Windows 7

He who asks the question is a fool for five minutes; he who does not ask the question remains a fool forever.
0 Kudos
Message 15 of 18
(1,545 Views)

@MattA1 wrote:

[...] 

If the values coming out are ASCII, how can I get them into decimal?



Typically, with the String to Byte Array function:
Richard






0 Kudos
Message 16 of 18
(1,538 Views)

Ok, here's the updated version of the VI and all its subs. There's a new one; SETP which shows how I'm dealing with setting one of the parameters and then getting the new value afterwards. I'm not entirely happy with having the time lags in there, but taking them out seems to confuse the device.

 

Hmm. Thanks for the tip, Arrow, I'll look that up. It's on the string palette?

---------------------------------------------------------------------
LabVIEW 2013, Windows 7

He who asks the question is a fool for five minutes; he who does not ask the question remains a fool forever.
0 Kudos
Message 17 of 18
(1,536 Views)

@MattA1 wrote:

Hmm. Thanks for the tip, Arrow, I'll look that up. It's on the string palette?


SBA.png

Richard






Message 18 of 18
(1,533 Views)