How to realize TCP communication between EPSON robot and visual host computer

Publisher:buzzedyLatest update time:2022-10-10 Source: dotNet工控上位机Author: Lemontree Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Preface

Communication often occurs during development. Today, I would like to share with you how a robot can achieve TCP communication with a visual host computer.

Connected Robot

The robot used here is a Scara robot from the EPSON T3 series.

The robot software uses EPSON R V7.4.5. If you need the software, +V: thingerzj

First, you need to establish a connection with the robot. Generally, there are two ways to connect to the robot, one is the serial port and the other is the Ethernet interface. The Ethernet interface is used here.

SPEL+ Commands

EPSON robot programming uses SPEL+ language, and you need to refer to SPEL+ related commands for programming.

Here are some key commands for EPSON Ethernet programming.

1. SetNet command

Parameter list:

Communication port number: Specify the TCP/IP port number for which you want to set parameters. The range is 201 to 216.

Host Address: Specify the IP address of the host.

TCP/IP Port Number: Specify the TCP/IP port number.

Terminator: Specify a line end character among CR, LF, and CRLF.

Flow control: refers to software flow control, the default is NONE.

Timeout: Specify the maximum time for sending and receiving in seconds. If you specify 0, the timeout becomes infinite.

Communication protocol: Specify the communication protocol (TCP/UDP) type.

Example of use:

SetNet #201, "192.168.0.1", 2001, CRLF, NONE, 0

2. OpenNet Commands

Format:

OpenNet #Port Number As Client/Server

Parameter list:

Port Number: An integer value that specifies the TCP/IP port number to be opened. The port number range is 201 to 216.

Example of use:

Funcon tcpip
String data$
OpenNet #201 As Client
WtNet #201
Input #201, data$
Print "received '", data$, "' from host 1"
Fend

3. ChkNet Command

Format:

ChkNet (communication port number)

Parameter list:

Communication port number: Specify the TCP/IP port number (201 to 216).

Return Value

Returns the number of characters received (an integer value).

If there is no receive data, the following negative value returns the port status.

-1 The port is open, but communication is not established

-2 Another task is using the port

-3 Port not open

Usage Examples

Integer numChars
numChars = ChkNet(201)

4. Line Input Command

Format:

Line Input #Port number, string variable name$

Parameter list:

Port number: an ID number that indicates a file, communication port, database, or device.

String variable name$: Specifies the string variable name.

EPSON Programming

1. TCP sub-function

'Define receiving and output variables
Global String ReceiveData$, SendData$

Function ASTCPClient
 'Set IP address, port number, end character, etc.
    SetNet #201, "192.168.1.100", 2000, CRLF, NONE, 0
    'The robot acts as a client and opens the port
 OpenNet #201 As Client
 'Wait for connection
 WaitNet #201
 'Connection successful display
 Print "TCP ConnectOK....."
 
 Do
  'Reconnect after disconnection
  If ChkNet(201) = -3 Then 'Check the port status (>0 is the number of buffered characters. <0 is an abnormal state)  
   CloseNet #201 'Close the port and reconnect
   Wait 0.2
   OpenNet #201 As Client 'Open the client
   WaitNet #201 'Waiting for connection      
  EndIf
  'Receive data from host computer
  If ChkNet(201) > 0 Then
   Line Input #201, ReceiveData$
      Print "【" + Da$ + " " + TIme$ + "】" + "Received data from the host computer: " + ReceiveData$
       
  EndIf
  'Send data
  If SendData$ <> "" Then
   Print #201, SendData$
    Print "【" + Date$ + " " + TIme$ + "】" + "Send to host computer:" + SendData$
   SendData$ = ""
  EndIf
 Loop
 
Fend

2. Main function call

Function main
 'Multi-threaded execution
 Xqt ASTCPClient
Fend

Communication test

1. First use the network debugging assistant to open a TCPServer, the IP address is 192.168.1.100, here you can set it according to your computer IP, the port number is 2000.

2. Select Run in the menu bar of the EPSON robot to directly load the program into the robot.

3. After the download is complete, click Start to achieve communication.

4. You can send instructions to the robot through the network debugging assistant.

Review editor: Tang Zihong

Reference address:How to realize TCP communication between EPSON robot and visual host computer

Previous article:The global robot market is expected to exceed US$65 billion in 2024
Next article:5G+AI: The future of the robotics industry

Latest robot Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号