LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to send this command to RS232 Port

I want to use LV to control a label printer to print what I need. Following info is from printer user manual.
 

From RS232 port:

 

If Codex has been used with the controller then the simple serial protocol will need to be enabled by sending ESC Z SWITCH ON <CR> (without spaces). Codex automatically disables the simple protocol for security reasons, so it is a good idea to start all sessions with this command.

 

ESC Z S W I T C H O N <CR>

à From BASIC the first line would be CHR$(27)+”ZSWITCHON”+CHR$(13)

 

Send the following ASCII data to the RS232 port:

 

ESC J 0 C H R I S T M A S <CR>

ESC J 1 A N D   S E A S O N S <CR>

ESC J 2 G R E E T I N G S <CR>

ESC J 3 T O   M Y   H E L P E R S <CR>

ESC J 4 0 9 8 7 6 5 4 3 2 1 2 1 <CR>

à From BASIC the first line would be CHR$(27)+”J0CHRISTMAS”+CHR$(13). Etc.

 

In VB I can use this command to control the printer. But In LV how can I do?

 

I'd appreciate it if anybody give me a simple sample.

0 Kudos
Message 1 of 11
(11,502 Views)
A string control or constant in LabVIEW can be set for normal, hex, or '\' code display by just right clicking on the control constant. CHR$(27) is the the ESC character and the hex equivalent of 27 is 1B. The CR is hex  0D. So, a simple way to do this would be to have a hex display constants for the ESC and CR character and a normal display for the the command. Use the concantanate string function to build one string.
 

Message Edited by Dennis Knutson on 10-10-2007 09:57 PM

0 Kudos
Message 2 of 11
(11,492 Views)

Hi Dennis,

 

Thanks for your help, I will try it.

0 Kudos
Message 3 of 11
(11,472 Views)

Hi Dennis,

I tried it according to your suggestion, but when I change to HEX display the text controler display "010B" not "1B", "000D" not "0D".

Can you send me your Vi file?

 

Thanks.

0 Kudos
Message 4 of 11
(11,442 Views)
Sure. Post yours and lets see what you might have done incorrectly.
0 Kudos
Message 5 of 11
(11,431 Views)
Hi Dennis,
 
When I send this command to RS232 port, there is nothing feedback.
 
1. input ZSWITCHON in the text controller and then click start button to send command to the printer.
 
2. input J0HELLO in the text controller and click start button to send.
 
 
 
Can you tell me how to solve this problem?
 
here is my VI.
 
0 Kudos
Message 6 of 11
(11,404 Views)
I don't see anything wrong with the code othjer than you should not be doing a VISA Close inside the case statement. Are you sure the cable type and com settings are correct?
0 Kudos
Message 7 of 11
(11,390 Views)
Also, it's probably not a good idea to continually set the COM port settings insdie the loop.
0 Kudos
Message 8 of 11
(11,381 Views)
I can connect the printer via VB program but LV can not.
 
The com setting is correct.
 
I do not know why?
 
Do you have any other suggestion?
0 Kudos
Message 9 of 11
(11,361 Views)
0 Kudos
Message 10 of 11
(11,354 Views)