• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2056
  • Last Modified:

Sending a pulse to the printer port

 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
1 Solution
On Torry.ru 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


Email: diskdude@poboxes.com
WWW:   http://diskdude.cjb.net/

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: alweit1@hotmail.com

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

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!)  
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now