It is sometimes useful to have the possibility to print from a nano PLC, especially for small machines.

Here we will see how to connect an RS232 thermal printer to a PLC, e.g. to print machine status information, print the machine’s alarm history, print the number of products from the PLC’s counter,..

 

First of all, design the template of your ticket to be printed

In our example, we choose to print this template on you right.

For this purpose, built your template on https://convert.town/text-to-ascii

  • Use the “#” character for all your variables that you want to insert in this template.
    • It is important to use a sufficient number of “#” according to your values.
    • Also, add the underscore character “_” at the end of your template

Your ASCII code list on the right should end with “95”, and have 1 or more “35” for each digit inside.

 

Copy your template into a array of values

You have 3 subroutines in the program you can download here

  • Print ticket.viofs : Main subroutine which print the template with all off your numbers
  • NumberToASCII.viofs : Convert a number in ASCII code
  • AddValueToString.viofs : Add your values in the array (replace the 35 by the right ASCII codes of your numbers)

You can use this program for your test and then import the 3 subroutines into your machine program or create your machine program from it.

You must:

  • In the subroutine “Print ticket”, copy all the ASCII codes to build your template in your ACE machine.
  • then, add this subroutine call “AddValueToString” as many times as there are numbers in the template.

Dont forget to increment the pointer of the Numbers[x] tag : Numbers[0], Numbers[1], Numbers[2],..

 

Start printing on the printer!

Finally, in your main program:

  • Copy yours values/numbers in the MyValues[] array, in the same order as they appeared in your template
    • You can use another name for the array tag MyValues.
  • For start the printing, just call (only once !) the subroutine “Print ticket”
    • Here the InBitC1 input of the ACE PLC starts printing.