Connecting Omron PLC to printer with TCP/IP

S Sam Winterton 3 years 7 months ago
1046 2 0

Hello,

In this post I will outline how I was able to connect a ZD420 printer to an Omron NJ series PLC. This task took me a considerable amount of time and manual reading, so hopefully this will help speed up the process for someone out there!

The first trick was to define a structure in Sysmac Studio that matched the Input Assembly from the Network Connect for Automation Developers Guide:
https://www.zebra.com/content/dam/zebra_new_ia/en-us/manuals/software/n…

I used a UINT counter to increase the Sequence Number, set the Format Number to 01, and left every field, except Raw Parser Data, as null. In the Raw Parser Data I could write up to 320 bytes ZPL code as a string. If your ZPL code is longer than the 320 bytes, two messages can be sent with another instance of the Input Assembly Structure with ^XA starting the first message, and ^XZ terminating the second message. Using UINT to BYTE and StringToAry the data was placed in a sending array of 496 bytes with offsets defined by the Input Assembly to account for the two null bytes required at the beginning of each section.

The TCP/IP port for the printer can be found by connecting to the printers IP address (when on the same network as the printer, type the printer's IP address into web browser search bar), and going into the TCP/IP settings (default username is admin and password is 1234). Use that port number as the destination port for the SktTCPConnect. The source port for this command should be set to 0. In Sysmac this will make the PLC find a new available port number for each connection, allowing connections to be made as often as needed. Use the structure outlined in the Sysmac instruction help manual to complete the sending and receiving of messages to and from the printer.

I was able to use the ~HSEQ  ZPL command to receive errors back from the printer. The errors are returned in a string, but are formatted so that the error bytes are in the same index position each time. The programming guide for ZPL 2 says that the ~HS command is not compatible with the ZD420 printer, I think this is because it does not have a display, not because the printer doesn't recognize the command / return anything (can someone from Zebra confirm this?). The return size of this array is 144 bytes, which will be placed in the RcvDat array of the SktTCPRcv command in Sysmac.

Good luck,
Sam

Please Register or Login to post a reply

2 Replies

P Phi Bach

I am impressed of what you did, but details are sketchy to follow, some example would be nice.
BTW, Did you use / update the special firmware SP004629A ?

V Viraj Shah

Hi Sam,

Thank you for sharing this information.Its really helpful for the beginners and like people working with zebra printers for the first time.
Can you please share your sysmac studio PLC file with network configurator so that it will be perfect sample to start with. Any of your help will be really appreciated.

Thanks

CONTACT
Can’t find what you’re looking for?