keal

Sysmac Studio : connect a printer

12 posts in this topic

Hi !

First, sorry for my english, i'm french. So, i want to create a program with sysmac studio for connect a NJ301-1200 to a printer. Then sent data (PCL Code) to the printer, after, the printer read the PCL code, understand, execute and print !

I have the PCL Code, but i find nothing for connect the printer and the NJ, and send to the printer data.

If anyone have an idea, I'll take this !

Thank's !

Share this post


Link to post
Share on other sites

Please, it's important, nobody knows how to connect to a printer? SktTCPConnect function, or another?

Share this post


Link to post
Share on other sites

You provided no information about the connection or the printer type.  How is anyone supposed to help?

What printer?  Ethernet or serial?  Connected to the PLC how?

I haven't done it, but nobody can answer half a question...

Share this post


Link to post
Share on other sites

Hi, sorry for the lack of informations, so it's a HP Printer that understand the PCL Code (language for print), it is connected to the ethernet port of a NJ301-1200, the NJ is connected to the PC via the USB port.

And i'm use sysmac studio for doing this.

So, I have test the function block CIPopen and skt, but nothing, i think the PC doesn't see the printer

 

edit : i've now a NB7 screen for doing this

Edited by keal

Share this post


Link to post
Share on other sites

With the first solution, the NJ doesn't see the printer

I've test with a NB7 screen, all done but the printer need to be pictBridge, i'm very lost, i don't see how i can print text with a NJ

Edited by keal

Share this post


Link to post
Share on other sites

HP Printers typically uses PCL on a TCP Server Port 9100.

You need to know / set the IP Address of your printer to match NJ's subnet. (e.g. NJ is 192.168.250.1, printer is 192.168.250.10, both same subnet mask of 255.255.255.0)

Then you need to use SktTCPConnect function block on NJ to the open connection to printers port 9100.

After connection has been made, you can send PCL commands using SktTCPSend. Send it as an array of ASCII BYTEs typically.

 

However I'm not sure whether TCP Port 9100 is used on your printer or not. Sometimes HP also uses UDP, so it'll depends on your printer model and specs.

Share this post


Link to post
Share on other sites

Great !

thank you very much, i can print now !

Share this post


Link to post
Share on other sites

Hi !

I have a last problem, so, i can send PCL code to printer, but, i want to do this differently, i need the charactere esc !

In hexa it's 1Bh, but i need the ascii charactere, when i use the function block to convert, I get a point '.' but it's not this, because when i convert point to hexa, i haven't 1Bh. So it's a special character, i want to copy it, and paste simply, but i can't copy the character, sysmac studio copy the line or the variable..

Edited by keal

Share this post


Link to post
Share on other sites
7 hours ago, keal said:

Hi !

I have a last problem, so, i can send PCL code to printer, but, i want to do this differently, i need the charactere esc !

In hexa it's 1Bh, but i need the ascii charactere, when i use the function block to convert, I get a point '.' but it's not this, because when i convert point to hexa, i haven't 1Bh. So it's a special character, i want to copy it, and paste simply, but i can't copy the character, sysmac studio copy the line or the variable..

If you can print already then it means you already understand how the SktTCPSend works. It sends data stored in Array of Bytes.
Typically you will create a STRING variable first which contains the text, like 12345 for example, then you use StringToAry function I believe to convert the said STRING into Array of Bytes.

To add <ESC> you can do it 2 ways :

1. Put a $1B in your String, e.g. you want to print 12345<ESC>, then you fill your string with '12345$1B' . The $ operator is a String character code detector. On some cases though it cannot detect what code is inputted (depending on what code being used).

2. Set the last byte in your array to 16#1B. Let's say printing 12345, then you will have a byte array of (16#31, 16#32, 16#33, 16#34, 16#35). You just need to move the value 16#1B into the next array index

Share this post


Link to post
Share on other sites

So, i need to print <esc>E<esc>&26A<esc>&30B

if i use $1BE$1B&26A......  it does not work

Share this post


Link to post
Share on other sites
2 hours ago, keal said:

So, i need to print <esc>E<esc>&26A<esc>&30B

if i use $1BE$1B&26A......  it does not work

Funny, because it did worked for me. I attached an example here. This is the way I did the conversion.
You can see from the Watch Table that each characters are converted to it's proper Hex ASCII Code

Capture.JPG.3dd70bc23434978c572d32255a07

Share this post


Link to post
Share on other sites

I have the same as you, but nothing, it's a problem with the printer, they don't understand all the pcl code.

 

But all the program works, thank you very much for your help !

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now