Skip to main content

Kollmorgen Support Network

Getting Started with KAS UDP Communications | 06 Jun 2016 | |

Getting Started with KAS UDP Communications

Introduction

Attached is a sample program showing basic UDP communications between two KAS PxMM controllers. The concepts here can easily be applied to communicating between a PxMM controller and a PC or other non-Kollmorgen product.

With PxMM UDP communications:

  • a Port is an internal Software structure that is identified as a Port Number  
  • The udpCreate function is used to create a Socket which is the combination of a IP address and a Port Number.
  • Typically a PxMM requires 2 Sockets: one to receive data and the other to send data

The KAS UDP udpSendTo and udpRcvFrom functions are used to send and receive characters between PxMMs or a PxMM and a third party device.

EXAMPLE: 2 PxMMs using UDP communications to transfer data to each other

image

Controller IP Address Client Port (sending data) Listening Port (receiving data)
1 10.50.67.226 0 20
2 10.50.67.95 0 20

Controller 1

PxMM example project: UDP_SendPositionConmmandAndReceiveFeedback

The program SendPosition below sends a position (1001) over UDP using Port 0 (Client_Port) from a PxMM (address 10.50.67.226 ) to another device (Controller 2) with IP address 10.50.67.95. Prior to sending information with the udpSendTo function a socket (udpCreate) and address “add” (udpAddrMake) are created to send information to Controller 2.

image

The program MonitorPosition below receives a actual motor position from Controller 2 (address 10.50.67.95) over UDP using Port 20 (Listening_Port). Prior to receiving information with the udpRcvFrom function a socket was created (udpCreate) to receive information from Controller 2

image

Controller 2

PxMM sample project: UDP_ReceivePositionAndSendFeedback

The program ReceivePosition receives a position from Controller 1 (address 10.50.67.226) over UDP using Port 20 (Listening_Port). Prior to receiving information with the udpRcvFrom function a socket was created (udpCreate) to receive information from Controller 1. The program receives a position and places it in a relative motion command (Pipe Network motion function k MLAxisRel).

image

The program SendFeedback below sends back a parameter (feedback) over UDP using Port 20 (Server_Port) to Controller 1(IP address 10.50.67.226) . Prior to sending information with the udpSendTo function a socket (udpCreate) and address “add” (udpAddrMake) are created to send information to Controller 1.

image

Comments

Submitted by silverwind on Sun, 09/23/2018 - 08:21

dear author:
    thanks for your project,it is useful in my work.
    However,i will use a software on the Windows system to communicate with PCMM, but both of them can't receive the message from my software . They can send the feedback to my software. So what do you think about this phenomenon? 

   Look forward to your reply. Thank you!


 

Submitted by C Wontrop on Mon, 09/24/2018 - 12:12

Did you  set up communications (IP address, port) in the Windows system for each PCMM 

Submitted by silverwind on Tue, 09/25/2018 - 13:54

Yes,i did.
In the KAS project,the IP:Port are 192.168.0.102:20. 

In the windows system the IP:port are 192.168.0.68:20.

So i can use the send function in KAS which the IP:port are 192.168.0.102:0 to send data to the windows system.And the windows system can get the data.One problem is that my software show that the port is not 0 .

On the other hand , when i used the windows system to send message to KAS(192.168.0.102:20),but the KAS can't get message.
   

In this test,I only used one computer.
And i have no idea about that why kas can't receive my message.

Look forward to your reply. Thank you!
 

Submitted by C Wontrop on Wed, 09/26/2018 - 14:20

Is the data sent from the PC to the PxMM a string? How many characters are in the transmission? The udpRcvFrom  will accept a maximum of 5 characters. Here is information on using udpRcvFrom:

http://curvegen.kollmorgen.com/webhelp/kas/#11.TechRefs/UDP/UDPRcvFrom.htm?Highlight=udpRcvFrom

Submitted by silverwind on Wed, 09/26/2018 - 14:36

I just send “111” as a string. When BytesReceived should be 3 , it is 0.

About this Article

C Wontrop