Gray Code – Reflected Binary Code – Use in FieldServer’s

Gray Code is one of the most important codes. It is a non-weighted code which belongs to a class of codes called minimum change codes. In this codes while traversing from one step to another step only one bit in the code group changes. In case of Gray Code two adjacent code numbers differs from each other by only one bit. The idea of it can be cleared from the table given below.  As this code it is not applicable in any types of arithmetical operations but it has some applications in analog to digital converters and in some input/output devices.

Decimal Binary Gray Code
0 0000 0000
1 0001 0001
2 0010 0011
3 0011 0010
4 0100 0110
5 0101 0111
6 0110 0101
7 0111 0100
8 1000 1100
9 1001 1101
10 1010 1111
11 1011 1110
12 1100 1010
13 1101 1011
14 1110 1001
15 1111 1000


Using Gray Codes in FieldServer Gateways


In the configuration below:

Reads 6 Binary inputs from each of 2 BACnet devices, convert to a Binary (Decimal) Number and then converts those numbers to Gray Codes which are served using MSTP

Data_Array_Name , Data_Format , Data_Array_Length

DA_BitsA        , Bit         , 100

DA_BitsB        , Bit         , 100

DA_Float        , Float       , 100




//    Server Side Connections




Adapter , Protocol

N1      , Bacnet_IP





//    Server Side Nodes



Node_Name    , Node_ID , Protocol  ,Node_Option  ,Adapter

SouceNodeA   , 37306   , Bacnet_IP ,COV_disable  ,N1

SouceNodeB   , 37307   , Bacnet_IP ,COV_disable  ,N1




//    Server Side Map Descriptors




Data_Type , Object_ID , Map_Descriptor_Name         , Units    , Data_Array_Name , Data_Array_Offset , Node_Name    , Property      , Function

BI        , 0         , Bit 0                       , No_Units , DA_BitsA        , 0                 , SouceNodeA   , Present_Value , rdbc

BI        , 1         , Bit 1                       , No_Units , DA_BitsA        , 1                 , SouceNodeA   , Present_Value , rdbc

BI        , 2         , Bit 2                       , No_Units , DA_BitsA        , 2                 , SouceNodeA   , Present_Value , rdbc

BI        , 3         , Bit 3                       , No_Units , DA_BitsA        , 3                 , SouceNodeA   , Present_Value , rdbc

BI        , 4         , Bit 4                       , No_Units , DA_BitsA        , 4                 , SouceNodeA   , Present_Value , rdbc

BI        , 5         , Bit 5                       , No_Units , DA_BitsA        , 5                 , SouceNodeA   , Present_Value , rdbc

BI        , 6         , Bit 6                       , No_Units , DA_BitsA        , 6                 , SouceNodeA   , Present_Value , rdbc

BI        , 7         , Bit 7                       , No_Units , DA_BitsA        , 7                 , SouceNodeA   , Present_Value , rdbc



Data_Type , Object_ID , Map_Descriptor_Name         , Units    , Data_Array_Name , Data_Array_Offset , Node_Name    , Property      , Function

BI        , 0         , Bit 0                       , No_Units , DA_BitsB        , 0                 , SouceNodeB   , Present_Value , rdbc

BI        , 1         , Bit 1                       , No_Units , DA_BitsB        , 1                 , SouceNodeB   , Present_Value , rdbc

BI        , 2         , Bit 2                       , No_Units , DA_BitsB        , 2                 , SouceNodeB   , Present_Value , rdbc

BI        , 3         , Bit 3                       , No_Units , DA_BitsB        , 3                 , SouceNodeB   , Present_Value , rdbc

BI        , 4         , Bit 4                       , No_Units , DA_BitsB        , 4                 , SouceNodeB   , Present_Value , rdbc

BI        , 5         , Bit 5                       , No_Units , DA_BitsB        , 5                 , SouceNodeB   , Present_Value , rdbc

BI        , 6         , Bit 6                       , No_Units , DA_BitsB        , 6                 , SouceNodeB   , Present_Value , rdbc

BI        , 7         , Bit 7                       , No_Units , DA_BitsB        , 7                 , SouceNodeB   , Present_Value , rdbc




Source_Data_Array , Source_offset , Target_Data_Array , Target_Offset , Length ,Function

DA_BitsA          , 0             , DA_Float          , 0             , 8      ,Bit_pack

