This is an old revision of the document!
Table of Contents
Thermoprinter
General info
Here I will post the information and progress about my diploma thesis. Shortly describing the project, it should be portable thermoprinter with bluetooth/USB communication, supporting multiple protocols.
This type of printer can be used with POS for printing recipes or with scientific equipment for printing reports.
Assets
What I have:
- Thermoprinter head
- STM32-Nucleo eval board
- BLE module
- All needed connectors that fit thermoprinter head
Stepper motor driver breakout module- Li-Ion batteries and holders
- Li-Ion battery protection and charging circuits
- Other small parts, like voltage regulators, LEDs, buttons, descreet elements
What is missing:
Some transistorsProper stepper motor driver IC- STM32 programming experience
Plans
- Write firmware to print predefined lines
- Attach assembled circuits to print head and to eval board
- Test printing
- Implement subset of ESCPOS protocol
- Change firmware to print
predefined linesvia BT (implement RAW proto) - Add power saving mode into firmware
- Find suitable Li-Ion battery management circuit
- Find suitable voltage regulators
- Test eval circuit with battery
- Redesign hardware in Diptrace if possible
- Final hardware design
- Implement subset of PJL protocol
- Write report
In progress
- Write firmware to drive stepper motor
- Should use acceleration/deceleration from datasheet (count lines in queue to calculate speed profile or decelerate after all lines are printed, anyway some space between documents is needed)
- Should be interrupt based (to allow time for calculations, data sending to the printer head and printing)
- Should follow datasheet guide on printing start sequence (pull paper, then push to allow more or less constant speed printing)
- Assemble temperature and voltage protection circuit
- Attach stepper motor driver to motor and eval board
- Test assembled circuits with oscilloscope and compare with simulation
Done
- Connect BT module to eval board
- Write firmware to establish BT communication between PC/Smartphone and eval board
- Find stepper motor driver
- Assemble stepper motor driver breakout board
- Assemble pulse length protection circuit
- Assemble other print head driving circuit
As SPICE simulations course work
- First hardware design (schematic and PCB)
- Protection SPICE simulation
6.09.2017
- Filled this page with information
- Searched for documents and forums with information about parts, connecting them and writing firmware for controlling them
8.09.2017
- Soldered wires to BLE module.
- Read BLE module datasheet
- Read eval board datasheet
10.09.2017
- Installed several IDEs for STM32 and selecting most convenient
- Researching code examples for controlling USART with hardware flow control (BLE module requires HW flow control)
- Researching code examples for controlling GPIO (button needed to initiate BLE module pairing with smartphone), handling internal and external interrupts (let MCU conserve energy in sleep mode and only wake up to process incoming data)
- Testing IDEs (emBitz, emIDE, CrossStudio, SEGGER Studio)
11.09.2017
- Testing IDEs (IAR, Keil, AtollicStudio, SystemWorkbench, STM32CubeMX)
- Researching code examples for controlling MCU clocks (MCU has several internal and external clock sources, several buses that can be fed from different clock sources, as well as almost each feature can be fed from different clock sources and there are clock dividers and multipliers between them to set required frequency)
- Successfully tested USART example with SystemWorkbench IDE and selected it with STM32CubeMX configurator for further use.
13.09.2017
- Successfully tested interrupt based GPIO code to control USER button and LED on eval board
14.09.2017
- Found and researched examples of using UART hardware flow control, required for BLE module
16.09.2017
- Compiled USART examples into a somewhat working code. HAL USART driver is not suitable due to interlocking issue described here. I will have either to rewrite HAL portion of UART driver or reimplement UART communication myself. At the moment code should read byte by byte and immediately copy that into the second UART port. However, it can either send or receive at once, so every odd byte is lost. Perhaps using DMA is the one of the best solutions. Communication issues can be seen on the screen shot, where pre-last lines have missing symbols and last line was sent using doubled symbols.
- BLE module UART communication receive and transmit functions are implemented within different GAP services, so no ready made BLE serial port android applications can work with it. I can only send or only receive, since application connects to a single service at once.
Screen shot explanation: READY is printed, when eval board is started, CONNECTING… is printed, when USER button on eval board is pressed and BLE module is enabled to broadcast continuously to allow connection from other devices, TTM:xxx are module informational messages and all other text is sent from android based mobile phone using BLE communication application.
18.09.2017
- Rewritten code without handling UART interrupts with HAL and without DMA. Now every character is transmitted correctly back and forth. Tested with several android BLE apps. Also added the place in the code where printer commands and BLE module communication to be parsed.
20.09.2017
- Ordered missing components required for protection circuits and stepper motor driver
21.09.2017
- Got my stepper motor driver returned by friend who borrowed it for his CNC cutter, just to find out, it requires minimum of 12 V power supply for motor. This renders it unusable, since printer head allows no more than 8.5 V, which is fully charged 2S Li-Ion battery pack voltage. Will wait for ordered parts and make my own breakout board. Fortunately, I have ordered 2 ICs and will not have to take the breakout board apart for the final hardware.
27.09.2017
- Received stepper motor driver ICs, multivibrators, MOSFETs, transistors and logic gates, that were missing.
- Should finish stepper motor driving code
- Should now be able to assembly stepper motor driver breakout board (smth. like Polulu)
- Should now be able to assembly protection circuits and test them with oscilloscope
4.10.2017
- Finished soldering available breakout boards (shift register for managing heat elements blocks, battery voltage switch to supply stepper motor and heat elements, and pulse length protection), 5.09.2017 remaining ordered components should arrive
5.10.2017
- Performed research on different printing protocols (http://hacking-printers.net/wiki/index.php/Fundamentals). Basically 3 communication layers exist:
- Physical (networked/wire/wireless connection and protocols)
- Printer job management (spooling, settings, etc.)
- Printer control (print data, settings, status)
- Since existing BLE module allows only low speed communication and USB does not need network, then no network protocol support will be implemented for the prototype.
- Links about printer control:
- Links about printer job management
- It seems to be pretty large work to implement many standards and even subsets, so I will implement ESC/POS for the start and then PJL which will allow extension of supported standards later.
- General information for implementing ESC/POS or PCL
- https://en.wikipedia.org/wiki/Point_(typography)
- Performed research about full-featured bluetooth modules:
- https://www.itead.cc/wiki/Serial_Port_Bluetooth_Module_(Master/Slave)_:_HC-05
- To summarize, there is a family of chinese HC-0X BT modules, some of them are master/slave-only firmware locked. HC-08 is BLE, HC-09 is latest BT. HC-07 and HC-09 might have difficult to use, so HC-05 might be considered for purchase. As much as delivery period from China is totally random, I will continue to use current BLE module, and in case BT module will arrive timely, I will replace the BLE module.
- Received remaining ordered parts
6.10.2017
- Finished soldering stepper motor driver breakout board and printer head sensors breakout board. Temperature and voltage protection circuit remain unsoldered.
7.10.2017
- Finished soldering temperature and voltage protection circuit