Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Syntax Problems

Hi,
 
I've been having trouble getting my computer and a device (Masterflex pump) to communicate via LabVIEW on a serial interface. However, I am able to execute commands such as set RPMs, amount of revolutions, etc, using ASCII command characters in Hyperterminal, such as enquire (<ENQ>; CTRL-E), Start of Text (<STX>; CTRL-B), and Carriage Return (<CR>; CTRL-M). I've been using the bundled example VI "Basic Serial Write and Read", and have yet to come up with the proper syntax for "string to write" so I get a response from the pump via the "read string." I've googled and searched on the NI.com webpage extensively, but no such luck. Any suggestions? Thanks a lot!
 
Adam  
0 Kudos
Message 1 of 5
(4,330 Views)
Ibiaza,

not really beeing sure what your problem is, let me try to explain the string control a little bit. You may find a lot about this topic by searching the LabVIEW help for 'Configuring String Controls and Indicators'.
To summarize it a bit:
* There are 4 operational modes for string controls and indicators, which are 'normal', 'backslash', 'password' and 'Hex' mode.
  - 'normal' displays just all printable characters and hides or replaces all nondisplayable characters with some representations or actions e.g. a tab with a space or a NewLine with a line break
  - 'backslash' ('\')mode is similar, but replaces nondisplayable characters with their backslash code, e.g. '\s' is a space, '\r' is a return, '\n' is a newline and '\hh' is the character with the hex code of 0xhh. This gives you full visibel control of the string value and enables the insertion of literally all characters, while displayable strings are still visibel.
  - 'password' just shows an asterix for every character           and
  - 'Hex' displays the hexcode of each character. This give full control over the string value, but is harder to decipher visibel strings and numbers.
* One can choose the operational mode of a string control with a right click onto it

Lets return to your example 'Basic Serial Write and Read.vi'. It has an initial code of '*IDN?\r\n' in 'string to write', which is in '\' mode.
This means your device 'sees' the command string '*IDN?', followed by a CarriageReturn and a LineFeed. This is a standard SCPI command and instruct the device to indentify itself.
BTW, SCPI is a kind of control language for devices. Your example does not rely on SCPI, this is just an example within the example VI.


HTH   and  Greetings from Germany!<br>-- <br>Uwe
Message 2 of 5
(4,320 Views)
To add to the previous response, you can find a table of ASCII codes in the following Knowledge Base:

ASCII Table

By looking at this table you can determine which backslash codes to use.  You can use a hex code after the backslash, so using the example of commands you mentioned, and the table, we can see that:

ENQ = \05
STX = \02
CR = \0D or \r

You can find more information about the backslash codes by looking in the LabVIEW Help.  Just switch to the index tab and search for "backslash"

Jason S.
Applications Engineer
National Instruments
0 Kudos
Message 3 of 5
(4,315 Views)

Much thanks to you both! It is responding now 🙂

 

Adam

0 Kudos
Message 4 of 5
(4,304 Views)

Hi Ibiaza,

 

I also have a peristaltic pump manufactured by MasterFlex. Somehow, it works with their program but when I try to send commands from Hyperterminal, it doesn't. Also there is no answer on my PC screen. I have a baud rate of 9600, 8 data bits, parity none, stop bits 1, and flow control none. Could you please help me out on this matter? I wonder if you would be so kind to send me some commands that work for you. My email address is raresstanciu@yahoo.com.  

 

Thank you and best regards,

rares

0 Kudos
Message 5 of 5
(3,708 Views)