Skip to main content

Kollmorgen Support Network

KAS HTTP Communication | 26 Jun 2014 | |

KAS HTTP Communication

KAS has a HTTP communication option for users to write their own programs (in C++, C#, JAVA, visual basic, etc) and be able to read or write any variable in a KAS project.  It is documented in the 2.8 software, and I have attached a demo program with an excel spreadsheet that has visual basic scripts to read and write data in the program.  One thing to note is the controller IP address of 1920168.0.102 is used throughout the excel spreadsheet, so if you want to test it on real hardware it would be easiest to use this static IP on your controller (Preset 2 on the rotary dial of a PDMM controller). The only thing required in the KAS IDE is to activate the feature in the same screen where you enter the target IP address.  You will see the option to “Enable PLC variable remote access.”  It is up to the user to add commands in their program to read or write the variables then.

The basic command to read is

http://192.168.0.102/kas//plcvariables?variables=Data1 

where Data1 is the name of a global variable.  You can put this in any web browser to read the state of variables if you want.  Below is an example of a visual basic script to write to a Boolean variable named CloseButton

Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")

   URL = "http://192.168.0.102/kas//plcvariables"

   objHTTP.Open "PUT", URL, False

   objHTTP.send ("CloseButton=1")

Any variable can be accessed, and it does not matter if it is global or local, or a part of an array or structure.  Other examples can be seen in the excel spreadsheet by going to the Developer tab and clicking on the "Visual Basic" tab to see the scripts used.

Comments

Submitted by mahendra.kane on Tue, 08/18/2015 - 14:06

There is also a way to find out whether the data transfer from Excel is competed or not.

I used below code to send some data from Excel in Array format to PDMM.

------------------------------

  ColumnCountA = Sheets(1).Range("A" & Rows.Count).End(xlUp).Row

        Sheets(1).Range("BA" & 1).Value = ColumnCountA
        

   a3 = 1
   a5 = 1
   Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
   URL = "http://192.168.0.101/kas//plcvariables"
   
        strDATA3Array = "len1=" + LTrim(Application.ActiveSheet.Range("ba1").Value)
        
        strSendToKAS1 = strDATA3Array + ","
        
        objHTTP.Open "PUT", URL, False
        objHTTP.send (strSendToKAS1)
   
   For a1 = 0 To ColumnCountA - 1
   
   
        a2 = CStr(a1)
        a4 = CStr(a3)
        
        strDATA1Array = "Sample1Array[" + a2 + "]=" + LTrim((Application.ActiveSheet.Range("a" + a4).Value))
        strDATA2Array = "Sample2Array[" + a2 + "]=" + LTrim(Str(Application.ActiveSheet.Range("b" + a4).Value))
        
        
        strSendToKAS = strDATA1Array + "," + strDATA2Array + ","
        
        objHTTP.Open "PUT", URL, False
        objHTTP.send (strSendToKAS)
           
        If objHTTP.ReadyState = 4 Then
        HTTPTransferDone = True
             
        Else
        HTTPTransferDone = False
        
        End If
        
        'Do something to inform the user the data transfer has completed
        
        a3 = a3 + 1
         
   Next
    If HTTPTransferDone = True Then
       MsgBox "Data successfully transferred to KAS motion controller. You can start the machine now."
    End If


------------------------------
 

About this Article

Joe Parks