Help - Search - Members - Calendar
Full Version: 1746-bas Or Serial Port?
Forums.MrPLC.com > PLCs and Supporting Devices > Allen Bradley
Chris Elston
I've got an application coming up and wondered what you guys thought.

I need to program a ZEBRA printer which supports (DOS) BASIC commands. I've heard of other people using the BAS modules connected to the ZEBRA printer. But I've seen and read alot about the headaches involved using the BAS module. I need to store commands for FIVE different labels types which in my mind at the moment can only be stored in sub routines in the BAS module. Each sub routine has the command set to make the five different labels.

So my question is: Am I stuck using a BAS module?

There is no way I can store the BASIC commands needed for the ZEBRA in the PLC using ascii is there? (sending the command sets through the front port rs-232) I think there would be about 150 lines of BASIC commands per each label.

10 PRINT "HELLO"
20 PRINT "OH CRAP"
30 REM
40 CALL 21
50 CALL my grandma!
etc...
150 GOTO 10

And lastly, does anyone have any sample BAS code they can post? What I've read the most trouble is communicating with the PLC, or trading I/O between your BASIC program and the PLC ladder, but it seems to me at this point AB has some examples that should help me along located here:

http://www.ab.com/manuals/io/1746/1746-td005b-en-p.pdf
http://www.ab.com/manuals/io/1746/1746-rm001a-en-p.pdf

Actually they are just the manuals...with examples

But any pointers or examples would be a big help.
cool.gif
Jeff
A co-worker of mine is currently working on a project that involves using a zebra printer. I did the text for him in a ST file. The scheme he has developed requires the use of a laptop (with the printer software installed on it) to interface between the PLC and printer. The laptop will be connected to the PLC via the serial port (SLC 5/04 channel 0). The program logic will move data from various words in the ST file to an Excel spread sheet on the laptop using an "Intouch" driver.
Slick504
We use Basic modules to interface with barcode scanners and ID Matrix vision systems (2 dimensional barcodes), but all of our Zebra printers are interfaced with RB Modules.

I'm on holiday at the moment, but, i can send you samples of our Basic Module / Ladder handshaking code, next week, when i'm back at the front line.

Cheers
Graeme
Rother
Go on then, please enlighten me and probably others. What is a Zebra printer. A guess, a printer that prints bar codes. (the black & white stripes)
monkey
I have never used Allen Bradley's basic module nor do I have any idea what this zebra printer is. But, I have used the ascii commands in a SLC many times to communicate with other devices that speak ascii. In my opinion sending stuff this way is a giant pain compared to doing it in a basic language, but, if you want to use ladder logic it is possible. If you have 150 lines X 5 labels you may need a lot of room in your PLC's memory!
I would create an ascii 'server' subroutine that can plow through a string file (i.e. ST9) sending each address out the serial port. This requires indirect addressing (ST9:[N7:0]) where N7:0 contains the string address you want to send. I set up a couple of integers as 'control' words. For example, N7:0 is the starting address of a string file, and N7:1 is the ending address. Say you want to send the contents of ST9:20 - ST9:50 to your printer. (you would have already entered the lines of code to send in the string file) First, move a value of 20 into N7:0(start address) and a 50 into N7:1(end address). Then enable a sequencer that uses the AWT or AWA instruction to send a string out of the port. For the source enter ST9:[N7:0]. Next step of the sequencer is to wait for the AWT or AWA instruction to be completed (ascii read and write commands do not happen imediately in the ladder scan. Instead the are queued, and are executed asynchronously to the ladder scan) Check the EM bit of the control file for the AWT or AWA instruction. Once the string has been written (EM bit true) increment the value of N7:0 (ADD 1 to N7:0 and store in N7;0). Check to see if N7:0 is greater than N7:1 (end address) if it is disable your ascii 'server' sequencer. If not, loop back to the top of the sequencer and process another AWT or AWA instruction. The address sent will be the next line from your string file. The whole thing also requires that you configure channel 0 to user mode with an ascii driver. And you will need to set up the termination characters to whatever the printer will require. Most likely you will use the AWA (ascii write with append) to write a string to the serial port (appending the termination characters i.e. CR-LF).


