08-08-2011 12:53 PM - edited 08-08-2011 12:54 PM
Try this using the Hexadecimal String to Numbers function in the Strings palette.
08-09-2011 07:02 AM
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.
08-09-2011 07:54 AM
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.
08-09-2011 07:58 AM
@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)
08-09-2011 09:00 AM
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?
08-09-2011 09:09 AM
@MattA1 wrote:
[...]
If the values coming out are ASCII, how can I get them into decimal?
Typically, with the String to Byte Array function:
08-09-2011 09:13 AM
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?
08-09-2011 09:16 AM
@MattA1 wrote:
Hmm. Thanks for the tip, Arrow, I'll look that up. It's on the string palette?