DA_BitsB          , 0             , DA_Float          , 1             , 8      ,Bit_pack






// COnnection



Adapter, Protocol  ,

N1     , CAS_TOOLN1 ,




//    Client Side Nodes




Node_Name, Node , Protocol   ,Adapter

CASUTIL  , 1    , CAS_TOOLN1  ,N1





//    Client Side Map Descriptors





Map_Descriptor_Name ,Scan_Interval ,Data_Array_Name ,Data_Array_Offset ,CAS_TOOLS_Array_Name ,CAS_TOOLS_Array_Offset ,Function ,Node_Name ,CAS_TOOLS_Function_Name       ,Length ,Address

toGray              ,1.0s          ,DA_FLOAT        ,0                 ,DA_FLOAT             ,10                     ,wrbc     ,CASUTIL   ,TO_GRAYCODE                   ,1      ,00

toGray              ,1.0s          ,DA_FLOAT        ,1                 ,DA_FLOAT             ,11                     ,wrbc     ,CASUTIL   ,TO_GRAYCODE                   ,1      ,00

//fromGray            ,1.0s          ,DA_GRAY         ,0                 ,DA_BIN               ,1                      ,wrbc     ,CASUTIL   ,FROM_GRAYCODE                 ,1      ,00



//    Server Side Connections




Port, Baud , Parity, Data_Bits, Stop_Bits, Protocol   , Timeout, Connection_Type ,

R2  , 38400, None  , 8        , 1        , Bacnet_MSTP, 30     , MSTP_Master_Node,







//    Server Side Nodes



Node_Name        , Node_ID , Protocol    , Node_Option

ServerNode       , 31      , Bacnet_MSTP , COV_Disable





Data_Type , Object_ID , Map_Descriptor_Name         , Units    , Data_Array_Name , Data_Array_Offset , Node_Name    , Property      , Function , Data_Array_Low_Scale , Data_Array_High_Scale , Node_Low_Scale , Node_High_Scale

AI        , 1         , AnalogValue_converted_A     , No_Units , DA_Float        , 0                 , ServerNode   , Present_Value , Server   , 0                    , 100                   , 0              , 100

AI        , 2         , AnalogValue_converted_B     , No_Units , DA_Float        , 1                 , ServerNode   , Present_Value , Server   , 0                    , 100                   , 0              , 100



Sample c++ code

unsigned int bin2Gray(unsigned int num)


return (num >> 1) ^ num;


unsigned int gray2Bin(unsigned int num)


unsigned int mask;

for (mask = num >> 1; mask != 0; mask = mask >> 1)


num = num ^ mask;


return num;



Online Gray Code Converter

RS485 Polarity Issues

RS485 is an electrical communication standard used by Modbus­RTU, BACnet­MSTP, and many other building automation protocols. This article covers issues related to the polarity of the RS485 differential balanced line. A differential balanced line consists of two wires (negative and positive). Binary ‘1’ is indicated by the voltage in the positive wire being greater than the negative wire. Binary ‘0’ is indicated by the positive wire having a voltage less than negative wire. The difference in voltages is expected to be at least 0.2v according to the RS485 standard, although not all devices comply with this. If the difference between positive and negative wires is less than 0.2v the bus is idle.


V+ ­ V­ > 0.2v : 1

V­ ­ V+ > 0.2v : 0

­0.2v < V+ ­ V­ < 0.2v : Idle


Four wire RS485 has two differential balanced lines. Two wire RS485 uses a single differential balanced line. RS485 polarity labels differ between manufacturers. According to the RS485 standard the two terminals are A for negative and B for positive. Most manufacturers will instead use + and –, or some variation such as D+, D­. Some manufacturers will label inputs as A,B but get the polarity backwards so A is positive. It is important to read the manual rather than assuming a manufacturer follows the standard.


RS485 has a reputation for being polarity insensitive because under normal conditions most devices will automatically determine which wire in the differential balanced line is positive and which is negative. This is because during the idle state the positive wire should have a slightly higher voltage than the negative wire. Fig1 shows a typical RS485 message, with the polarity of the positive and negative wires during the idle state. A multimeter can be used to verify the positive wire is higher than the negative wire during idle.


polarity article fig. 1


The positive wire has a higher voltage than the negative wire during idle states because RS485 differential lines use termination resistors. The line is idle when no devices are sending data, which means all devices have switched their output to high impedance. In this state the voltage levels of wires are primarily set by the termination resistors. Figure 2 shows an example set of RS485 termination resistors and the voltage they produce on the wires during an idle state.


