Author Archive for pchipkin

FieldServer Modbus TCP - Device / Station Address (ID) 0 (Zero)

Many Modbus TCP clients send polls with the Station / Device address (ID) set to zero.

Fieldserver’s cannot be configured as station zero so they cannot respond. There is a work around. Set the FieldServer Node_ID parameter to a value of 239. When Modbus TCP messages are received, the FieldServer looks at the one byte station number. If it is zero it changes the byte to 239 and then passes the message for processing by the driver. Thus if the server node is configured as 239 the FieldServer can respond correctly.

One example of a Modbus Client that sends requests to station zero is the EZ Touch Panel HMI from EZAutomation.net

Did you like this post?

Subscribe To The RSS Feed!
To catch many more articles like this in the future, make it easy on yourself and subscribe to me via RSS. You will not regret it!

Do you have a question?
We will do our best to try and solve any building automation, protocol, integration problem you may have

How do you put more than 32 devices on a single RS485 trunk ?

The simple answer is use a repeater but in practice one isn’t always necessary.

The RS485 standard is based on 32 devices. Since the standard was developed most RS485 chips present less than the full unit load originally specified. Today you get half and quarter load devices. Thus to see how many devices you can install you simply get the data sheets and add the loads. Look for “UL” on the data sheet. It stands for Unit Load.

Did you like this post?

Subscribe To The RSS Feed!
To catch many more articles like this in the future, make it easy on yourself and subscribe to me via RSS. You will not regret it!

Do you have a question?
We will do our best to try and solve any building automation, protocol, integration problem you may have

Simplex 4100u FieldServer Configurations

When simplex 4100U’s are networekd together the configuration of a FieldServer needs special considerations.

Follow these steps

1. Use the correct input doc. It must say ‘HW Ref’. This is the only report that can be used.

Sim4100 Input Report

2. Use the HW Ref column to work out which card-point-subPoints you need to capture in the configuration.

You will need one Map Descriptor for each card. 

3. Points from networked panels lose their original HW ref and get a new based on the network card.

For example if the network card is card 3 then all the points from the remote panels will come in as card=3.

The HW Ref will be 3-xxxxx

The trick is to convert the xxxxx to a point-SubPoint address so you can work out where the event will be stored in the data array.

4. Make a Map Descripto to cpature events from card 3.

Map_Descriptors
Map_Descriptor_Name ,Data_Array_Name ,Data_Array_Offset ,Function ,
Node_Name  ,sim4100_func ,sim4100_card ,sim4100_point ,sim4100_sub ,
protocol ,length ,Card_03_Points ,DA_CARD3 ,0 ,passive  ,Simplex_01 ,
xpoint ,3 ,0 ,256 ,sim4100 ,20000

There can only be one Map Desc for card 3.

Always set point to zero

Set SubPoint to 256 for networked points. (This means the driver expects 256 subpoints per point)

5.  Determine the Data Array Offset where a point’s event will be stored.

Convert the HW Ref to Point-SubPoint

For example:

Input Doc: 3-14126      3:M4-78-0        RIAM          RELAY           L2 BAK/CHE T2.035 CORR BY MEET RM B7.011

HW Ref=3-14126 so we know the card=3

temp=14126

temp2 = temp - 1

point = trunc(temp2/256)   trunc=truncated division. Rounds down.

subPoint = temp - point *256

Offset into Data Array = (point+1)*256+subPoint

Thus in this example: Offset=14381. When the point has an event, the data will be stored in DA_CARD3[14381].
 
 

Did you like this post?

Subscribe To The RSS Feed!
To catch many more articles like this in the future, make it easy on yourself and subscribe to me via RSS. You will not regret it!

Do you have a question?
We will do our best to try and solve any building automation, protocol, integration problem you may have

What can go wrong with 485 and BACnet MSTP ?

Lets say you adopted all the best practices for installation of the network but you get intermittent or unacceptable performance because of packet loss, noise, collisions … Then you should consider hiring an expert to resolve your problems because now you are in the ‘Art’ part of RS485. These are some of the things they will look at.

Reflections

Without a scope and expertise you wont know this is a factor. Its easy and cheap to eliminate. Look at the cable spec. Find the nominal impedance. Buy two resistors of the same value. At each end of the trunk install the resistors between the Tx and Rx terminals. If you don’t have obvious ends of the trunk (because you created a star) then we recommend re-cabling to form a linear trunk or we wish you luck.

