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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

948 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now