Go Down

Topic: Thermal printer isn't Printing Images (Read 4916 times) previous topic - next topic

Nauman048

Hello,
I am using a 2 inch thermal printer with arduino uno r3. I used adafruit library for thermal printer i.e. "Adafruit_Thermal.h". With this library the text (Strings)
are printing fine, but when there comes a bitmap image, the printer just prints some garbage dots. Guide me how to fix it.
Thanks 

Quick5pnt0

You're probably going to need to post your code.

Nauman048

#2
Feb 07, 2013, 01:25 pm Last Edit: Feb 07, 2013, 01:46 pm by AWOL Reason: 1

You're probably going to need to post your code.


Code is as follows:
Code: [Select]

#include "SoftwareSerial.h"
// If you're using Arduino 23 or earlier, uncomment the next line:
//#include "NewSoftSerial.h"

#include "Adafruit_Thermal.h"
#include "adalogo.h"
#include "adaqrcode.h"
#include <avr/pgmspace.h>

int printer_RX_Pin = 5;  // This is the green wire
int printer_TX_Pin = 6;  // This is the yellow wire

Adafruit_Thermal printer(printer_RX_Pin, printer_TX_Pin);

void setup(){
 Serial.begin(115200);
 pinMode(7, OUTPUT); digitalWrite(7, LOW); // To also work w/IoTP printer
 printer.begin();

 // The following function calls are in setup(), but do not need to be.
 // Use them anywhere!  They're just here so they're run only one time
 // and not printed over and over.
 // Some functions will feed a line when called to 'solidify' setting.
 // This is normal.

 // Test inverse on & off
 printer.inverseOn();
 printer.println("Inverse ON");
 printer.inverseOff();

 // Test character double-height on & off
 printer.doubleHeightOn();
 printer.println("Double Height ON");
 printer.doubleHeightOff();

 // Set text justification (right, center, left) -- accepts 'L', 'C', 'R'
 printer.justify('R');
 printer.println("Right justified");
 printer.justify('C');
 printer.println("Center justified");
 printer.justify('L');
 printer.println("Left justified");

 // Test more styles
 printer.boldOn();
 printer.println("Bold text");
 printer.boldOff();

 printer.underlineOn();
 printer.println("Underlined text ");
 printer.underlineOff();

 printer.setSize('L');     // Set type size, accepts 'S', 'M', 'L'
 printer.println("Large"); // Print line
 printer.setSize('M');
 printer.println("Medium");
 printer.setSize('S');
 printer.println("Small");

 printer.justify('C');
 printer.println("normal\nline\nspacing");
 printer.setLineHeight(50);
 printer.println("Taller\nline\nspacing");
 printer.setLineHeight(); // Reset to default
 printer.justify('L');

 // Barcode examples
 printer.feed(1);
 // CODE39 is the most common alphanumeric barcode
 printer.printBarcode("ADAFRUT", CODE39);
 printer.setBarcodeHeight(100);
 // Print UPC line on product barcodes
 printer.printBarcode("123456789123", UPC_A);

 // Print the 75x75 pixel logo in adalogo.h
 printer.printBitmap(adalogo_width, adalogo_height, adalogo_data);

 // Print the 135x135 pixel QR code in adaqrcode.h
 printer.printBitmap(adaqrcode_width, adaqrcode_height, adaqrcode_data);
 printer.println("Adafruit!");
 printer.feed(1);

 printer.sleep();      // Tell printer to sleep
 printer.wake();       // MUST call wake() before printing again, even if reset
 printer.setDefault(); // Restore printer to defaults
}

void loop() {
}


The output print iss attached...
Text is fine but image is returned as garbage dots... :(

Moderator edit "You're probably going to have to post your code with [font=Verdana][[/font]code][font=Verdana][[/font]/code] tags"

Retroplayer

What thermal printer are you using?

Nauman048


What thermal printer are you using?

Its chinese made printer. Model number is PT-48b.

Retroplayer

Do you have a link to the datasheet?

What I am looking for is whether this printer supports graphic characters. You may be getting garbage because it doesn't.

Nauman048


Do you have a link to the datasheet?



http://www.prttech.com/Printer-mechanism/PT48B/#4

Retroplayer

Thanks. The PDF icon doesn't work, but it did lead me to another question. Are you driving the signal levels on that flat cable directly with your arduino or using an interface board in between? Your code doesn't look like it is driving everything directly.

Nauman048


Are you driving the signal levels on that flat cable directly with your arduino or using an interface board in between?

A interface board is available which is actually the logic level translator between printer and arduino. 

Nauman048


The PDF icon doesn't work.

Here the manual is attached.

michinyon

A thermal printer is readily capable of printing images,   but the software controlling it may not me.

In fact,  any printer can print images,  except the ones based on typewriter technology which have
actual metal printing elements representing the letters and numbers.

Retroplayer


Here the manual is attached.


Thank you. I see that it has a bit image mode, now just need to look at the adafruit library to make sure it is compatible and putting this into the correct mode.


Retroplayer

Looking at the datasheet and looking at the adafruit library, it doesn't look like the library is directly compatible with your board. To get into bitmap mode, you need to send a specific command. The reason it works with everything else is because the printer is set at defaults at power up and accepts your text.

Page 14 of the datasheet describes how to use the bitmap mode. You have to send ESC (27) then * (42) then a mode of 8 or 24 dots, and then your actual bitmap information. I don't see the library sending all those commands.

This was only a quick look, but I don't see it controlling the printer in the same way as the datasheet. However, some of the commands are the same, but those are for text stuff. The barcode and bitmap routines are not doing things the same way.


Nauman048

Can you tell me how to send the command???
I am sending the commands as:
printer.writeBytes(27,42,1);//ESC * m
printer.writeBytes(100,2);//n1 n2
for(int i==0;i<=200;i++)
printer.writeBytes(data);//d1 d2 .... dk
where the data is stored in program memory in the same format as in adafruit library example.
The code is successfully compiled and uploaded on arduino but the output is same as I have shown you above.(The data is also same)
I am stuck here... :(

Go Up