Thermal printer is often referred as receipt printer. It is widely used in restaurants, ATM, shops and many other places where receipts or bill is required. It is a cost-effective solution and very handy to use from the user’s side as well as from the developer’s side. A thermal printer uses a special printing process which uses thermochromic paper or thermal paper for printing. The printer head is heated at a certain temperature that when the thermal paper passes from the print head, the paper coating turns black in the areas where the printer head is heated.

In this tutorial, we will interface a thermal printer CSN A1 with widely used PIC microcontroller PIC16F877A. Here in this project, a thermal printer is connected across PIC16F877A and a tactile switch is used to start the printing. A notification LED is also used to notify the printing status. It will glow only when the printing activity is going on.

Printer Specification and Connections

We are using CSN A1 Thermal Printer from Cashino, which is available easily and the price is not too high.

If we see the specification on its official website, we will see a table which provides the detailed specifications-

On the back side of the printer, we will see the following connection-

The TTL connector provides the Rx Tx connection to communicate with the microcontroller unit. We can also use the RS232 protocol to communicate with the printer. The power connector is for powering the printer and the button is used for printer testing purpose. When the printer is being powered, if we push the self-test button the printer, will print a sheet where specifications and sample lines will be printed. Here is the self-test sheet-

As we can see the printer use 9600 baud rate to communicate with the microcontroller unit. The printer can print ASCII characters. The communication is very easy, we can print anything by simply using UART, transmitting string or character.

The printer needs a 5V 2A power supply for heating the printer head. This is the drawback of the thermal printer as it takes huge load current during the printing process.

Prerequisites

To make the following project, we need the following things:-

Breadboard

Hook up wires

PIC16F877A

2pcs 33pF ceramic disc capacitor

680R resistor

Any color led

Tactile switch

2pcs 4.7k resistors

Thermal Printer CSN A1 with paper roll

5V 2A rated power supply unit.

Circuit Diagram and Explanation

Schematic for controlling printer with PIC Microcontroller is given below:

Here we are using PIC16F877A as microcontroller unit. A 4.7k resistor is used to connect MCLR pin to the 5V power supply. We have also connected an external oscillator of 20 MHz with 33pF capacitors for the clock signal. A notification LED is connected across RB2 port with 680R led current limiting resistor. The Tactile switch is connected across RB0 pin when the button is pressed it will provide Logic High otherwise the pin will receive Logic low by the 4.7k resistor.

The printer CSN A1 is connected using the cross configuration, Microcontroller Transmit pin is connected with the printer’s Receive pin. The printer also connected with the 5V and GND supply.

In the main function, we first checked the ‘button press’ and also used switch debounce tactics to eliminate the switch glitches. We have created a if statement for ‘button pressed’ condition. First the led will glow and the UART will print the strings. Custom lines can be generated inside the if statement and can be printed as a string.