polarity article fig. 2



Possible Problems With Automatically Detecting Polarity:

• Termination resistors are not set up properly.

• Electrical noise interferes with voltage levels during idle state.

• There ground connected to the termination resistors does not match the ground of the devices.

• The Vcc voltage connected to the termination resistors does not match the Vcc of the devices.

• The RS485 device does not support polarity detection. (this is very rare).


Ways to Avoid Polarity Issues:

• Connect positive and negative wires to the device as specified in the manual.

• Ensure proper termination resistors.

• Run a common (ground wire) to all devices and the termination resistors.

• Verify which wire is positive using a multimeter during idle state. Do not assume wire coloring is correct.

If you liked this post;
  • Please consider subscribing to our RSS feed
Posted in RS485

GE-TLC RLINK Connections and Diagnostics

The Field Fail LED Indicates:

  • Relay failure in one of the panels
  • Panel without configuration – no program
  • Driver card failure

Link Fail Indicates:

  • Dataline short or disconnected (missing the 24VDC)
  • Burned interior ¼ Amp fuse – F1
  • Defective unit

At power up the LINK Fail blinks and if the Dataline is clear (24VDC) for 10 seconds, the LINK fail will stop. If there is a BMS controller on-line that polls the network, the Dataline voltage will be below 20 V – which will not allow the LINK to clear. In this case, after a power outage, the BMS interface shall be disconnected till the LINK fail goes off.


  • Pin 2 – White
  • Pin 3 – Blue
  • Pin 4 – Black  (DTR)
  • Pin 5 – Green

Check out the Video:




Multiple GE TLC RLINKS on a Data Line

The TLC dataline communications system supports multiple access points – RLINKS. Each RLINK supports global programming, monitoring and control of the distributed Lighting Automation Panels. However, to avoid conflicts, only one unit (the “Master”) can broadcast the time of day. CAUTION: In a multiple RLINK system, the 2nd, 3rd, …th RLINKs must be configured as “slaves” by moving the internal switch setting as described below. The Master RLINK is connected directly to the primary operator’s PC – The PC which will be used to set the system clock.


Dataline Article img 1

CAS have used 2 Rlinks in master mode successfully

 Changing an RLINK from Master to Slave

1. Remove the two Phillips screws in the rear panel

Dataline Article img 2


2. Slide the board assembly out of the housing as a unit

Dataline Article img 3


3. Move the slide switch in the front right corner  to the “Slave” position

Dataline Article img 4


4. Position the board in the extruded rails and slide back into place, while making sure the “ALARM RESET” button clears the front face plate.

Dataline Article img 5






Building libCUrl on Windows with /MT and /MTd

CUrl and libCUrl is a very powerful library for sending HTTP and HTTPS requests to servers. Building the libraries  on windows with Visual studios using the /MT and /MTd flags is non-trivial. 

Using: curl-7.37.0


  1. Download and extract the CUrl source code to a temp directory., in this tutorial we will be using curl-7.37.0
  2. Open the “Visual Studio Command Prompt (2010)”
  3. Browse to the Winbuilds folder. \curl-7.37.0\winbuild
  4. Type “Set RTLIBCFG=static ” in to the command prompt and hit enter. This will set up the compiler to build for  /MT and /MTd
  5. Type “nmake /f mode=static DEBUG=yes” to build the debug version or
    Type “nmake /f mode=static DEBUG=no” to build the release versions


CAS Gateway – Taking wireshark logs with the CAS Gateway

1) Login to the CAS Gateways web interface and browse to the “System Actions” page /bin/system/
2) Under the debug logging, Change the level level from IMPORTANT (10) to ALL (100),
3) Ensure that the Log to SysLog (UDP: 514) is set to enabled. This is the default setting.

4) Click the “Save” button

5) Click the “Generate configuration File” to download the current configuration from the CAS Gateway.

6) Download and install Wireshark ( on a local computer. Its a free packet capture tool

7) Run Wireshark and click the “Capture Options” button

