In this tech tip we will look at how to determine status of communications devices in Red Lion Crimson. The basics apply to all versions of Crimson and all devices that support communication drivers. The function calls may be used directly on a display page, or in complex expression for a tag.
Is Device Online
The IsDeviceOnline function is used for determining if the device is online. To use this function, select it from the Comms Device folder of the System Resource Panel (right) as shown below.
You can get help on the function by pressing the F1 key. The format of the function is IsDeviceOnline(Device) where Device is the device number of your device. The device number information is found in the status bar of Crimson while the device is selected as shown below.
In this example, the device is online when the function IsDeviceOnline.
In this example, the device is online when the function IsDeviceOnline(2)returns an integer value of 1. The returned status can be used as a fault-finding tool, or as status indication to monitor network and system health.
Network Ping
NetworkPing is useful for determining if network settings or network infrastructure issues exist. NetworkPing can be found in the Network Port folder of the System Resource Panel. The format of the NeworkPing function is NetworkPing(IP_Add,TimeOut). The IP_Add is the IP address of the device and TimeOut is the time in which a response is required, with the value in milliseconds. The two lines below show the script required to ping our PLC using its IP address and waiting up to 5s for a response. The function returns integer value of 1 if the device returns the ping request within the timeout period or returns 0 if not. If the function does not return 1, some possible reasons are wrong network settings, cabling issue or the network is heavily congested.
IP_ADD = TextToAddr("192.168.1.100");
Result=NetworkPing(IP_ADD,5000);
Get Device Status
The GetDeviceStatus is used to provide more detailed devicecommunication status than IsDeviceOnline. This function is also found in the Comms Device folder of the System Resource Panel. Again, pressingF1 with the function selected will provide detailed information on this function. The format is GetDeviceStatus(Device). The device number is also obtained from the status bar as shown above. The response from the function is shown in the table below. The least significant 2 bits show the device error state as show in the table below.
The function will also return the following hexadecimal codes.
To view the response on a display page in hexadecimal format, select Format Type as Numeric and Fixed Data Format as Hexadecimal as shown below.
For our example above the format of the function is GetDeviceStatus(2). If there are no issues, the GetDeviceStatus will return 0101. Which corresponds to, “The device comms is operating correctly” + “Some level of response has been received from the device”.
Note that the 0x0100 value does not imply that comms is working correctly, but merely that some sort of response has been received. It is useful for confirming wiring and so on. In a similar manner, the 0x0200values does not imply that comms has failed but indicates that all is not running as smoothly as it should. For example, Crimson’s retry mechanism may allow recovery from errors such that comms appears to be operating, but this bit may still indicate that things are not proceeding on an error free basis. These values can be added together so a value of 0x0032 = 0x0010 + 0x0020 + 0x0002.
This function can be useful in fault-finding but will not point specifically that the device or block which is faulting. This information can be used by deleting device and block to determine which devices are contributing to the faults. Other tools such as WireShark are also very useful in this process. |