Some devices have terminating resistors built into them. If the vendor did a poor job, the default is to have the resistor active and they must be disabled unless they are the terminating devices on the network. Read vendor docs.

Biasing , Idle State Biasing, Fail Safe Biasing, Anti Aliasing

 There are a whole string of terms uses as synonyms to describe this phenomenon.

To use two wires ( as opposed to full duplex 4 wire) for RS485 each devices transmitter and receiver must be set to an idle state to release the line for others use. Releasing the line means allowing it to ‘float’. It must not be allowed to float at any voltage level so devices have pull up/down resistors to pull the line to an allowable ‘floating’ voltage. (the floating state is also known as the tri-state. )  The load presented by other devices on the network affects this floating so the resistor values may need to be changed depending on the number of devices installed and the values of the pull up/down resistors they are using. (You can imagine how tricky its going to be to resolve this). If a device floats out of the specified range then to other devices it will look like the floating devices isn’t floating at all. The other devices will think that it is transmitting or receiving and thus blocking the line.

The simplest way of knowing if this is a factor - Does the device work properly when it is the only device on the network ?. When you install it in the full network other devices or this device stops working properly. This device and/or the pull up/down resistors of other devices are candidates for investigation.

A number of vendors have a range of pull up/down resistors installed and allow you to change the selection using software or jumpers.
 

Line Drive On / Off

To use two wires for RS485 each devices transmitter and receiver must be set to an idle state to release the line for others use. When a device wants to send it must grab the line. When it has finished sending it must release the line. You can see there are potential problems here. What happens if one device waits too long after sending its last bit before releasing the line - its possible that the other devices will miss some bits of data.

Did you like this post?

Subscribe To The RSS Feed!
To catch many more articles like this in the future, make it easy on yourself and subscribe to me via RSS. You will not regret it!

Do you have a question?
We will do our best to try and solve any building automation, protocol, integration problem you may have

BACnet MSTP (RS485), Cable selection does make a difference.

All cables offer impedance (resistance). Some cables are designed so that the impedance is relatively independent of distance. You want one of these cables. A clue to knowing if you selected one is to look at the cable’s Nominal Impedance. If they quote a number such a 100Ohms you have a good cable. If they quote an impedance per meter/foot you have chosen the wrong kind. Wrong in the sense – to determine the value of terminating resistors now requires measurements and calculations. Choose low capacitance cables.

Can you use Cat5 cable ? Yes. Use one pair for Tx,Rx and a conductor from another pair for the ground reference signal.

We recommend these two cables.

Belden 3106A

Belden 3106A - RS485 Cable 

Multi-Conductor - EIA Industrial RS-485 PLTC/CM
22 AWG stranded (7×30) tinned copper conductors, Datalene® insulation, twisted pairs, overall Beldfoil® shield (100% coverage) plus a tinned copper braid (90% coverage), drain wire, UV resistant PVC jacket. 
 

Belden 3107A

Belden 3107A - RS485 Cable 

Multi-Conductor - EIA Industrial RS-485 PLTC/CM
22 AWG stranded (7×30) tinned copper conductors, Datalene® insulation, twisted pairs, overall Beldfoil® shield (100% coverage) plus a tinned copper braid (90% coverage), drain wire, UV resistant PVC jacket.

Did you like this post?

Subscribe To The RSS Feed!
To catch many more articles like this in the future, make it easy on yourself and subscribe to me via RSS. You will not regret it!

Do you have a question?
We will do our best to try and solve any building automation, protocol, integration problem you may have

Cable Lengths and Baud Rates for RS485 or BACnet MSTP

Practically speaking you can go up to 4000 feet (1200m) at baud rates up to 76800 baud. Above that you need to do a little math and reduce the length. For example, at 115k baud your cable should not be much longer than 2500 feet.

However, the higher the baud rate the more sensitive the cable is to the quality of installation – issues like how much twisted pair is unwound at each termination start to become very very important.

Our advise: For longer networks with lots of devices, choose 38k400 baud over 76k800 baud and optimize using COV, separate networks and by setting the Max Master to a lower number.
RS485 Cable Length Vs Distance

Image Source: Ten Ways to Bulletproof RS-485 Interfaces National Semiconductor
Application Note 1057 John Goldie October 1996

What about BACnet MSTP ?

This is how the 2004 version of the spec defines the MSTP medium:

