Professional Documents
Culture Documents
Jabir VS
ABSTRACT
Thermal printers are very common due to their wide-spread use in so many devices in our day-to-day life.
Some of them are handheld devices used for point-of-sales, ticketing machines, metering, and so forth.
The benefits of thermal printers are compelling. There is no toner, ink or ribbons required for a thermal
printer. A thermal receipt printer uses a printhead with few moving parts and it fits in a thin space about
three inches across. By contrast, the standard receipt printer is composed of about 20 moving parts and
electrical devices, and takes up at least twice the space. Nowadays, thermal printer mechanisms are even
available with an integrated electro-mechanical paper cutter in it. All of these features make thermal
printers a right choice in a wide variety of applications.
This application report discusses the complete hardware and software required for a thermal printer
solution based on Texas Instruments Tiva™ controllers. Tiva controllers are 32-bit ARM® Cortex®-M4 80-
MHz processor core with IEEE754-compliant single-precision Floating-Point Unit (FPU), on-chip memory,
featuring 256 KB single-cycle Flash, 32 KB single-cycle SRAM; internal ROM loaded with TivaWare™ for
C Series software; 2KB EEPROM and several other features.
With all the above hardware features and the graphics library support available for Tiva controllers makes
it easy to do the text rendering and simultaneous printing required for thermal printing.
Project collateral and source code discussed in this application report can be downloaded from the
following URL: http://www.ti.com/lit/zip/spma071.
Contents
1 Introduction ................................................................................................................... 2
2 System Block Diagram ...................................................................................................... 3
3 Circuit Diagram ............................................................................................................... 3
4 Firmware ...................................................................................................................... 4
5 Theory of Operation ......................................................................................................... 6
6 Graphical User Interface .................................................................................................... 9
7 Thermal Printer Graphical Interface ..................................................................................... 10
Appendix A Schematic .......................................................................................................... 12
List of Figures
1 System Block Diagram ...................................................................................................... 3
2 Flowchart - Part 1 ............................................................................................................ 4
3 Flowchart - Part 2 ............................................................................................................ 5
4 Software Flowchart .......................................................................................................... 6
5 Timing Chart for Using Fixed Six Divisions Printing..................................................................... 8
6 Thermal Printer Demo Interface .......................................................................................... 10
7 Schematic ................................................................................................................... 12
1 Introduction
1.1 Specifications
• Main controller – TM4C1233H6PM 64 LQFP
• Supporting chipsets
– DRV8834
– TS5A1066
– TPS76833
• External connectivity Interfaces
– Universal Asynchronous Receiver/Transmitter (UART)
– Universal Serial Bus (USB)
• Software features
– Support 2 inch thermal heads
– Can be extended easily for 3 inch printer head
– Wide support for fonts
• Multi-sized fonts
• Italics fonts
• Bold fonts
– Also support Image
– Architecture supports implementation of escape commands
This application report explains the working of the software and hardware required for building a thermal
printer solution.
The hardware for the system is designed around Texas Instruments TM4C1233H6PM Microcontroller. It is
a 80 Mhz processor with 256Kbytes of Flash and 32Kbytes of internal RAM. There are two motor driver
sections implemented in the system: one motor driver section for the printer motor and the other for the
paper cutter integrated to the printing mechanism. The motor driver sections are implemented using the
DRV8834 motor driver ICs from Texas Instruments. The hardware also provides the facility for
communication using UART and USB interfaces through the inbuilt peripherals available inside the
controller.
The thermal printer firmware is running in a foreground and background execution approach. It utilizes
various peripheral interrupts available in the microcontroller to achieve the performance. For example, the
design utilizes the UART interrupts for collecting the data from an external host, uses the timer interrupt
for accurately controlling the heating strobes of the printer mechanisms, and so forth. The font tables
(used for text rendering, and so forth) are stored in the built in Flash. The font tables are stored in a
compressed format for saving the application Flash. The images are stored in the form of C arrays.
The various functions performed by the firmware are listed below:
• Rendering of the text character received through the communication port to the printable image
• Logo printing using the onboard switch provided
• Font management by selecting the appropriate Font Table
• Increasing or decreasing the height of the printed text
• Increasing or decreasing the width of the printed text
• Precisely controlling the printing strobes as per the timing specification of the mechanism
• Auto cutter facility using the built-in paper cutter
• Provides a basic set of escape commands for data and commands
• Provision for adding more escape commands for data and commands
• Monitor the battery voltage of the system
DRV8834 for
Printer Motor
4-Wire/2-Wire
Serial Interface
TM4C1237
RS232
/TTL UART
TS5A1066
Printer Motor
Current Control
Power Supply
TPS76833
DRV8834 for
Cutter Motor
TI Components
3 Circuit Diagram
For the schematic details, see Appendix A.
4 Firmware
4.1 Flowchart
Power On Reset
Initialize GPIO
Initialize UART
Initialize TIMER
Initialize ADC
B NO
YES YES
A
UART Interrupt Handler
If Print YES
Command Set Text
Received Print
If Text Print YES
Mode CALL text_print();
and Mode Enabled
return()
NO
Set
If Paper CUT YES CutFlag NO
Command and
Received
return()
YES
If Switch 1 CALLLogo_Print();
NO Pressed
If any Escape NO
return()
Commands NO
Received
YES
If Switch 2 YES
Pressed CALLLinefeed();
Enable Corresponding
Flags or Settings and
return ()*
NO
YES
If CutFlag Set CALL FullCut();
Return() Return()
5 Theory of Operation
5.2 Specification of the Thermal Printer Head Used With This Document
The thermal printer mechanism used for this application report is from Seiko. The model number is
CAPD245D-E. It has a built-in auto-cutter mechanism integrated into it. Table 1 shows the electrical
specification for CAPD245D-E.
Figure 5 describes the drive method as an example of the CAPD245 and shows a timing chart for using
fixed six divisions printing.
Indicator LEDs
There are two indicator LEDs provided for displaying various status signals:
• Led 1 is the indication for 3.3 V power.
• Led 2 is the indication for any error. For example, paper roll not present.
Figure 6 shows the GUI for the Tiva thermal printer demo. Using this GUI, you can print sample text from
the comfort of a Windows-based PC . You can try various commands supported by the firmware by using
this interface. It supports multiple commands like cutting, double height printing, image printing, and so
forth. It also displays the command byte information it sent through the UART.
Before sending any commands, you have to select the appropriate com port number and enter it into the
box given on the right hand top corner and press the OK button. If the port is free and usable, the software
issues the message “PORT OPENED SUCCESSFULLY”. After this, you can start using the various
command buttons.
3.3V
3.3V
POWER MOTOR CURRENT CONTROL 3.3V
R4 VREFO_C VREFO_P
10K R8
10K VM R7
J6 VCC F1 VM 330E
R30 U3 R5 R35 R33 3.3V
1 3 5 330E 27K 27K U11 U8
2 4 IN OUT 6
3 IN OUT 90_MA_EXCITATION4 5 nSLEEP_P 1 24 VREFO_P
4 FUSE 1E/1W 7 IN V+ 2 nSLEEP VREFO 23 REFV_P C40 D2
5 C44 C30 2 FB/NC 8 PGOOD REFV_C REFV_P R31 1K 1 2 ADECAY_P 3 BDECAY BVREF 22 REFV_P .1uF LED_RED
GND
6 100uF 100uF EN PG D1 NO COM AOUT_P 4 ADECAY AVREF 21
D 3 5 AOUT1 GND 20 D
1
LED_RED GND AISEN VINT
TPS76833 C31 AINV_P 6 19
CON6 10uF R34 R32 BINV_P 7 AOUT2 VM 18
4.75K 3.57K TS5A1066 8 BOUT2 VM 17
BOUT_P 9 BISEN VCP 16 nFAULT_P
nENBL/AENBL_P 10 BOUT1 nFAULT 15 CONFIG_P
STEP_P 11 nENBL/AENBL CONFIG 14 M1_P
R3 R6 R9 DIR_P 12 STEP/BENBL M1 13 M0_P
.15E .15E 330E DIR/BPHASE M0/APHASE
PPAD
C39
Appendix A Schematic
2.2uF
DRV8834
25
MOTOR CONTROL - PRINTER
3.3V
J2
J8 1 TMS
2 TCK MCU - LM4F120
STEP_P 1 3 TDI C32 C33
2 4 TDO C34 C35 C36 C37 C38 2.2uF 1uF 3.3V
5 .1uF .1uF .1uF .1uF .1uF 3.3V
3.3V
CON2
CON5 R16
R2 10K VM R15
10K 330E
U1
2
42
54
26
11
56
25
U9
JTAG RST 38
RST 4 nSLEEP_P nSLEEP_C 1 24 VREFO_C
VDD
VDD
VDD
VDD
90_MA_EXCITATION 13 PB7 1 nENBL/AENBL_P 2 nSLEEP VREFO 23 REFV_C
VDDA
VDDC
VDDC
C42 D3
1
3
CUTS 14 PC7 PB6 57 STEP_P ADECAY_C 3 BDECAY BVREF 22 REFV_C .1uF
PC6 PB5 ADECAY AVREF LED_RED
15 58 4 21
1
3
SW4 PS DIR_P AOUT_C
LF SWITCH TEST PRINT SWITCH ERR LED 16 PC5 PB4 48 nSLEEP_C 5 AOUT1 GND 20
TACT SWITCH PC4 PB3/I2C0SDA AISEN VINT
C C29 TDO 49 47 nENBL/AENBL_C AINV_C 6 19 C
.1uF TDI 50 PC3/TDO/SWO PB2/I2C0SCL 46 UART1TXD VM VUSB BINV_C 7 AOUT2 VM 18
2
4
TMS 51 PC2/TDI PB1 45 UART1RXD 8 BOUT2 VM 17
1
3
1
3
TCK 52 PC1/TMS/SWDIO PB0 BOUT_C 9 BISEN VCP 16 nFAULT_C
2
4
PC0/TCK/SWCLK 10 BOUT1 nFAULT 15
1
3
1
3
SW6 SW5 nENBL/AENBL_C CONFIG_C
10 LF SWITCH R21 R28 STEP_C 11 nENBL/AENBL CONFIG 14 M1_C
TACT SWITCH TACT SWITCH PD7 STEP/BENBL M1
DST6 60 53 TEST PRINT SWITCH 22K 0E R13 R14 R17 DIR_C 12 13 M0_C
DST5 59 PE5 PD6 44 USB+ .15E .15E 330E DIR/BPHASE M0/APHASE
2
4
2
4
PPAD
2
4
2
4
DRV8834
25
VB
D-
D+
ID
GD
GND
GND
GND
GND
GNDA
2 1
0E LED_RED 2
VUSB C6 C7 3
1
2
3
4
5
3
LM4F120B2QR 3
39
55
12
27
10PF 10PF 4
5 4
6 5
CON-USB-MINIB DI 7 6
CLK 8 7
Figure 7. Schematic
9 8
9
USB-
USB+
10
B 11 10 B
3.3V 12 11
USB 13 12
13
14
R12 DST6 15 14
10K 3.3V DST5 16 15
DST4 17 16
18 17
TH2 19 18
2
6
16
R20 R18 R11 R10 VM 33 32
430E 36K 36K 300E 34 33
V-
V+
J5 35 34
VCC
UART1RXD 12 R19 36 35
UART1TXD 11 ROUT1 14 UART1TXD_232 1 47K 37 36
DIN1 DOUT1 7 UART1RTS_232 UART1TXD_232 2 J4 38 37
UART1CTS 9 DOUT2 13 UART1RXD_232 UART1RXD_232 3 1 PS 39 38
UART1RTS 10 ROUT2 RIN1 8 UART1CTS_232 UART1RTS_232 4 2 1 40 39
C24 DIN2 RIN2 C28 UART1CTS_232 5 3 2 41 40
1 4 CUTS 4 3 HS 42 41
3 C1+ C2+ 5 BINV_C 5 4 TP1 43 42
C9 C8
C1- C2- CON5 BINV_C 6 5 470PF 470PF 1 FG 44 43
GND
.1uF .1uF AINV_C 7 6 45 44
C10 AINV_C 8 7 46 45
15
470PF BOUT_C 9 8 TEST POINT AINV_P 47 46
A BOUT_C 10 9 BOUT_P 48 47 A
MAX3232CPW AOUT_C 11 10 AOUT_P 49 48
U7 AOUT_C 12 11 BINV_P 50 49
12 50
0545501271
UART1TXD R23 0E UART1TXD_232
0541045031
UART1RXD R24 0E UART1RXD_232
UART1RTS R25 0E UART1RTS_232 PRINTER INTERFACE
UART1CTS R26 0E UART1CTS_232
CUTTER INTERFACE
Title
TI THERMAL PRINTER REFERENCE DESIGN
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2014, Texas Instruments Incorporated