Show Posts
Pages: [1] 2
1  Using Arduino / Networking, Protocols, and Devices / Re: Thermal printer isn't Printing Images on: February 14, 2013, 02:52:01 am
Did the modified library work okay?
I must say thankyou to you... Its working fine.. Thanks
2  Using Arduino / Networking, Protocols, and Devices / Re: Thermal printer isn't Printing Images on: February 12, 2013, 05:19:59 am
The output produced is smiley-small..... smiley-sad
3  Using Arduino / Networking, Protocols, and Devices / Re: Thermal printer isn't Printing Images on: February 12, 2013, 05:08:43 am
BTW, you can change the adafruit library directly. It has the main structure that you want, you just have to modify the parts that are different.

I have modified it according to the datasheet of printer. One more thing I have done is that I have made private functions accessable publically. Then I tried sending commands as in datasheet. I could see the commands working fine. Even the bitmap command also runs but couldn't produce a bitmap unfortunately.. smiley-sad
4  Using Arduino / Networking, Protocols, and Devices / Re: Thermal printer isn't Printing Images on: February 12, 2013, 05:04:20 am
Code:
#include <SoftwareSerial.h>
SoftwareSerial Thermal(2, 3);

int zero=0;

int heatTime = 80;
int heatInterval = 255;
char printDensity = 15;
char printBreakTime = 15;

static PROGMEM prog_uchar my_data [] = {
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};//I am skipping the data but the format is same..
void setup()
{
  Serial.begin(57600); // for debug info to serial monitor
  Thermal.begin(115200); // to write to our new printer
  initPrinter();
}

void initPrinter()
{
  //Modify the print speed and heat
  Thermal.write(27);
  Thermal.write(55);
  Thermal.write(7); //Default 64 dots = 8*('7'+1)
  Thermal.write(heatTime); //Default 80 or 800us
  Thermal.write(heatInterval); //Default 2 or 20us
  //Modify the print density and timeout
  Thermal.write(18);
  Thermal.write(35);
  int printSetting = (printDensity<<4) | printBreakTime;
  Thermal.write(printSetting); //Combination of printDensity and printBreakTime
  Serial.println();
  Serial.println("Printer ready");
}

void loop()
{
  // underline - one pixel
  Thermal.write(27);
  Thermal.write(45);  
  Thermal.write(1);
  Thermal.println("Underline - thin");
  Thermal.println("01234567890123456789012345678901");    
  Thermal.write(10);

  // underline - two pixels
  Thermal.write(27);    
  Thermal.write(45);
  Thermal.write(2);    
  Thermal.println("Underline - thick");
  Thermal.println("01234567890123456789012345678901");    
  Thermal.write(10);  

  // turn off underline
  Thermal.write(27);    
  Thermal.write(45);
  Thermal.write(zero);
  delay(3000);
  Thermal.write(10);  

  // bold text on
  Thermal.write(27);    
  Thermal.write(32);
  Thermal.write(1);
  Thermal.println(" #### Bold text #### ");
  Thermal.println("01234567890123456789012345678901");    
  delay(3000);  

  // bold text off
  Thermal.write(27);    
  Thermal.write(32);
  Thermal.write(zero);
  Thermal.write(10); //Sends the LF to the printer, advances the paper
  delay(3000);  

  // height/width enlarge
  Thermal.write(29);    
  Thermal.write(33);
  Thermal.write(255);
  Thermal.println("ABCDEF");
  Thermal.println("012345");
  delay(3000);  

  // back to normal
  Thermal.write(29);    
  Thermal.write(33);
  Thermal.write(zero);
  delay(3000);
  
  Thermal.write(10);
  Thermal.println("Back to normal...");
 // Bitmap routine
  Thermal.write(27);
  Thermal.write(42);
  Thermal.write(1);
  Thermal.write(250);
  Thermal.write(2);
    for(int i=0; i<1024; i++)
    {
    Thermal.write(adalogo_data[i]);
    }
  Thermal.write(29);
  Thermal.write(47);
  Thermal.write(1);
  Thermal.println("Image ...");
  
 
  Thermal.write(10);
  Thermal.write(10);  
  do { } while (1>0); // do nothing
}


Moderator edit: [code] [/code] tags added.
5  Using Arduino / Networking, Protocols, and Devices / Re: Thermal printer isn't Printing Images on: February 12, 2013, 05:02:23 am
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.

I have got another code which is not using any specific Library. Its simply working on POS Commands... I used to send bitmap commands under //bitmap routine if you see.
The output is same yet...smiley-sad
The code is in next reply.

6  Using Arduino / Networking, Protocols, and Devices / Re: Thermal printer isn't Printing Images on: February 12, 2013, 04:52:03 am
So, if you only use a single =,
Sorry the '==' was written here by mistake. Ofcourse I am using single ' ='. .. .
7  Using Arduino / Networking, Protocols, and Devices / Re: Thermal printer isn't Printing Images on: February 12, 2013, 01:47:57 am
I also have tried in this way:
for(int i=200; i>=0; i--)
    {
    printer.writeBytes(data);
    }
This made the location of dots changed but meaningless yet.
8  Using Arduino / Networking, Protocols, and Devices / Re: Thermal printer isn't Printing Images on: February 11, 2013, 11:30:12 pm

for(int i==0;i<=200;i++) 

you mean
for(int i=0; i<200; i++)  // 0..199 == 200 bytes
Yes , if its the data of 200 bytes then I am sending it in this way. But its not working fine. The output is still meaningless dots.
9  Using Arduino / Networking, Protocols, and Devices / Re: Thermal printer isn't Printing Images on: February 11, 2013, 12:03:27 am
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... smiley-sad
10  Using Arduino / Networking, Protocols, and Devices / Re: Thermal printer isn't Printing Images on: February 08, 2013, 04:21:56 am
Thankyou so very much...
11  Using Arduino / Networking, Protocols, and Devices / Re: Thermal printer isn't Printing Images on: February 08, 2013, 01:29:29 am
The PDF icon doesn't work.
Here the manual is attached.
12  Using Arduino / Networking, Protocols, and Devices / Re: Thermal printer isn't Printing Images on: February 07, 2013, 01:44:32 pm
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. 
13  Using Arduino / Networking, Protocols, and Devices / Re: Thermal printer isn't Printing Images on: February 07, 2013, 01:25:12 pm
Do you have a link to the datasheet?


http://www.prttech.com/Printer-mechanism/PT48B/#4
14  Using Arduino / Networking, Protocols, and Devices / Re: Thermal printer isn't Printing Images on: February 07, 2013, 07:40:45 am
What thermal printer are you using?
Its chinese made printer. Model number is PT-48b.
15  Using Arduino / Networking, Protocols, and Devices / Re: Thermal printer isn't Printing Images on: February 07, 2013, 07:25:21 am
You're probably going to need to post your code.

Code is as follows:
Code:
#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... smiley-sad

Moderator edit "You're probably going to have to post your code with [code][/code] tags"
Pages: [1] 2