“An MS/TP EIA-485 network shall use shielded, twisted-pair cable with characteristic impedance between 100 and 130 ohms. Distributed capacitance between conductors shall be less than 100 pF per meter (30 pF per foot). Distributed capacitance between conductors and shield shall be less that 200 pF per meter (60 pF per foot). Foil or braided shields are acceptable. The maximum recommended length of an MS/TP segment is 1200 meters (4000 feet) with AWG 18 (0.82 mm2 conductor area) cable. The use of greater distances and/or different wire gauges shall comply with the electrical specifications of EIA-485.”

 In other words, if it complies with the RS485 spec it meets the BACnet spec.

The cable gauge only changes the cables impedance. You should already be selecting a cable whose nominal impedence is relativly independent of length such as Belden 3106a. If you are using the correct cable then the gauge should have little effect on the carrying capacity except at very high frequencies.

Did you like this post?

Subscribe To The RSS Feed!
To catch many more articles like this in the future, make it easy on yourself and subscribe to me via RSS. You will not regret it!

Do you have a question?
We will do our best to try and solve any building automation, protocol, integration problem you may have

BACnet Objects and Properties

Data inside a BACnet device is organized as a series of objects. Each object has a type and a set of properties. There is always at least one object in a device – it is used to represent the device itself . The other objects represent the device’s data.

In practical terms think of a simple thermostat. Our example is a simple device that has a temperature sensor, allows the set point to be changed locally or remotely, has a local remote selection and reports there is an internal fault by reporting its status as normal/abnormal.

Commonly used properties
Object Type:  Popular Object Types: Analog Input, Analog Output, Binary Input, Binary Output.

Instance Number:  A number that must be not be repeated for any other object of the same type.
Name: The optional property called ‘Description’ is usually used to describe the object. This porperty is often no more than a tag.
Present Value: The current value of the object. BACnet has ways of telling you if the present value is valid – it uses a property called ‘Reliability’.

Did you like this post?

Subscribe To The RSS Feed!
To catch many more articles like this in the future, make it easy on yourself and subscribe to me via RSS. You will not regret it!

Do you have a question?
We will do our best to try and solve any building automation, protocol, integration problem you may have

Changing the BACNet Present Value (Or Why the Present Value doesn’t change)

All devices on a BACNet network are effectively peers. This means that any device (we take device here to mean any Bacnet capable entity – device or software application) can write to the writable properties of another device’s objects. This can result in conflicting commands.

BACnet has a mechanism to resolve the conflict. It differentiates between writable and commandable properties and the conflict resolution only applies to commandable properties. For writable ( and non-commandable properties) the last write wins and overwrites any previous writes – there is no conflict resolution.

Which properties are commandable and how does the command resolution work ?

• The Present Value of AO, BO, MO objects are always commandable.
• The Present Value of AV, BV, MV objects are commandable if the vendor implemented  them that way. It’s a vendor choice.  You can tell what choice they made by looking for the Priority_Array and Relinquish_Default properties on the object. That’s a clue but not a guarantee (we have found). Last resort is their documentation. (good luck).
• A vendor may choose to make any vendor (proprietary) property commandable.  If a property is commandable then it is required to have appropriately named Priority_Array and Relinquish_Default properties.

If an object has a Present Value that is commandable then it also has two additional properties ; Priority Array and Relinquish Default. These two properties are used to resolve command conflicts.

When a write is sent to a commandable point it always contains a priority. If the priority is not specified then the priority is assumed to be the lowest. There are 16 priorities. 16 is the lowest. On restart each slot in the array is set to a Null (unused) state. When the command is received the BACnet device updates the slot in the Priority Array that corresponds to the commanded priority with the new value.

The device continuously looks thru the priority array of each commandable property and looks for the highest priority slot that is non Null. It uses that value to update the Present Value. Now its easy to understand why the command you sent to an objects Present Value has no effect. You may have commanded with a priority lower than the one currently in use.

How to you empty a priority slot ? You send a command to the point to relinquish (give up control). This is like a normal command – its specifies a value ( a special value – Null ) and a priority. The device frees the Priority Array slot that corresponds to the relinquished priority. There are 3 possible outcomes to a relinquish – 1) There is no change to the Present Value because the relinquished priority is lower than the one in use 2) The Present Value changes because the relinquished command was at a higher priority than another commanded value. 3) All the Priority Array slots are now Null (unused). In this case the device uses the value of the Relinquish Default property to set the value of the present value.

What happens if two remotes device command at the same priority ? The last command wins, overwriting the value in the Priority Array for the given priority ? The same applies to relinquishing – the first relinquisher wins. How do you avoid this ? Assign different devices, application or functions different priorities. These choices are site specific. BACnet does names the priorities to suggest a use but how they are used is up to you – the implementor.

Some Objects that have commandable Present Values also have properties that define a minimum on and/or off time. When either of these are present it could affect the outcome of the write you send to the Present Value. A full description of this behavior will be provided in a subsequent article.

Worked Example:

The Relinquish Default Value is set by the device. The Vendor may choose to make it a writable property in which case in can be changed remotely. Even though the present value is commanded the device stores the commanded value in the priority array and uses the highest priority array slot to set the Present Value.

Relinquish Default Example - Figure 1

In our example, the device boots, the Priority array slots are all Null (Unused) and this vendor has set the Relinquish Default to 50. Since all the slots are null the device sets the Present Value to the Relinquish Default Value. The Present Value changes to 50.
Relinquish Default Example - Figure 2

Now a command is sent to set this objects Present Value to 45 at Priority 5. The device sets slot 5 in the Priority Array to 45. It then starts at the highest priority (1) and looks for the 1st non Null slot. It finds slot 5 filled with 45 and sets the Present Value to 45.

Relinquish Default Example - Figure 3

Now a new command is sent to set this objects Present Value to 70 at Priority 8. The device sets slot 8 in the Priority Array to 70 . It then starts at the highest priority (1) and looks for the 1st non Null slot. It finds slot 5 filled with 45. Thus there is no change to the Present Value to 45.
Relinquish Default Example - Figure 4

Now a command is sent to Relinquish the command at Priority 5. One would hope that the device that sent the original command sent the relinquish command but that is up to you and how you configured you system.  When the relinquish command is received, the device sets the corresponding slot in the Priority Array to Null. The device then starts at the highest priority (1) and looks for the 1st non Null slot. The device finds slot 8 filled with 70. It changes the Present Value to 70.
Relinquish Default Example - Figure 5

The most recent command at a specific priority wins. Here a command is sent to set the Present Value to 80 at priority 8. The device overrides slot 8 in the array with the new value. In this case it is also the highest priority slot that is used so the device updates the Present Value to 80.
Relinquish Default Example - Figure 6

Finally, a command is sent to relinquish the command at priority 8. Slot 8 is set to Null and when the device looks through the priorty array it finds it all empty and it thus uses the Relinquish Default value to set the Present Value to 50.
Relinquish Default Example - Figure 7

This mechanism can be complicated if the object has minimum on/off times.

Did you like this post?

Subscribe To The RSS Feed!
To catch many more articles like this in the future, make it easy on yourself and subscribe to me via RSS. You will not regret it!

Do you have a question?
We will do our best to try and solve any building automation, protocol, integration problem you may have

BACnet MSTP - Bandwidth usage - How many devices on a network.

How many devices to install on a single RS485 Trunk (Bandwidth Issues). There are non electrical considerations to determine how many devices you put on an MSTP network.

The chart below illustrates (from one installation) how little of the bandwidth is used to transfer data. The APDU’s are application layer message that poll and respond with property values - they do work for us as data consumers. The rest is used to maintain the network - passing the token around and looking for new devices.

Pie Chart Showing MSTP Bandwidth Usage

 

 

It’s not possible to provide a calculator to work out how many devices to install on a single network but the following list provides some help in assessing bandwidth considerations.

  • How many of the devices will be BACnet slaves.

Token passing and looking for new devices on the MSTP trunk consumes a fair amount of bandwidth.

A BACnet slave can be read/written but never gets token so it cant initiate any messages because it never gets the token. The more slave the fewer token passes. Typically you are not able to put a device in slave mode. Most vendors implement their devices as masters (ie token passing devices)

  • How many Objects in each device are you interested in monitoring ?

The more you read and the greater the frequency the more bandwidth that will be consumed.

It takes approx 30 bytes to poll for a single property. It takes about 40 bytes to reply. A token is 8 bytes as is a Poll for master.
Assume that 50% of your bandwidth will be used by overhead (token, poll for master).
Divide the baud rate by 10 to get bytes per seconds.
Using a number like 30+40=70 as a best case and 100 as a worst case (obviously reading descriptions will take more) multiply by the number of objects and properties you are going to poll on a regular basis.

Here are some typical numbers assuming device doesn’t support the ‘multiple’ services (see below).

  • How many properties from each of these objects ?
  • What is the baud rate?
  • What is Max Master Set to?

