Industrial Automation
Industrial Automation | Europe

myKnowledge

Main > Product Type > Software > Visualisation
Minimize Text   Default    Enlarge Text
 

Print
E-mail

How Can I Change PLC Communication Settings From Within A CX-Supervisor Application?


Introduction

Sometimes you may wish to change the PLC settings while an application is running. This can be particularly useful if you need to communicate with multiple PLCs of the same type but don't wish to (or can't) configure 100s of PLCs in your application. This can also be useful if you communicate with multiple PLCs via a modem and want to connect to them by changing just the phone number at runtime.

Solution

Since CX-Supervisor V2.0 there has been the option to use an embedded CX-Server Lite ActiveX component (included free with CX-Supervisor) which allows you to use CX-Server Lite commands within scripts on the PLC configured in CX-Supervisor.
 
To use this functionality you must first configure CX-Supervisor to use this embedded CX-Server Lite component and also use an external configuration file (CX-Server cdm file) rather than an internal configuration. To do this you must first click Project->Runtime Settings->Advanced Settings, this displays a dialog containing advanced settings for the project:
 
 
The bottom item in this dialog gives you the option of embedding the CX-Server project within the CX-Supervisor project - this option must not be checked.
 
Next you must choose Project->Runtime settings->Startup Conditions, this displays the following dialog:
 
 
The bottom section has the option to Allow script access to PLC via "CXServer" control, this item must be checked.
 
Once these settings are applied you are ready to use the CXServer control in your scripts. This article has an attached CX-Supervisor project with an example of how to change the IP address and Node of a PLC.

In this project, there are 3 buttons, the first shows the current details using:

mydeviceconfig = CXServer.GetDeviceConfig ("myplc", "ADDRESS", "" )

The second sets the device config using the SetDeviceConfig command:

ClosePLC("myplc")
CXServer.SetDeviceConfig "myplc", "ADDRESS", "IPADDR", "10.59.50.73"
CXServer.SetDeviceConfig "myplc", "ADDRESS", "DA1", "73"
OpenPLC("myplc")

The Third sets the device config using the SetDeviceAddress command

ClosePLC("myplc")
CXServer.SetDeviceAddress "myplc", 4, 74, -1, "10.59.50.74"
OpenPLC("myplc")
 
You can choose to use either of these two solutions to change the IP address of a PLC, however using SetDeviceAddress makes it much simpler.  Note: you must always close the PLC before changing the setting.
 
If you want to change the phone number of a modem connected PLC you must use the SetDeviceConfig command as follows:

ClosePLC("myplc")
CXServer.SetDeviceConfig "myplc", "MODEM", "AREA", "1202"
CXServer.SetDeviceConfig "myplc", "MODEM", "NUMBER", "123456"
OpenPLC("myplc")

This will change the phone number on a PLC that is already configured to use a modem.
 
If you want to change other settings you can easily find out what the settings are using the GetDeviceConfig command with nothing between the quotes:
 
mydeviceconfig = CXServer.GetDeviceConfig ("myplc", "", "" )
 
This will get all settings for this particular PLC something like:
 
[DEV]CLOCK:TRUE;CPU:CPU11;DEV:CJ1M;GATE:TRUE;REMOTE:TRUE;UM:UM,0,12288,WORD,RW,1,RAM;[DRVR]DETECT:1;PORT:COM1,19200,None,8,1;[MODEM]AREA:1202;COUNTRY:44;DEVICE:ThinkPad Modem;NUMBER:123456;[NET]FRAME:1004;NET:SPMA;TMO:2000;[PROJECT]HANDLE:12;KEY:!D0004;
 
Each section (e.g. MODEM or ADDRESS) is in square brackets '[ ]' and is the second parameter in the SetDeviceConfig command. The third parameter is the item you want to set and is before a colon ':' (e.g. AREA, NUMBER, IPADDR). The final parameter is the value you want to change it to in "".

 



Attachments

changeipaddress.zip - Size: 19304


Comments (View All Comments / Add Comment)

Related Articles
No related articles found.
Created 2009-06-11
Modified 2009-06-11
Views 4438

 

You are not logged in.