Sending a pulse to the printer port

Posted on 2000-04-04
Last Modified: 2008-02-20
 Can you help me,
  I am currently working on a simple Point of sale for my hairdressing salon.
  I am using Delphi 3.I have a reciept printer ( POS transaction printer ) and a cash drawer.
  The Cash drawer is connected to the POS printer and when I print a reciept or send a job to
  the printer the cash drawer opens by recieving a command from the printer.This is not good
  because anyone can open the cash drawer by printing from NOTEPAD.I am attaching a file
  to this EMail, open it and you will know that it is possible for me to change drivers so that the cash
  drawer does not open when the reciept printer is printing.It is possible for me to open the cash
  drawer by sending signals to the reciept printer.This I do know how to do.
 Below is a note from the vendor of the printer about sending signals to the printer but I do not how
 to use it in Delphi.
         Generate Cash drawer pulse.
         Generates a pulse to the cash drawer output if reciever at the begining of a line.
         if f = 0 or 48 the first cash drawer on pin 2 is activated and if f = 1 or 49 the second cash
         drawer on pin 5 is activated.
          Hexadecimal 1B 70 f m n
          Decimal         27 112  f m n
          ASCII            ESC p f m n
          values           f = Cash drawer select
                              m = Cash drawer on time
                              n = Cash drawer off time
          Rangers  :     Hexadecimal f = 00,01,30,31
                                                        m _< n = 00 - ff
                              Decimal  f = 0,1,48,49
                                            m _< n = 0 - 255
Related information : Both cash drawer on and off time values are multiplied by 2ms to
determine the pulse time.the off time should be greater than the on time. If the downloaded on time is greater then the off time,the off time will be increased to match the on time.
Installation and operation guide that came with the printer
Cash Drawer.
There is a single cash drawer driver with sense using an RJ-11 connector.This device
is designed for use with Epson compatible cash drawers.Thedriver supplies 24v dc
with maximum current of 1 amp.the coil resistance in the cash drawer must be no less
than 24 ohms or damage to the printer will result.Refer to the programming
manual for <ECS> p command usage.
Pin #         Signalname             Signal Source       Discription
1               CHASISS GND        -                          Chasis ground              
2               DRIVE                   Printer                  cash drawer drive. This pulse length is based
                                                                          on the 'ESC p' Command.
3               SENSE                  Cash Drawer         Cash drawer sense returned to the host
                                                                          with the 'ECS u' command.This pin should be pulled
                                                                          up by the printer.    
4               + 24 VDC               Printer                  
5               N/C                         -                          No Connection
6               SIGNAL GROUND    Printer                  Signal ground
Question by:tdecruz
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 2682852
On there are 2 components that let you send data to the printer ports


TDLPortIO v1.2: DriverLINX Win95/98/NT Port IO driver wrapper.
TDLPortIO is (c) 1999 John Pappas (DiskDude).
DriverLINX is (c) 1996 Scientific Software Tools, Inc.

This package allows read/write of IO ports in Win95/98/NT.

   o C++ Builder 3/4 VCL component
   o Delphi 3/4 VCL component
   o ActiveX (OCX) control (for Visual BASIC)
   o DLL version equivalent
   o All source code
   o Quick Windows NT System Admin driver installer
   o Examples (project sources)
   o Compatibility with the TVicPort shareware package



and smallport

SmallPort Delphi Component.

Thank you for trying SmallPort Component.

This component allows you to reach hardware ports using  "smport.vxd" driver with Win95/98.
It works a little bit faster and stable than regular assembler commands, that they usual use to reach h/w ports in Win95/98.

To install this component use Component >>Install Package>>Add>> HWTool4.bpl-for Delphi4 or HWTool3.dll-for Delphi3.
For Delphi2 use Component >>Install Component>>Browse>> \\..\SmallPort.pas
Copy file "smport.vxd" to Windows\System directory or to directory of your application.
Put component on your form and set property Opened to true. SmPort will open driver and now is ready to perform I/O operations. If you see message, that it's impossible to open driver, it means that driver is not in
application's folder and not ii System folder. Fix it and try again.

 Opened - read/write : boolean : open and close "smport.vxd".
 DriverHandle -read only : boolean: handle of driver.
 IOResult : read only: boolean :true if last I/O operation successful.
 Port : read/write : array: implementation Pascal array Port[portaddress].

Please direct all correspondence to  Alexander Weitzman at: mailto:

I hope these components can help you read/write the printer ports :-)


Accepted Solution

mullet_attack earned 25 total points
ID: 2683477
Seems to me all the info is there. I gather your cash draw is connected to a port on the printer, _not_ directly to the PC's printer port. in this case, the above printer port drivers are overkill and you should be able to
just print the string '#27#112#f#m#n' using standard delphi printer commands

where f = 0 or 48 for cash draw one
   or f = 1 or 49 for cash draw two

the m and n values will depend on the pulse widths required by your particular cash drawer (look in the manual!)  

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor ( Top Charts is a view in which you can set seve…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question