Every few cycles each (master) token passing device on the network must look to see if there are new devices. Max Master determines the biggest address that must be searched for. Each search involves sending a message and waiting for a response or a timeout (if the devices isn’t there). Timeouts cost time. The higher the number of Max Master (default is 127) the more potential devices must be searched for. If you use Max master to improve bandwidth then you must adjust it in each device.

  • Do the devices support the “Read/Write Property Multiple” services or must each property be read in a separate message?

Every few cycles each (master) token passing device on the network must look to see if there are new devices. Max Master determines the biggest address that must be searched for. Each search involves sending a message and waiting for a response or a timeout (if the devices isn’t there). Timeouts cost time. The higher the number of Max Master (default is 127) the more potential devices must be searched for. If you use Max master to improve bandwidth then you must adjust it in each device.

Obviously, if you can read a chunk of properties in one message you will be better off than if you can only read a single one.

  • Can you use BACNet’s COV mechanism?

COV stands for Change of Value. When a device supports COV another device / application can subscribe to receive notifications when an object property changes. This means the data client doesn’t have to poll for data continuously but can wait passively to be notified of the change. This reduces the number of messages on a network dramatically.

  • Some devices are slower than others.

BACnet allows up to 15 msec for a device to use the token. Since most messages on a MSTP network are token passes a device that uses the token in 5 msec will consume much less bandwidth than one that takes 15msec. (A number of vendors relax this requirement to allow for other vendors implementations. The more relaxed the more bandwidth is consumed doing nothing.)

Did you like this post?

Subscribe To The RSS Feed!
To catch many more articles like this in the future, make it easy on yourself and subscribe to me via RSS. You will not regret it!

Do you have a question?
We will do our best to try and solve any building automation, protocol, integration problem you may have

How does BACnet MSTP discover new devices on a network ?

(To provide clarity this article does simplify the issues to some extent.)

BACnet MSTP is a token passing protocol. Only nodes with the token are allowed to initiate service requests such as requests for data. A device that receives a request, a request that requires a response, may respond without having the token.

 

Based on this behavior it is easy to understand the difference between a MSTP master and slave. A slave is a device that can only send responses. A master is an initiator of a service request.

 

Only allowing masters to initiate a message exchange when they have the token provides a mechanism whereby there can be multiple masters on a network and contention or collision can be avoided. Ethernet uses a different system – it allows collisions and provides a recovery mechanism. Imposing rules on the token passing such as specifying how much a master can do while it has the token provides a mechanism to balance the performance of various devices on a single network.

 

Back to the question of how new devices are added to the network. If you add a new slave device then you will need to program at least one master on the network to exchange data with that slave. The master needs to be programmed specifically to read that slave since slave devices don’t support discovery. (That’s one of the reasons that most field devices are not slave devices.)

 

If you add another master it needs to receive the token before it can act like a master but the other devices on the network need to discover the new device first. Every master on the network, has the job, of periodically polling for a new master.

 

Each master knows who the next master on a network is, because that is who it will pass the token to. So, each master, must poll for masters that could exist in the address range that exists between its own address and the next master’s address. Thus a master addressed as 1 must look for master’s in the range 2 to 10 if the next known master is 11. Master number 11 must look for new masters starting at 12 etc. The master with the highest number must try masters …,127,0…… When a device receives a poll asking if it is a master (Called a ‘Poll for Master’ message) it replies immediately. In the above example, if master number 1 cant find a master number 2 it should try number 3.

 

When should it try ? That’s a choice that is left up to the implementor of the BACnet protocol on that device. The spec only demands a minimum of 1 Poll for Master every 50 times a master receives or uses the token. The new master must respond within 20 milliseconds.

 

You can see, that if every master polls for a large number of new masters and they do this often then lots of bandwidth is lost. For this reason BACnet MSTP has a parameter called Max Master. Each master has its own setting for this variable. Typically it is set at 127 but imagine that master number 50 is the highest master on the network, and its Max Master is set to 64. Then it will never discover a new master whose address is larger than its max master, ie it will never discover master with address 65 to 127. This is a common reason why a new device on a network is not discovered.

 

 

How often should a master search ?

http://www.chipkin.com/articles/how-often-should-a-bacnet-mstp-device-search-for-a-new-master

 

You may also wish to read our article on duplicate Mac Address and Device Instance Numbers. 2 BACnet MSTP devices with the same device ID

 

Did you like this post?

Subscribe To The RSS Feed!
To catch many more articles like this in the future, make it easy on yourself and subscribe to me via RSS. You will not regret it!

Do you have a question?
We will do our best to try and solve any building automation, protocol, integration problem you may have