Solved

Sending a pulse to the printer port

Posted on 2000-04-04
2
1,948 Views
Last Modified: 2008-02-20
Hello,
 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
-----------------------------------------------------------------------------------------------------------------------------
 
                             
0
Comment
Question by:tdecruz
2 Comments
 
LVL 5

Expert Comment

by:Gwena
ID: 2682852
On Torry.ru there are 2 components that let you send data to the printer ports

portio

----------------------
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.

Includes:
   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

FreeWare!

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.

Properties:
 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 :-)

...Gwen..
0
 
LVL 2

Accepted Solution

by:
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!)  
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

746 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

10 Experts available now in Live!

Get 1:1 Help Now