arduino uno and label printer

hello everyone!

i want to connect arduino uno to zebra gk420d with rs 232 to ttl
and this is my rs232 pin:
zebra arduino
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8

and this is my code:

#include <SoftwareSerial.h>

#define rxPin 2
#define txPin 3

// set up a new serial port
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);

void setup()  {

  // define pin modes for tx, rx:
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  // set the data rate for the SoftwareSerial port
  Serial.begin(9600);
  mySerial.begin(9600);
}

void loop() 
{
  if (mySerial.available()) 
  {
    mySerial.write("^XA");
    mySerial.write("^FO50,50^ADN,36,20^FD test");
    mySerial.write("^FS");
    mySerial.write("^XZ");
}
}

and the output is my printer can’t print.

can you suggest to me, what should i do?

thank you…

Hi,
You have given us pin numbers, but not what they are named.

Have you crossed Tx to Rx and Rx to Tx between them?
So that the Tx signal goes into the Rx pin etc.

Tom... :slight_smile:

TomGeorge:
Hi,
You have given us pin numbers, but not what they are named.

Have you crossed Tx to Rx and Rx to Tx between them?
So that the Tx signal goes into the Rx pin etc.

Tom... :slight_smile:

sorry i forgot.

zebra arduino
1 DCD 1 DCD
2 TXD 2 RXD
3 RXD 3 TXD
4 DSR 4 DTR
5 GND 5 GND
6 DTR 6 DSR
7 CTS 7 RTS
8 RTS 8 CTS

Hi,

Where are you connecting pins other than Gnd ,Tx and Rx.

Serial with the arduino only uses Tx and Rx and gnd

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Can you please post a picture of your project?

Thanks.. Tom.. :slight_smile:

this is my connection arduino uno to rs232toTTL

Hi,
Thanks for the diagram.
pict1.jpg

Tom... :slight_smile:

pict1.jpg

TomGeorge:
Hi,
Thanks for the diagram.
pict1.jpg

Tom... :slight_smile:

i dont get it, you just want me to upload a picture and do nothing?

Hi,
Hey ! ! !
I was at work on a break when I answered
So your connections look okay, what is the printer supposed to have printed?

Where did you get the info on what to send?

Tom… :slight_smile:

TomGeorge:
Hi,
Hey ! ! !
I was at work on a break when I answered
So your connections look okay, what is the printer supposed to have printed?

Where did you get the info on what to send?

Tom... :slight_smile:

i just want to know my rs232 work or not to connect arduino uno with zebra gk420d

You have a theoretically correct wiring it seems. now that won’t do anything unless you know what instructions to send and what to listen for to handle timing to not jam the printer

J-M-L:
You have a theoretically correct wiring it seems. now that won’t do anything unless you know what instructions to send and what to listen for to handle timing to not jam the printer

oh i forget to tell you all, i wiring rs232 with the UTP cable, do you think it’s wrong?

and can i check the connection of rs232 with arduino code like this? thank you

#include <SoftwareSerial.h>

#define rxPin 2
#define txPin 3

// set up a new serial port
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
int i=1;
int x;
char c;
String Berat;

void setup()  {

  // define pin modes for tx, rx:
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  // set the data rate for the SoftwareSerial port
  Serial.begin(9600);
  mySerial.begin(9600);
}

void loop() 
{
  Serial.println (mySerial.available());

}

Hi,
I think you need to read the appendix in this manual.

Tom... :slight_smile:

TomGeorge:
Hi,
I think you need to read the appendix in this manual.

https://cdn.cnetcontent.com/59/40/59400a3d-ea15-469a-90a5-a632fb89e191.pdf

Tom... :slight_smile:

should i setting DTR/XON/XOFF? DTR/XON/XOFF is default setting ? i want to connect without DTR/XON/XOFF

Hi,
It looks like you have to set them yes, because all serial on the Arduino does is Tx and RX, the control ahs to be done with extra software.

Tom.... :slight_smile:

You have connected the handshake lines (dts,cts etc.) of the rs232 so you need also do something in your code with it.

Or bridge them on the printer side.
Start bridging RTS with CTS and DTR with DTS on the printer side.

edje11:
You have connected the handshake lines (dts,cts etc.) of the rs232 so you need also do something in your code with it.

Or bridge them on the printer side.
Start bridging RTS with CTS and DTR with DTS on the printer side.

you can see link in #11, page 88 the connection DCE to DCE wiring is like #2. should i bridging RTS with CTS and DTS with DTS like connection DTE to DCE page 88?

riandanualdy:
you can see link in #11, page 88 the connection DCE to DCE wiring is like #2. should i bridging RTS with CTS and DTS with DTS like connection DTE to DCE page 88?

In the PDF appendix, the connections you need are only 3 wires! Pin 2 on the printer to receive data, pin 3 on the printer to send data, and pin 5 for a common ground.

In addition, on the printer, jumper pin 4 and pin 6. All others are not used or not needed.

The corresponding Arduino connections are up to you and your program.

Paul

And I hate it when people cross post into other parts of the forum and when I reply, the posting has got off into the unknown.

Paul_KD7HB:
In the PDF appendix, the connections you need are only 3 wires! Pin 2 on the printer to receive data, pin 3 on the printer to send data, and pin 5 for a common ground.

In addition, on the printer, jumper pin 4 and pin 6. All others are not used or not needed.

The corresponding Arduino connections are up to you and your program.

Paul

And I hate it when people cross post into other parts of the forum and when I reply, the posting has got off into the unknown.

why just using 3 wires? 4,6,7,8 why you ignore it?

can you explain me about "the corresponding arduino connection are up to you and your program?

sorry my bad sir.

The data sheet states one connection for "receive data", one connection for the "transmit data", and one connection for the common or ground connection. Three are all that is needed, as per the documentation. We try to connect just as the document states. All other pins contribute nothing to the data transmission or reception.

The two pins that I wrote that need to be connected together do not enter into the communications at all. They just tell the device it can transmit whenever it wants to. The Arduino is always ready to receive.

The connections to the Arduino pins are what ever pins the program uses to communicate. Look at the code.

Paul

Paul_KD7HB:
The data sheet states one connection for "receive data", one connection for the "transmit data", and one connection for the common or ground connection. Three are all that is needed, as per the documentation. We try to connect just as the document states. All other pins contribute nothing to the data transmission or reception.

The two pins that I wrote that need to be connected together do not enter into the communications at all. They just tell the device it can transmit whenever it wants to. The Arduino is always ready to receive.

The connections to the Arduino pins are what ever pins the program uses to communicate. Look at the code.

Paul

Paul - many small printers do not handle well pushing content too fast on the serial line as they have a limited serial receive buffer and they are a driving physical movements with inertia / precision so that are vastly slower than a serial communication even at 9600 bauds. If you Push bits to the printer faster than it can physically print the dots and feed paper, then you experience an “overflow” — bitmap images become garbled, text and formatting commands will be skipped.

To prevent this, many printers will communicate with the host computer when they are ready to receive the next batch of instructions to not saturate their incoming buffer. This Hardware handshaking - which is virtually eliminating buffer overflows whilst operating at peak throughput - is often made available on the DTR pin.

If you don’t take this into account then you’ll need to throttle sending data into your printer a bit arbitrarily to avoid jamming commands

To OP:
Once you get that working, to print anything you will need to send EPL or ZPL commands to the printer as this is the supported languages apparently