Thermal printer application notes

Source: Internet
Author: User

Thermal Electric printers are widely used on PS machines. Parameters for filtering are as follows:

1. Printing method: thermal, dot matrix, etc;

2. Print level: affects the number of words that a row can play;

3. Print density: the width of the affected line, in the unit of point/mm or point/line

4. Print Head life:

5. Valid print width: the actual printable character width;

6. Paper speed: speed;

7. Supported character sets: Chinese/English

8. Interface Format: parallel/string tll/232

9. Power Consumption:

10. Shape and installation method:

11. Qualification Certification: for Explosion-Proof scenarios

 

* Wei-Huang * E9 * (more stars to avoid advertising) the printer is applicable to explosion-proof occasions. The hardware connection is very simple, mainlyCodeDebugging, the format alignment is relatively paper-based, haha:

1. When debugging, the single-chip microcomputer and the printer supply power independently.ProgramPrinter current is very severe (thermal printing disadvantages), about 1.5a, will make the microcontroller die or cause print termination. It is best to use a linear power supply to observe the current;

2. Select the font type before sending and printing data in the program;

3. Print the maximum number of characters that can be printed on the printer to avoid line spacing;

 

# Include "stm32f10x. H"
# Include "Misc. H"
# Include "system_stm32f10x.h"
# Include "stm32f10x_gpio.h"
# Include "stm32f10x_rcc.h"
# Include "stm32f10x_usart.h"
# Include "FIFO. H"
# Include "string. H"

# Define max_line 13

# Define enabledata () usart_itconfig (ticketprintuart, usart_it_txe, enable)
# Define isprinterbusy () gpio_readinputdatabit (ticketprintbusygpio, ticketprintbusypin)
Void ticketprinterinit (void );
U8 ticketprinterwrite (u8 ** DP );
Void ticketprintertest (void );

# Define ticketprintirq usart2_irqhandler

# Define ticketprintuartioclk rcc_apb2periph_gpioa

# Define ticketprintuartclk rcc_apb1periph_usart2

# Define ticketprinttxgpio gpioa

# Define ticketprintbusygpio gpioa
# Define ticketprinttxpin gpio_pin_2
# Define ticketprintbusypin gpio_pin_3
# Define ticketprintuart usart2
# Define ticketprintirqn usart2_irqn


Static void ticketprinterioinit (void)
{
Usart_inittypedef usart_initstructure;
Nvic_inittypedef nvic_initstructure;
Gpio_inittypedef gpio_initstructure;

Rcc_apb2periphclockcmd (ticketprintuartioclk | rcc_apb2periph_afio, enable );
Rcc_apb1periphclockcmd (ticketprintuartclk, enable );

Nvic_prioritygroupconfig (nvic_prioritygroup_0 );
Nvic_initstructure.nvic_irqchannel = ticketprintirqn;
Nvic_initstructure.nvic_irqchannelsubpriority = 0;
Nvic_initstructure.nvic_irqchannelcmd = Enable;
Nvic_init (& nvic_initstructure );

cipher = ticketprintbusypin; // printor busy
cipher = cipher;
gpio_init (ticketprintbusygpio, & gpio_initstructure);
cipher = ticketprinttxpin; // tx2
bandwidth = gpio_speed_50mhz;
bandwidth = gpio_mode_af_pp;
gpio_init (ticketprinttxgpio, & gpio_initstructure);

Usart_initstructure.usart_baudrate = 9600;
Usart_initstructure.usart_wordlength = usart_wordlength_8b;
Usart_initstructure.usart_stopbits = usart_stopbits_1;
Usart_initstructure.usart_parity = usart_parity_no;
Usart_initstructure.usart_hardwareflowcontrol =
Usart_hardwareflowcontrol_none;
Usart_initstructure.usart_mode = usart_mode_rx | usart_mode_tx;

Usart_init (ticketprintuart, & usart_initstructure );
Export oinit (& printfifo, sizeof (printfifo. Data ));
Usart_cmd (ticketprintuart, enable );
}

Void ticketprintirq (void)
{
U8 ch;
If (usart_getitstatus (ticketprintuart, usart_it_txe )! = Reset)
{
If (! Isprinterbusy ())
{
If (! Fiforead (& printfifo, & Ch ))
Ticketprintuart-> DR = (uint16_t) 0x01ff & Ch;
Else
Usart_itconfig (ticketprintuart, usart_it_txe, disable );
}
}
}

 

 

// Test code

 

Test [] = {"stm32 microcontroller "};

For (y = 0; y <sizeof (TEST); y ++)

Export owrite (& printfifo, test [y]);

Export owrite (& printfifo, '\ n ');
Enabledata ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.