Brief introduction

  Thermal printers are very common in our daily life, and there are examples of thermal printers in restaurants, parking lots and shopping. This article will focus on the application of thermal printers in parking systems.

  Materials to be used

  STONE STWI101WT-01
FTP thermal printer head
Raspberry Pi pico
Coin-operated machine

  Function

  The control function is displayed on the serial screen, the main interface selects the floor, after entering the main interface selects the parking space, at the same time it will display the parking space number in the text box on the top right, then selects the stay time, it is two scrolling text selectors, then also the same will display the order information in the text box on the top right, according to the fixed unit price which multiplies with the stay time to get the total price. Then only when the parking space and the stay time are selected, you can go to the payment button, otherwise, it is invalid. After entering the payment screen, a coin acceptor will be used. Then the screen will show the number of coins to be put in and the number of coins already put in. After the coins have been put in, a payment success message will be displayed. Then you can choose to print a small ticket to print the place number and time on the thermal paper.

  The design process

  At first, I wanted to use the Raspberry Pi pico to make a small printer. Then in the process of selecting components, I think the thermal printer is more convenient to achieve, after determining the program, I began to purchase hardware. In fact, in the process of online procurement, I found that there are many thermal printers with good driver circuits, most of them are made by using STM’s chip, and they are designed with their own set of instructions. For example, by using his instructions to let the printer print characters or go paper, but this printer’s practicality is very high, but there is no value in learning. It is to send instructions through the serial port on the line, you can manipulate the printer. So I thought I’d buy a print head and develop it myself. Then about the print head, I chose an FTP thermal print head.

  The FTP thermal print head

  parking-management-system

  This print head should be available internationally, the basic principles are similar. The left side is a stepper motor. Then the middle head is 6 heating units. Each heating unit has 64 heating points on it. So a total of 384 heating points. Then below is a latch. Below the latch is a shift register. Finally, there is a clock signal to be provided. So the whole principle of operation is to provide a clock signal to the print head and then send data every clock period, after sending 384 clock signals and 384 data, the data in the shift register will be stored in the latch. Then the latch is set to a low level. Then the 384 heating points will choose to heat or not to heat according to whether each data is 0 or 1. At the same time, let the stepper motor rotate to drive the thermal paper to design the desired character.

  After I got the thermal print head, I went ahead and asked for a datasheet and it was a 30pin FPC cable. So it’s obviously not very convenient to connect to the pico directly with it. So I thought I’d better design a backplane circuit.

  I have a STONE serial screen is a 12v power supply, and then I look at the thermal print head printing voltage of a reference value is 7.6v, the maximum value is 8v, then provide it with a voltage of about 7.6v. It also has a logic voltage is 3.3v, and then the Raspberry Pi pico maximum support 5v power supply and it has a 3.3v output voltage, then the power supply design can use two dcdc, with 12v power supply, one dcdc output 7.6v to power the thermal print head, the other dcdc output 5v to the pico, and then use the 3.3v from the pico to power the thermal print head logic voltage. Then 12v leads the way directly to the serial screen.

  By the way, the stepper motor for that thermal print head also needs to be driven. I have an integrated Darlington tube integrator. But it’s too big, and it’s a straight plug-in, so just buy a driver chip. Then this aspect of the drive motor is also OK.

  Printing requires the design of the font, basically, everyone is using spin flash for font storage, which is a huge project. Only ASCII code is more than 100, so you need to buy another SPF flash. Then the whole planning is almost like this.

  Design the circuit

  Then the following began to design the circuit. First, find the power supply, in fact, at the beginning, I used a three-terminal voltage regulator, because the circuit is simple, after being made, the heating situation was more serious during debugging, very hot to touch, so I change to use dcdc. Just follow the chip datasheet directly to do the circuit diagram. I chose mt2492 here, but I ignored an important parameter is the print head operating current, the maximum output current of this chip is 2A, but the print head operating current of 2.3A, a difference of 0.3A, it can also be used, but the efficiency is not so high, we’ll talk about the specific effect later.

  parking-management-system

  Then the motor driver chip that I bought is lv8548, see the print head data sheet, which has a stepper motor drive timing diagram, according to its timing, to provide it with a four-way pwm signal on it.

  parking-management-system

  Then is the flash chip, with by25q32bs, capacity of 32Mbit is quite large, and connected to the pico, waiting to be called by the pico.

  parking-management-system

  After that, the overall circuit diagram is like this, the upper left corner is the communication socket and power supply socket, below there is a buzzer (not actually used in the circuit), there is a light-emitting diode on the right, and the lower right corner is a 30pin FPC for connecting the print head.

  parking-management-systemparking-management-system

  The Raspberry Pi pico

  parking-management-system

  Turn on the power, first not connected to the pico and print head, measure the output voltage of the dcdc, in the normal case one is about 7.5v, the other one is about 5v.

  parking-management-system

  parking-management-system

  parking-management-system

  Then connect the print head, serial screen, and pico, measure the logic voltage is about 3.3v, after no problem, you can write the program.

  Program

  I intend to first adjust the stepper motor, this part is easy to adjust, look at the timing diagram in the datasheet, 8 clock periods, every clock period should separately give the motor’s four pins a logic signal, after 8 periods the motor will turn up, and then adjust the speed, but in the middle, we have to add a delay to adjust the duty ratio otherwise it turns too fast, the delay time I set is about 5ms and then after letting it turn you must give the level to low, otherwise the motor does not seem to turn in fact the internal coil is still on the power, after a long time you can smell the burning smell.

  Then write the function, put the body in a loop, the number of cycles represents the length of motor rotation, the function looks a little long, put it somewhere else alone and wait for the call.

  parking-management-system

  parking-management-system

  This is the function after a few changes, the speed and duration will be transmitted in the main program. It still needs a lot of optimization.

  Then is the point of adjusting the print head, this part is difficult for me, it needs a clock signal, the data-sheet is written in the maximum 8M, I thought it needed a signal of about 8M frequency, it’s difficult, first I measured the frequency with io flip level, the difference is too much.

  And then I want to use a pin, and I researched for a whole day but the result is not good, my personal skills are limited, probably I need to deeply study the rp2040 chip manually.

  Then flip the level 384 periods to try, it is a workflow like this, initialize the data input 1 pin, latch 1 pin, clock signal 1 pin, 6 print unit pins, and then in addition to the latch all other pull low, and then send one data within one clock period, after cycling 384 times to set the latch to 0, to set the 6 print unit to 1, and then which point has data which point will be heated. After the implementation of the set, pull the level back.

  Then after the program was written and started testing, it really didn’t work, actually because too many print units were controlled but the current was not enough, then change it to give less two print units high level and test again.

  parking-management-system

  It’s really working! It printed a horizontal line.

  That means there is no lower limit on the clock frequency, then you can run the stepper motor to print a vertical line. pico dual thread, then let the other thread to synchronous run the motor, then write the program and run. The vertical line comes out.

  parking-management-system

  With the horizontal and vertical lines, then get a diagonal line, pay attention to one print unit has 64 points, that defines a length, such as 32, and then cycle 32 times 384 periods, each period only set the first 64 data to 1 and set the next 320 data to 0, and then 32 times each time only in the first unit to print a point and then cycle incremental, combined with the speed of the stepper motor to adjust, and finally adjusted out 64 * 32 size of the diagonal line, you can also first spell out a letter Z.

  parking-management-system

  Then the outline of the program is there, if you want to print the word you need to do the font first. First do a capital letter A, 32 * 32 sizes, with a list of definitions, I am planning to do here with a pin. value (), so make the font, then use 32 rows and 32 columns of binary values to be called, take out to do a shift, and then pass to pin. value (), so this is the process of implementation.

  parking-management-system

  With 0 as the background and 1 as the foreground, the actual implementation process then looks like this.

  parking-management-system

  The most external large cycle 32 is representing the cycle of 32 lines, that is, print 32 lines, and then the first 32 cycles inside is to heat half of the first heating unit, then the remaining 352 periods will be set to 0, and then minus 1 from 31 each time until 0, you can count the first line of the points that need to be heated from left to right, and then every 384 periods to be completed once the latch set 0 and the heating unit set 1 and then you can print, and then one A word out after looping 32 times again.

  parking-management-system

  Still bold, this kind of dot matrix word, there are tools online can be done directly, the front plus 0b and then add a comma on the back, and then you play according to your own ideas, the font is actually initially intended to be stored in the flash chip, but I adjust a long time it still can not be opened.

  parking-management-system

  I don’t know where the problem is, after I have time I will adjust again, the good thing is that pico itself has a 16mbit size flash, storing an ASCII library is still enough, then I am so stored.

  parking-management-system

  Define it with a dictionary, put it in a separate piece, and call it back in the main program. Then after debugging, the available version looks like this.

  I am a separate control printing unit, because the current is not enough so like this, but in order to print clear, making my printing speed becomes particularly slow, the more words the slower, and then the lowercase letters are 24 * 32 dot matrix, that it is fewer print points to use, but can not give it to leave 32 heating points of space then the character spacing is large, so the capital letters and lowercase letters are separated, the numbers are still 32 * 32. Then print can achieve the basic functions, but there are two auxiliary functions that have not been done, one is the lack of paper detection and overheating protection, the circuit part has been done, the program I still have no time to do it.

  Temporarily first manual attention to renew the paper and do not let the heating head heating it for a long time.

  The next step is to do the coin acceptor, and I found that the circuit forgot to leave a wiring port for the coin acceptor, so I’ll connect the wires from the back of the board.

  Fortunately, only one signal line to be used for the coin acceptor, and then look at my pico, there is a GP28 available on the right side, but, after connecting, the signal can not be measured, so I changed to use the GP22, the same program I do not understand why the GP28 can not be used.

  parking-management-system(20)

  Related posts:

  Record Medical Surgery Notes with STONE Serial LCD Screen
What is a rechargeable car, electric car type introduction
Servo Motor Routine in the More Common Kinds of Failure
STONE TFT LCD Module Acceleration Gyroscope Sensor
STONE TFT Screen ventilator Project: HMI Design, Control Creation, Hardware Connection and Command Testing
Arduino uno +STONE LCD + Display data read by MFRC522
Portable Monitor with STONE serial Touch Screen and ESP32
Tutorial: STONE HMI display for EV charging infrastructure project
LCD Arduino + STONE HMI + Display Heart Rate
STONE TFT LCD Module + STM32 + Ultrasonic Dstance Measurement

Thermal Print Head for a Parking Management System Based on Raspberry Pi Pico and STONE TFT LCD

Tagged: