• AVR Freaks

Hot!TTL THERMAL PRINTER EUSART Library

Author
irmak
Starting Member
  • Total Posts : 49
  • Reward points : 0
  • Joined: 2019/07/05 23:50:12
  • Location: 0
  • Status: offline
2019/11/17 09:38:20 (permalink)
0

TTL THERMAL PRINTER EUSART Library

I have bought a TTL thermal printer from aliexpress
https://www.aliexpress.co...311.0.0.13554c4dVSVFmv
 
I have test it with arduino and it works fine.
 
I use PIC 16f1789 and I want to develop a library like
https://circuitdigest.com...facing-with-pic16f877a
 
My connection diagram is
Printer GDN --> GND PIC
Printer RX ---->TX PIC
Printer TX---->RX PIC
Printer DTR --->Ground PIC
Printer VH--> VCC PIC
 
Baundrate of printer is 9600
 
What should be the other settings in code configurator for this printer.
 
I could not succeed to find orginal user manual that includes commands for this printer but in the attachment you can find a user manual of similar printer.
 
 
 
#1

15 Replies Related Threads

    irmak
    Starting Member
    • Total Posts : 49
    • Reward points : 0
    • Joined: 2019/07/05 23:50:12
    • Location: 0
    • Status: offline
    Re: TTL THERMAL PRINTER EUSART Library 2019/11/17 09:41:08 (permalink)
    #2
    ric
    Super Member
    • Total Posts : 24638
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: TTL THERMAL PRINTER EUSART Library 2019/11/17 12:16:43 (permalink)
    +2 (2)
    Did you try the commands in that manual?
    It's just using the EPSON command set (ESC/POS) which almost all printers of this type will use.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #3
    irmak
    Starting Member
    • Total Posts : 49
    • Reward points : 0
    • Joined: 2019/07/05 23:50:12
    • Location: 0
    • Status: offline
    Re: TTL THERMAL PRINTER EUSART Library 2019/11/17 13:14:40 (permalink)
    0
    Dear Ric
     
    I have tried it with CP2102 USB TTL converter & Tera Term
    My settings were like bluetooth module
     
    New Connection --> Serial-->com5 -->Slicon Labs Cp2102...
    Terminal Setup --> New line---> receive CR+ LF | trasnmit CR+LF  | Local echo checked
    Serail Port --> Port COM 5 | Baund Rate 9600 | Data 8 Bit | Parity None | Stop 1 bit | flow contro lnone
     
    Initialize printer
    ESC @  
    'ESC @'
     
    Print and line feed
    LF
    'LF'
     
    I have tried both combinations 
    #4
    irmak
    Starting Member
    • Total Posts : 49
    • Reward points : 0
    • Joined: 2019/07/05 23:50:12
    • Location: 0
    • Status: offline
    Re: TTL THERMAL PRINTER EUSART Library 2019/11/17 13:39:02 (permalink)
    #5
    ric
    Super Member
    • Total Posts : 24638
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: TTL THERMAL PRINTER EUSART Library 2019/11/17 14:43:40 (permalink)
    +2 (2)
    irmak
    ...
    Initialize printer
    ESC @  
    'ESC @'

    What does this mean?
    How did you send the ESC character in TeraTerm?
     
    Personally, I use Visual Basic or similar to test sending arbitrary sequences to a device from a PC.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #6
    irmak
    Starting Member
    • Total Posts : 49
    • Reward points : 0
    • Joined: 2019/07/05 23:50:12
    • Location: 0
    • Status: offline
    Re: TTL THERMAL PRINTER EUSART Library 2019/11/18 05:13:12 (permalink)
    0
    I retest the printer with arduino.
    I found the problem.
     
    It may be related to DTR PIN (I hAVE CONNECTED İT TO GROUND)
    Printer prints only 4 char and if I sent more than for in only makes an LF
     
    ==========================
    void setup() {
    Serial.begin(9600);
    while (!Serial) {
    ; // wait for serial port to connect.
    }
    //
    Serial.write(0x1B); //ESC
    Serial.write(0x40); //@
     
     
    Serial.write(0x12); //FOR dARKER PRINT
    Serial.write(0x23);
    Serial.write(0x05);
    Serial.write(0x1B); // PARAGRAPH ALIGMENT
    Serial.write(0x61);
    Serial.write(0x01); // 
    ////////////////////////////
    printFromAtoZ();
    }
     
    void printFromAtoZ()
    {
    unsigned char caracter = 'A';
    for(uint8_t i = 0; i<=3;i++){ // İF İT İS GRETER AND 3 ONLY LF HAPPENS
    Serial.write(caracter++);
    }
    Serial.write(0x0A);
    }
    #7
    ric
    Super Member
    • Total Posts : 24638
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: TTL THERMAL PRINTER EUSART Library 2019/11/18 05:21:22 (permalink)
    +2 (2)
    Maybe you are sending the data too rapidly. What if you add a small delay after each call to Serial.write ? Say about 10ms.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #8
    irmak
    Starting Member
    • Total Posts : 49
    • Reward points : 0
    • Joined: 2019/07/05 23:50:12
    • Location: 0
    • Status: offline
    Re: TTL THERMAL PRINTER EUSART Library 2019/11/18 08:10:17 (permalink)
    0
    Probably this is the problem
     
    I have change related ESC/POS parameters.
    It only effect a signle character.
     
    unfortunately delay(1) delay(10) delay(100) do not have positive effect
     
    Is there any other ESC/POS command to slow the printer
     
    ===================
     
     
    Serial.write(0x1B);///heating
    Serial.write(0x37);
    Serial.write(0xFF);// 0-255 Max printing dots,Unit(8dots),Default:7(64 dots)
    Serial.write(0xFF);// 3-255 Heating time,Unit(10us),Default:80(800us) If heating time is too short, blank page may occur.
    Serial.write(0xFF);// 0-255 Heating interval,Unit(10us),Default:2(20us)
    #9
    irmak
    Starting Member
    • Total Posts : 49
    • Reward points : 0
    • Joined: 2019/07/05 23:50:12
    • Location: 0
    • Status: offline
    Re: TTL THERMAL PRINTER EUSART Library 2019/11/18 08:11:56 (permalink)
    0
    I have tried FF, ESC FF but not suceed
     
    #10
    irmak
    Starting Member
    • Total Posts : 49
    • Reward points : 0
    • Joined: 2019/07/05 23:50:12
    • Location: 0
    • Status: offline
    Re: TTL THERMAL PRINTER EUSART Library 2019/11/18 09:35:44 (permalink)
    +1 (1)
    // Because there's no flow control between the printer and Arduino,
    // special care must be taken to avoid overrunning the printer's buffer.
    // Serial output is throttled based on serial speed as well as an estimate
    // of the device's print and feed rates (relatively slow, being bound to
    // moving parts and physical reality). After an operation is issued to
    // the printer (e.g. bitmap print), a timeout is set before which any
    // other printer operations will be suspended. This is generally more
    // efficient than using delay() in that it allows the parent code to
    // continue with other duties (e.g. receiving or decoding an image)
    // while the printer physically completes the task.
    // Number of microseconds to issue one byte to the printer. 11 bits
    // (not 8) to accommodate idle, start and stop bits. Idle time might
    // be unnecessary, but erring on side of caution here.
    #define BYTE_TIME (((11L * 1000000L) + (BAUDRATE / 2)) / BAUDRATE)
    #11
    irmak
    Starting Member
    • Total Posts : 49
    • Reward points : 0
    • Joined: 2019/07/05 23:50:12
    • Location: 0
    • Status: offline
    Re: TTL THERMAL PRINTER EUSART Library 2019/11/18 09:46:19 (permalink)
    0
    void Adafruit_Thermal::writeBytes(uint8_t a) {
    timeoutWait();
    stream->write(a);
    timeoutSet(BYTE_TIME);
    }
    #12
    irmak
    Starting Member
    • Total Posts : 49
    • Reward points : 0
    • Joined: 2019/07/05 23:50:12
    • Location: 0
    • Status: offline
    Re: TTL THERMAL PRINTER EUSART Library 2019/11/18 14:26:38 (permalink)
    0
    I have finally solved the problem
     
    ESC/POS command "ESC 7 n1 n2 n3"; parameters have very close relation with each other and character in a line.
    They should be well choosen. 
     
     
    =======================
    ESC 7 n1 n2 n3
    [Name] Setting Control Parameter Command
    [Format] ASCII: ESC 7 n1 n2 n3
    Decimal: 27 55 n1 n2 n3
    Hexadecimal: 1B 37 n1 n2 n3
     
    [Description]  Set “max heating dots”,” heating time”, “heating interval”
    n1=0-255 Max printing dots, Unit(8dots),Default:7(64 dots)
    n2=3-255 Heating time, Unit(10us),Default:80(800us)
    n3=0-255 Heating interval, Unit(10us),Default:2(20us)
     The more max heating dots, the more peak current will cost when
    printing, the faster printing speed. The max heating dots is 8*(n1+1)
     The more heating time, the more density, but the slower printing
    speed. If heating time is too short, blank page may occur.
     The more heating interval, the clearer, but the slower printing speed.
    #13
    ric
    Super Member
    • Total Posts : 24638
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: TTL THERMAL PRINTER EUSART Library 2019/11/18 14:43:14 (permalink)
    +1 (1)
    Do you have to set them?
    When I've used that sort of printer, I haven't played with those parameters at all.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #14
    irmak
    Starting Member
    • Total Posts : 49
    • Reward points : 0
    • Joined: 2019/07/05 23:50:12
    • Location: 0
    • Status: offline
    Re: TTL THERMAL PRINTER EUSART Library 2019/11/19 04:24:47 (permalink)
    0
    Dear Ric
     
    As I understood there are lots of variation in panel ttl thermal printers in Ali Express. 
    Also there are variations in original Adafruit.
     
    In Reeds blog you can find detailed report on some of these variations
    http://reed-printer.blogspot.com/2013/12/btht-v6-ttlrs232-thermal-printer-module.html
     
    First problem I have encountered was empty pages 
     
    When I increase contras related settings I have max 5 characters per line
     
    Then I will set the apropriate values to the settings above printer begin to work perfectly.
     
    The main problem  may be related to firmware in MCU (ARM:LPC-1114f) of these printers. There were no user manual with my printer and also there is no manual in manufacturer web site. I use user manuals of smilar printers. This was also my first experience with ESC/POS commands. 
     
    ESC/POS commonds that printer accepts also varies and first step may be to determine which commands are working properly. By this reason I use Arduino before PIC. Probabaly I will archive better results with PIC MCU.
     
     
     
     
    commands are 
     
     
     
    #15
    irmak
    Starting Member
    • Total Posts : 49
    • Reward points : 0
    • Joined: 2019/07/05 23:50:12
    • Location: 0
    • Status: offline
    Re: TTL THERMAL PRINTER EUSART Library 2019/11/22 12:26:48 (permalink)
    0
    I have  connected TTL thermal printer to PIC and I do not encountered any of the problems in Arduino. 
    Everything works fine without detailed additional settings.
     
    The only difference is Vprinter_supply is 5 V in Arduino and 9V in PIC
    post edited by irmak - 2019/11/22 13:28:21
    #16
    Jump to:
    © 2019 APG vNext Commercial Version 4.5