Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA and command

Hello
 
I am using LabVIEW 7e and VISA for RS232 communication. I want to send hexa command like "010101000003". When I type the hexa number and enter thru hyperterminal, the machine responds properly. But when I do in LabVIEW, the machine seems not to work properly. Can you guide me to communicate thru RS232 with my machine?
Thanks, GraceSun
0 Kudos
Message 1 of 5
(3,683 Views)
GraceSun,

I am not clear on what you mean when you say that it works sending hex data via Hyperterminal. Anyway, there is an easy explanation why it migth not vave been worked with LabVIEW and what you can do:
* LabVIEW uses some kind of Pascal-like strings, which means that the string size is given by a string property. This implies that a LabVIEW string can contain any characters that can be represented as a Byte or char. In contrary, a C-string are finished by the first 0x00 in its content.
* Not all  chars are displayabel, so one needs some means to enter and display those in a LabVIEW string control. If you right-click on one of those, you'll find 4 display options, which are 'normal', ''\'-Codes, 'password' and 'Hex'. The first option uses simple ASCII characters to display the string content, which means that non-displayabel charcters aere not displayed. The second option is similar, but displayes all non-displayabel characters with their '\'-code. There are some simple '\'-codes for frequently used characters, for instance \s for a space or \n for a newline. Consult the Help for more details. The third option just displayes an asterix for each character, while the last option displayes the hexcode of each character.
* Create a string control to enter your data on your front panel. Right-click on it and choose the hex-display option. Enter your hex data. Send it. You might use a string display for the devices responds that has been set to the same display option.

Greetings from Germany!<br>-- <br>Uwe
0 Kudos
Message 2 of 5
(3,671 Views)

If it's possible in hyperterminal it can be done (simply) in LabVIEW.

The difference is that in hyperterminal each character is send as you type it and when you hit enter it will send <CR> or <CR><LF> depending on the settings.

As far as I understand your post you want to send a string of letters in the range 0-9,A-F and a <CR> 

so your string to wire in VISA write in LV in '\-code display'  will look like '010101000003\r' (try also  '010101000003\r\n')

Some devices don't like to get the characters at full speed (µC UARTS without big buffer and some workload) , so sometimes it's a good idea to send each character with a short delay.  I modified the example shipped with LV ....

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 3 of 5
(3,668 Views)
Thank you for your kind reply. But the two replies are different which makes me confused. One suggestion is to write a command as in hexa display and the other is to write as in '\'-code display. Which is right?
 
Thanks again.
0 Kudos
Message 4 of 5
(3,650 Views)

Assuming you want to send "010101000003" command, what ASCII bytes are supporsed to be sent in this case?
For example, regarding the first byte "0" in the above command, do you want to send a human-readble "0" (= ASCII 0x30), or exactly an ASCII zero (= 0x00)? 

If you case is the first one, just give a string expression like "010101000003".  If your case is the second, give a control-code expression like "\00\01\00\01...." .  Anyway you can also send CR (0x0D) and LF (0x0A) with "\r" and "\n" expressions respectively.

このメッセージは 01-23-2006 10:35 AMに Makoto が編集しています。

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