04-14-2017 05:07 AM - edited 04-14-2017 05:14 AM
Commonly on this forum the advice is given to avoid the VISA 'Bytes at Port' query, and instead to use simply the 'Read' node with a terminal character.
I'm reading from a pump (manual) which has a somewhat frustrating reply - in some cases, it will return CR + LF, and in others only '*', '+' or '-'.
I downloaded the LabVIEW driver the company provides on their website (thank you Ismatec), and it does indeed 'work', but I don't like it that much and since I want to integrate it with an MSE 1D LDV (Laser Doppler Velocimeter) (description but don't bother...) which provides basically no useful interface for LabVIEW, I'm rewriting the (pump) code based on their (Ismatec's) implementation. Fortunately, Ismatec provide perfectly good documentation and so it isn't too hard.
I've attached their low-level VI, but my problem is that I want to replace a process of 'write, read, check using Match String for '[*+-\r]', if found exit loop, else when time > 3 seconds exit and set timeout error (manually, the timeout on Open Serial is 20s)' with 'write, read'...
If all commands ended with CR, LF this would be simple. Since some return only a single character, I think what I'm going to do is remove the termination character from Open Serial then Read one byte, check if it is any of [*+-\n] (not '\r'), end if so, else Read again (and drop the timeout check, which is somewhat messy).
Is there a better way?
(I made a minor edit to the original code to remove some additional VI dependencies (previously there was a 'NoErrorConstant.vi' and another error to set the no error constant when a specific error was found - I used Clear Errors.vi which perhaps wasn't available in LabVIEW 6.1). There's still a missing VI but it doesn't do much, just creates an error for Simple Error Handler.vi)
Solved! Go to Solution.
04-14-2017 05:39 AM - edited 04-14-2017 05:41 AM
I would leave the termination character on. To start, just read a single byte. If it is '*', '+', or '-' you are done. If you get something else, read an entire line (tell VISA Read to read something like 50 bytes) and concatenate it to the first byte read.
I would also change that VI to be an Action Engine. Get rid of the Stacked Sequence Structure and local variables. The error wires can keep your data flow.
04-14-2017 06:03 AM - edited 04-14-2017 06:03 AM
Ok, I just got a little overboard and just rewrote that VI for you...
04-14-2017 06:39 AM