8) Set the “Capture Filter” to “port 47808 || port 514
9) Set the path to a folder where to store the Wireshark logs. “C:\temp\wireshark logs\2014April28_
10) Check the “Use multiple files” and “Next file every” check boxes. Set the next file every text area to “20“, “megabyte(s)
11) Click the “Start” button on the “Wirehsark Capture Options” dialog. The main dialog should fill up with BACnet messages as well as SysLog messages.
12) Reproduce the problem with the CAS Gateway, This may take a day or two if the problem is infrequent. 
13) Send Chipkin an archive of the Wireshark logs and the CAS Gateway configuration.
Note: Depending on your configuration a HUB (Not a switch or router) maybe required to capture all the information from the CAS Gateway.

How to download the database from the CAS Gateway

  1. Goto the System Action page. http://<ip address>/bin/system/
  2. Click “Save Database” button.
    • This will present you with a XML page that says the action was done correctly.
  3. Go back to the System Action page. http://<ip address>/bin/system/
  4. Click “Export the database from the device” link
    • This should download a database.db file

How to download the configuration from the CAS Gateway

  1. Goto the System Action page. http://<ip address>/bin/system/
  2. Click the “Generate Configuration File” link
    • This will generate the configuration file and redirect you to a page where you can download the newly generated configuration file.
  3. Click “Export Configuration” after the system has finished generating the configuration file.

Write to Out Of Service Property Using CAS BACnet Explorer

This article will describe the steps to use the CAS BACnet Explorer to write to the Out Of Service Property.


1) Open the CAS BACnet Explorer and discover for the device that you would like to write to the Out Of Service Property.


2) Click on the Out of Service Property to select it.


3) Write-Click on the Out of Service Property to bring up the Pop-Menu. Select the “WriteProperty” option.


4) In the Write Property dialog, change the Data Value to either “True” or “False” depending on what value you want to write.


5) Check that the value did change.


Note: If the Out of Service property is not writable, then you may get the Write Access Denied error.

CAS BACnet Explorer Version 2.02aQ

We have updated the CAS BACnet Explorer with the following changes.

  • Proper parsing of Forwarded-NPDU messages allowing the CAS BACnet Explorer to correctly discover devices behind BBMDs and BACnet Routers.
  • Added Cancel Button to all users to cancel long discovers without having to exit and close the CAS BACnet Explorer
  • Added Who-Has discovery method.
  • Added Time Synchronization functionality. Users can now set the local time of a BACnet device through the use of a Time Synchronization message.
  • Can detect if there are duplicate device IDs on the network and provides users information about which devices have the duplicate IDs.
  • Numerous bug fixes.

This new version was be released on Tuesday Dec 10, 2013

FieldServer DH+ FSB4013 Blue-Hose Connection

A 10-serial, 2-Ethernet port, 1 DH+ port protocol translator gateway enables data transfer between serial, Ethernet and Allen Bradley DH+ protocols. An extensive library of drivers provides easy interoperability between a variety of devices used in process control and building automation industries.
The FieldServer is an Allen Bradley DH+ protocol translator/gateway which enables devices using one protocol to communicate with devices using another protocol. An example is a PLC using one protocol needing to supply alarm information to a DCS using Data Highway Plus. In a single, comprehensive package the FieldServer provides the hardware and software necessary for this translation.
The FS-B4013 DH+ gateway includes eight RS-232 ports, two RS-485 ports, two Ethernet (10BaseT) ports, and one Allen Bradley DH+ port to interface to the devices. All the necessary software and instructions for configuration are supplied with the FieldServer. FieldServer Technologies also offers fee based configuration services. Besides Allen Bradley DH+, FieldServer are available for various fieldbuses.
DH+ cables are often called the Blue Hose because of the blue color of the cable made for this purpose. It’s a twisted pair with a shield. The Drained Shield is used for the ground terminal. DH+ is based on RS485 but it isn’t.
Supported Baud Rate: 115.2K Baud rate
DH+ terminal Specification:

Signal- = Blue = Terminal 1 = Terminal closest to white LED
Shield = Clear = Terminal 2
Signal+ = Clear = Terminal 3

Stretch Sensors (Resistors)

A stretch sensor is a cylindrical cord which can be stretched to achieve varying resistances. It’s a sort of variable resistor where the resistance can be adjusted by the intensity of the stretch. Usually when the sensor is stretched by 50% it reaches double it’s initial resistance.

Some stretch sensor applications:

  1. Various stress measuring.
  2. Physics experiments.
  3. Could be used in robotics.
  4. VR suits/gloves.
  5. Biometric displacement reading.
  6. Feedback sensor for air muscles.