• AVR Freaks

Hot!18F4620 Printer Implementation

Author
WesCoP
New Member
  • Total Posts : 5
  • Reward points : 0
  • Joined: 2019/05/31 06:16:51
  • Location: 0
  • Status: offline
2019/06/07 05:36:00 (permalink)
0

18F4620 Printer Implementation

Hello, I'm new here and I have a big problem with implementation of a printer in a PIC18F4620.
Basically I need to use an MPT725 (www.prttech.com/products/product/index/cid/34/id/54.html) in the pins 27 (RD4) and 28 (RD5).
 

 
I read some of the content provided by PTR and I have no idea about how to start to make it work.
Has anyone here worked with printer implementation? I need a lot of help, thank the attention.
 
By the way, I am Brazilian, so excuse any failure in my writing.
Regards
#1

9 Replies Related Threads

    pcbbc
    Super Member
    • Total Posts : 1011
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: online
    Re: 18F4620 Printer Implementation 2019/06/07 20:31:51 (permalink)
    +1 (1)
    WesCoP
    Hello, I'm new here and I have a big problem with implementation of a printer in a PIC18F4620.Basically I need to use an MPT725 (www.prttech.com/products/product/index/cid/34/id/54.html) in the pins 27 (RD4) and 28 (RD5).

    Why that choice of pins? You’d be much better off using the EUSART to communicate with a serial printer, which is located on pins:
    RC6/TX/CK 25 EUSART asynchronous transmit.
    RC7/RX/DT 26 EUSART asynchronous receive.
    Otherwise you are going to have to bitbang a serial port - which is best avoided.

    Also it looks like that printer probably operates on RS-232 logic levels, so you will need a TTL to RS-232 converter. For example MAX232.
    #2
    WesCoP
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2019/05/31 06:16:51
    • Location: 0
    • Status: offline
    Re: 18F4620 Printer Implementation 2019/06/12 04:10:26 (permalink)
    0
    Thanks for answer, I choose that pins because my old printer use the same pins, so, I only have them to use the new printer.
    Off course, we use MAX232 too, I forgot to mention this. My biggets difficulty is how to program the MPT725 in the current firmware, do you have experience in the field? I really have no idea about how and where start the code.
     
    Att
    #3
    pcbbc
    Super Member
    • Total Posts : 1011
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: online
    Re: 18F4620 Printer Implementation 2019/06/12 04:26:30 (permalink)
    +2 (2)
    What protocol does the old printer use?  I presume that is RS-232 also?  So you already have a bit-banged serial implementation on RD4/RD5 in the firmware?
     
    Yes, I have experience of coding for various different serial printers, including ESC/POS.  If you send an ESC/POS printer ASCII data over the serial connection (with correct baud and data/start/stop/parity bits) it will print what you send.  Then in addition there are various escape sequences for selecting fonts, font sizes, bold, italics, cutting the paper, etc.
     
    You supplier should be able to provide you with a programming reference for the MPT725, but most ESC/POS devices follow the standard as defined by EPSON.
     
    Sorry - I'm not sure I see the problem here?  Unless of course your current printer is not RS-232?  If not then you'll have to bit-bang the serial protocol.  That's possible, but I've not done it personally and does have some potential pitfalls (you have to be very precise on timing for example).
    #4
    WesCoP
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2019/05/31 06:16:51
    • Location: 0
    • Status: offline
    Re: 18F4620 Printer Implementation 2019/06/12 09:51:03 (permalink)
    0
    Excuse me, I forgot to send you more information, probably because of my bad english.
    We use RS-232 protocol and I don't know about the bit-banged serial. My current printer use RS-232 too, I think that MPT725 may have some differences (maybe the DB9 connector) that is not working with the same pins and firmware.
    Consider that everything is allright wth the connections, what do I need to program to make it work?
    #5
    pcbbc
    Super Member
    • Total Posts : 1011
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: online
    Re: 18F4620 Printer Implementation 2019/06/12 10:12:04 (permalink)
    +1 (1)
    WesCoP
    Excuse me, I forgot to send you more information, probably because of my bad english.
    We use RS-232 protocol and I don't know about the bit-banged serial. My current printer use RS-232 too, I think that MPT725 may have some differences (maybe the DB9 connector) that is not working with the same pins and firmware.
    Consider that everything is allright wth the connections, what do I need to program to make it work?

    Do you have a spec for your old printer?  Does it use ESC/POS?  Or some other protocol?
    What baud and serial configuration (start/stop/parity bits) is it configured for?
     
    Firstly I would be checking that the new printer's serial port is configured the same as the old one.
    And then that the DB9 pins are connected correctly.
    If everything is the same then I'd expect your new printer to at least be producing some output with your existing code.
     
    I might start by connecting both printers to the serial port on my PC.  A lot easier to debug and fault find there.  And then at the Command Prompt:
    echo "Hello World!" > COM1

    For an ESC/POS printer that should print the line of text given.
    #6
    WesCoP
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2019/05/31 06:16:51
    • Location: 0
    • Status: offline
    Re: 18F4620 Printer Implementation 2019/06/13 11:49:04 (permalink)
    0
    Thanks for answering. Well, I don't have all this informations, so...
    "This series is suitable for a variety of applications, such as POS/
    ECR"
    (www.manualsbase.com/pt/manual/382074/printer/fujitsu/ftp-639mcl354-r)
    Baud rate 9600
    I don't know about the serial configuration, how can I find this?
    #7
    pcbbc
    Super Member
    • Total Posts : 1011
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: online
    Re: 18F4620 Printer Implementation 2019/06/13 13:19:40 (permalink)
    +1 (1)
    Is that manual for the old printer, or the new one?
    Assume the new one. 9600 would be fairly standard as a default baud.

    Well, if it was using the UART it would be easy. Just look at how the port is configured in the code.

    Unfortunately it appears as though you are not using a UART, so a few ways to tell...
    1. Look at the code you have and work out the delays it is using in the bit-banging. Then you can work back to the emulated baud rate.
    2. Attach a scope or serial monitor to the output and measure it.
    3. Connect printer to a PC and try various baud rates, start/stop/parity bit settings, until you find the ones that match (and the printer outputs what you send it).
    #8
    WesCoP
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2019/05/31 06:16:51
    • Location: 0
    • Status: offline
    Re: 18F4620 Printer Implementation 2019/06/17 06:04:05 (permalink)
    0
    Hello, thanks for answer.
    That manual is from the older printer, both of them use 9600 baud
    About the UART, can I do this with RD4 and RD5?
    Do you suggest that the problem with the new printer is the different baud rate?
    Excuse-me for so many questions, I'm really just a beginner.
    Again, thanks for the support!
    #9
    pcbbc
    Super Member
    • Total Posts : 1011
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: online
    Re: 18F4620 Printer Implementation 2019/06/17 07:00:52 (permalink)
    +1 (1)
    WesCoPAbout the UART, can I do this with RD4 and RD5?

    In post #3 you said your old printer uses the same pins?  Are you now saying the do not?
    But IF they do use the same pins, and as both old and new printer are 9600, one would assume that your existing firmware already has a bit-banged UART implementation on RD4 and RD5 @9600 baud.
     
    Do you suggest that the problem with the new printer is the different baud rate?

    That would have been my first thought - however you seem to be saying both are 9600 baud.
    Perhaps a different number of start/stop/parity bits?  What are they specified as?
     
    Both printers use ESC/POS command set.  Here is the programming spec for the old printer.
    So unless you are doing something really esoteric with you printing commands, it should be a like for like swap (no need to change firmware) at this stage.
     
    Why nothing is being printed with your replacement printer I cannot say.  Most likely causes are a physical connection issue (incorrectly wired to DB9 socket for example), or serial configuration issue (wrong baud/start/stop/parity bit settings).
     
    So I'd be using a serial monitor or scope to probe the data going to both old and new units.  I'd also be testing the new unit on a known good serial implementation (for example from your PC) so as to rule out any problems with the existing micro-controller hardware/firmware.  That will also confirm (or not) if you have the same baud/start/stop/parity bit settings for both devices.
     
    At this point there is zero point jumping in and saying "it's the firmware that needs changing" when you have absolutely no idea if there is anything wrong with it, let alone what might to change.
    #10
    Jump to:
    © 2019 APG vNext Commercial Version 4.5