BAS-310 · Lesson 3 of 12 · 21 min
BACnet services: reading, writing and subscribing
▶ Video coming soon A video version of this lesson is on the way.
Callie arrived at the third network night on Tuesday, October 6, still thinking about Ninefield's chilled water plant, where that morning she and Prakash had found the plant running at a delta-T of 3.5 K instead of the design 5.5 K. The evidence had come from trends of the two chillers' own leaving and entering water temperatures, which the building system had only been able to collect since August, when Quillon connected the chillers to the network. "Every one of those trend samples is a conversation," Prakash said. "The front end asked, the chiller answered, thousands of times. Tonight is about the conversations."
Clients, servers and services
In BACnet, a service is a standard kind of request and the answer to it. The device that makes the request is the client for that exchange, and the device that answers is the server. The same device is often both: a supervisory controller is a server when the front end reads its schedules and a client when it reads a zone temperature from a VAV controller. The BIBBs of lesson 1 are written in terms of these roles, with A for the client side and B for the server side.
Services are either confirmed or unconfirmed. A confirmed request expects an answer: an acknowledgement, the data asked for, or an error explaining why not. If no answer arrives within the client's timeout, it retries, and after its last retry it gives up and reports a communication failure. An unconfirmed request is sent and forgotten, with no answer expected. Unconfirmed services suit broadcasts, such as asking every device on a network to identify itself, where hundreds of replies to an acknowledgement would be pointless.
| Device property or setting | Typical value | What it controls |
|---|---|---|
| APDU_Timeout | 3,000 to 10,000 ms | How long a client waits for an answer before retrying |
| Number_Of_APDU_Retries | 3 | How many times it retries before giving up |
| Max_APDU_Length_Accepted | 480 bytes on MS/TP; 1,476 on BACnet/IP | The largest single message the device can receive |
| Segmentation_Supported | Both, transmit, receive or none | Whether the device can split and rejoin large messages |
A message too large for one frame, such as a long object list, can be split into segments if both devices support segmentation. A device that does not support it must answer a large request with an abort, and the client must ask for less at a time. Mismatched segmentation is one of the classic causes of a front end that discovers a device but never finishes reading it.
Finding devices and objects: Who-Is, I-Am, Who-Has and I-Have
Before a client can talk to a device it must know where the device is. Who-Is is an unconfirmed request, usually broadcast, that asks devices to identify themselves. It may name a range of device instances, so a technician can ask only for devices between 107000 and 107999. Each matching device answers with an I-Am giving its device instance, its maximum message size, its segmentation support and its vendor. Because I-Am comes back from the device's own address, the client now knows where to send further requests.
Who-Has asks which device contains an object with a given name or identifier, and the device that has it answers with I-Have. Who-Has is useful when a name is known but the device is not, such as finding which controller holds NF.AHU3.DA-T in an unfamiliar building.
Discovery is not free. A Who-Is with no range on a large internetwork produces hundreds of I-Am replies at once, and each router forwards the broadcast to every network it serves. Quillon's technicians used ranges whenever they could, and front ends are normally set to rediscover only when told to.
Reading: ReadProperty and ReadPropertyMultiple
ReadProperty, a confirmed service, asks for one property of one object: device 107023, analog-input 1, Present_Value. The server answers with the value, or with an error such as unknown-object or unknown-property. It is the simplest service in BACnet and every device must answer it.
ReadPropertyMultiple asks for several properties of several objects in one request: the Present_Value and Status_Flags of ten objects, for example. One request and one answer replace twenty exchanges, which matters enormously on a slow MS/TP trunk where each exchange has to wait for the token. Most front ends and supervisory controllers use ReadPropertyMultiple whenever the server supports it, and fall back to single reads when it does not. Whether a device supports it is in its PICS.
Client 900001 -> Server 107023 ReadPropertyMultiple-Request invoke-id 17
analog-input,1 [Present_Value, Status_Flags]
analog-input,2 [Present_Value, Status_Flags]
analog-output,1 [Present_Value]
Server 107023 -> Client 900001 ReadPropertyMultiple-ACK invoke-id 17
analog-input,1 Present_Value 22.6 Status_Flags {F,F,F,F}
analog-input,2 Present_Value 131.0 Status_Flags {F,F,F,F}
analog-output,1 Present_Value 38.0The invoke ID in the trace is a number the client puts in each confirmed request so that it can match the answer to the question when several requests are outstanding. Seeing the same invoke ID repeated in a capture means the client is retrying, usually because the first answer never arrived.
Writing: WriteProperty
WriteProperty, also confirmed, writes one value into one property, such as a new cooling setpoint into an Analog Value's Present_Value. For commandable objects such as outputs, the request includes a priority from 1 to 16, and the value goes into that slot of the object's priority array instead of directly into Present_Value. Lesson 7 explains how the priority array decides which written value wins. A write without a priority to a commandable object is treated as priority 16, the lowest.
WritePropertyMultiple writes several values in one request. Front ends use it to send a set of setpoints, and supervisory controllers use it to send a schedule's results to many controllers at once. As with reading, combining requests saves time on slow networks.
A server refuses writes it cannot accept and says why: write-access-denied for a read-only property, value-out-of-range for a value outside the property's limits, or a password error on devices that protect certain properties. An integration plan should list exactly which properties the building system is allowed to write, and the server's answers are how a technician confirms that it is.
Subscribing: change of value
Lesson 2 introduced change of value. The service that sets it up is SubscribeCOV. The client asks a server to report changes to one object, gives a lifetime for the subscription, and says whether it wants confirmed or unconfirmed notifications. The server then sends a COV notification immediately with the current value, and again each time the value changes by the COV_Increment or its Status_Flags change, until the lifetime expires. The client must renew the subscription before then, or it silently stops receiving data.
Change-of-value reporting cuts traffic dramatically for values that change slowly, such as zone temperatures, and gives faster updates for values that change suddenly, such as a fan status. It has two weaknesses. A device can only hold a limited number of subscriptions, listed in its documentation, so a front end and three supervisory controllers all subscribing to the same controller can run out of space. And a subscription that is not renewed stops without warning, which is why a point that has not changed for hours should prompt a check rather than reassurance.
Worked problem
Polling against change of value for a floor of VAV boxes
A supervisory controller reads the zone temperature of 140 VAV controllers once a minute with single ReadProperty requests. Each read is one request and one answer. How many messages does that make in a day? If change of value with a sensible increment averages about 12 notifications per zone per day, plus a renewal of each subscription every hour (one request and one answer), how many messages is that?
Show solution
- Polling: 140 reads a minute × 60 × 24 = 201,600 reads a day, each with a request and an answer: 403,200 messages.
- Change of value: notifications 140 × 12 = 1,680; renewals 140 × 24 = 3,360, each a request and an answer: 6,720 messages.
- Total for change of value: 1,680 + 6,720 = 8,400 messages.
Answer: About 8,400 messages a day against more than 400,000, a reduction of roughly 48 times. On a slow trunk shared by dozens of devices, that difference decides whether the network keeps up.
Other services a technician meets
| Service | Type | What it does |
|---|---|---|
| ReadRange | Confirmed | Reads a range of records from a list, most often a Trend Log's stored history |
| ConfirmedEventNotification and UnconfirmedEventNotification | Both | Send alarms and events to the recipients in a Notification Class |
| AcknowledgeAlarm | Confirmed | Records that an operator has acknowledged an alarm |
| GetEventInformation | Confirmed | Asks a device for all its active alarms and events |
| TimeSynchronization | Unconfirmed | Sets the clock in other devices, so schedules and trends agree |
| DeviceCommunicationControl | Confirmed | Tells a device to stop or restart communicating, usually password protected |
| ReinitializeDevice | Confirmed | Restarts a device, or starts and ends a backup or restore, usually password protected |
| AtomicReadFile and AtomicWriteFile | Confirmed | Read and write files, used by some tools for backups and programs |
DeviceCommunicationControl and ReinitializeDevice deserve respect. Sent to the wrong device, the first can silence a controller until someone restores it, and the second can restart a plant controller in the middle of a cold morning. Most devices protect them with a password, which belongs in the job records, not on a sticky note on the panel.
Callie asked how she would ever see these conversations. Prakash turned the laptop toward her and opened a capture he had taken at the bench earlier: page after page of requests and answers, each decoded into plain words. "Lesson 11's tools," he said. "For now, just know that every value on every graphic got there by one of these services."
Alarms and events as services
Alarms in BACnet use their own group of services. A device that detects an alarm condition itself, by comparing an input with limits set in the object, uses what the standard calls intrinsic reporting. The limits, deadband and delay sit in properties of the object, and the alarm is sent to the recipients listed in a Notification Class object. That object sets the priority of the alarm, whether it needs acknowledgement, and which devices receive it on which days and at which times.
The notification itself is an event notification service, sent confirmed or unconfirmed depending on the Notification Class setting. A confirmed notification is answered, so the sender knows the front end received it; an unconfirmed one is not, which is why alarms that matter are normally sent confirmed. The operator's acknowledgement returns to the device through the AcknowledgeAlarm service. When a front end restarts, it can ask each device for its current alarms with the GetEventInformation service, so that alarms raised while it was off are not lost.
| Service | Who asks | What it does |
|---|---|---|
| ConfirmedEventNotification | The device in alarm | Reports an alarm or return to normal and waits for an answer |
| UnconfirmedEventNotification | The device in alarm | Reports an event without waiting for an answer |
| AcknowledgeAlarm | The front end | Records that an operator has acknowledged the alarm |
| GetEventInformation | The front end | Asks a device for every active or unacknowledged event |
Timeouts, retries and segmentation in practice
Every confirmed request has a timer. If no answer arrives within the device's APDU timeout, the client sends the request again, up to its configured number of retries, and then reports the device as not responding. Common settings are a few seconds of timeout and three retries, so a device that has really gone needs some seconds before the front end gives up on it. On a slow or busy MS/TP trunk, a timeout set too short causes retries that add yet more traffic, which is one reason lesson 11 counts retries in captures.
Segmentation matters when an answer does not fit in one message. A ReadPropertyMultiple asking for many properties may produce an answer longer than an MS/TP device's maximum of 480 octets. If both devices support segmentation, the answer is sent in pieces; if either does not, the server returns an error and the client must ask for less at a time. Front ends usually learn each device's limits from its Device object and size their requests to match, but a gateway or a newly integrated product that reports its limits wrongly can cause reads that fail only for certain groups of points.
Common mistakes
MistakePolling slowly changing values every few seconds.
InsteadUse change of value, or poll at a rate that matches how fast the value matters.
MistakeForgetting that COV subscriptions expire.
InsteadMake sure the client renews them, and investigate points that stop changing.
MistakeBroadcasting Who-Is with no range on a large internetwork.
InsteadUse instance ranges and rediscover only when needed.
MistakeWriting to a commandable object without choosing a priority.
InsteadWrite at the priority agreed in the integration plan; no priority means 16.
MistakeSending ReinitializeDevice casually.
InsteadConfirm the device and the timing, and keep passwords in the job records.
Summary and key terms
- A service is a standard request and response; the requester is the client and the responder the server.
- Confirmed services expect an answer and are retried after a timeout; unconfirmed services expect none.
- Who-Is and I-Am find devices; Who-Has and I-Have find objects.
- ReadProperty reads one property; ReadPropertyMultiple reads many in one exchange and saves time on slow networks.
- WriteProperty writes one value, with a priority for commandable objects.
- SubscribeCOV sets up change-of-value reporting for a lifetime that must be renewed.
- ReadRange reads trend history; event services carry alarms; some management services need passwords and care.
- Service
- A standard BACnet request and its response.
- Client
- The device that makes a request in an exchange.
- Server
- The device that answers a request in an exchange.
- Confirmed service
- A request that expects an answer and is retried if none arrives.
- Unconfirmed service
- A request sent with no answer expected.
- Who-Is and I-Am
- The request that asks devices to identify themselves, and their reply.
- ReadPropertyMultiple
- A service that reads several properties of several objects in one exchange.
- SubscribeCOV
- A service asking a device to report changes in an object for a set lifetime.
- Segmentation
- Splitting a message too large for one frame into parts.
- Invoke ID
- A number in a confirmed request that matches it to its answer.
Practice problems
Work each problem on paper first, then reveal the answer to check.
A front end polls 60 points every 30 s with single reads. How many reads a day?
Show answer
60 × 2 × 60 × 24 = 172,800 reads.
A device answers a large request with an abort. What is the likely cause?
Show answer
The message needs segmentation that one of the devices does not support.
A point has not changed for six hours although the room is in use. What should you check?
Show answer
Whether its COV subscription has expired or the device has run out of subscriptions.
Which service reads a trend log's history?
Show answer
ReadRange.
Why is Who-Is an unconfirmed service?
Show answer
It is broadcast; acknowledgements from every device would flood the network.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.