As I said this will not be pretty (especially if you are used to using a basic language to send acsii data) but if you love a good challenge (as I do) your in for a lot of fun!

Good Luck,

Monkey
Chris Elston
Rother,

You crack me up! LOL colgate.gif

Here is a link you can check out for some zebra printers:

http://www.zebra.com/

http://www.zebra.com/PA/Printers/product_2746.htm


Monkey,

WOW! You've got it figured out already and haven't even seen the application. Thank you very much for taking the time to explain your theory of operation. Great work.


Eric
Here is code to do the following:

Read in data from both port 1 and 2 of the module. Light LED1 and LED2 if data is in the buffer. Transmit data to the PLC when either the delimiter is reached or the buffer is full. This talks to a SLC505. I can show you the code in the slc but it is very simple.


check out this site:

T:\Proj\627230\Controls\PLC\BasicModule\Software Connection - Techtips.mht



START of CODE
*************

10 PUSH 3 : CALL 120 : REM Clear all M0/M1 Buffers

20 PUSH 2 : CALL 96 : REM CLEAR PRT1 BUFFERs

30 PUSH 2 : CALL 37 : REM CLEAR PRT2 BUFFERs

40 REM 9600 Baud,Odd Parity,7 Data bits,2 Stop Bits,Xon-Off,RAM and ROM

50 MODE (PRT1,9600,O,7,1,S,R)

60 REM 9600 Baud,Odd Parity,7 Data bits,2 Stop Bits,Xon-Off,RAM and ROM

70 MODE (PRT2,9600,E,7,1,S,R)

80 REM ** Program to demonstrate CALL 22 functionality for **

90 REM ** Port 2 using the input image M0/M1 **

100 REM *********************************************************

110 REM

120 REM Initialize CALL 22 for PRT2

130 PUSH 2

140 REM Maximum character count (includes termination character [126 max])

150 PUSH 126

160 REM Carriage return for termination character (13 decimal)

170 PUSH 13

180 REM Destination file is input image

190 PUSH 1

200 REM Word offset

210 PUSH 0

220 REM String Number

230 PUSH 0

240 REM disable byte swapping

250 PUSH 1

260 REM Execute Call 22 - Write to M1 File

270 CALL 22 : POP S

280 IF (S<>0) THEN PRINT "UNSUCCESSFUL PRT 2 CALL 22 SETUP"

290 REM

300 REM *********************************************************

310 REM ** Program to demonstrate CALL 22 functionality for **

320 REM ** Port 1 using the input image M0/M1 **

330 REM *********************************************************

340 REM

350 REM Initialize CALL 22 for PRT1

360 PUSH 1

370 REM Maximum character count (includes termination character [126 max])

380 PUSH 126

390 REM Carriage return for termination character (13 decimal)

400 PUSH 13

410 REM Destination file is input image

420 PUSH 1

430 REM Word offset

440 PUSH 0

450 REM String Number

460 PUSH 0

470 REM disable byte swapping

480 PUSH 1

490 REM Execute Call 22 - Write to M1 File

500 CALL 22 : POP S

510 IF (S<>0) THEN PRINT "UNSUCCESSFUL PRT 1 CALL 22 SETUP"

520 PUSH 1 : CALL 95 : POP X

530 IF X>0 THEN PRINT "Port 1 Buffer Size - ",X

540 REM Examine Port 2 Input Buffer

550 REM Get number of characters in Input Buffer

560 PUSH 1 : CALL 36 : POP Y

570 IF Y>0 THEN PRINT "Port 2 Buffer Size - ",Y

580 REM

590 REM *********************************************************

600 REM Set LED1 and LED2 (1 is on, 0 is off, other is NC)

610 IF (X>0) THEN PUSH 1 ELSE PUSH 0

620 IF (Y>0) THEN PUSH 1 ELSE PUSH 0

630 CALL 112 : REM SET THE LEDS

640 GOTO 520


email me at eckirchn@yahoo.com if this helps and you want any more info
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.