BAS-310 · Lesson 4 of 12 · 23 min
BACnet MS/TP networks
▶ Video coming soon A video version of this lesson is on the way.
On Tuesday, October 13, Callie had spent the day on Ninefield's VAV floors, and that evening Prakash brought the trunk from the seventh floor back into the conversation. On September 21, in BAS-210, they had found a replacement box controller left at the factory MAC address 3, the same address as VAV-7-03, with its terminating resistor switched on and a 40 ft stub wired to a new box. "You fixed the wiring that day," Prakash said. "Tonight you find out why one wrong address made half the floor drop out." He wrote three words on the whiteboard: master, slave, token.
What MS/TP is
MS/TP, short for Master-Slave/Token-Passing, is BACnet's network type for twisted-pair wiring. It runs over EIA-485, the electrical standard BAS-210 described: a daisy-chained, shielded twisted pair with a terminating resistor at each end, typically up to 4,000 ft per segment at common speeds. It is cheap, it reaches every corner of a building on one pair of wires, and it is still the most common way to connect terminal unit controllers and many equipment controllers. It is also slow compared with Ethernet, and its rules for taking turns explain most of its quirks.
Only one device on an EIA-485 pair can talk at a time; if two talk at once, both messages are destroyed. MS/TP solves this by passing a token, a short message that gives its holder permission to send. A device that holds the token may send a limited number of messages, then passes the token to the next device. Every device gets its turn, nobody talks over anyone else, and the time each device waits depends on how many other devices there are and how much each has to say.
Masters, slaves and MAC addresses
Each device on a trunk has a MAC address, a number that identifies it on that trunk only. MS/TP addresses run from 0 to 254, with 255 reserved for broadcasts. Addresses 0 to 127 are for masters, which take part in passing the token. Addresses 128 to 254 are for slaves, which never hold the token and can only answer when a master asks them something. Almost every modern controller is a master; slaves are rare, usually simple sensors.
MAC addresses must be unique on the trunk. Two devices with the same address answer the same messages at the same time and pass the token at the same time, which garbles both. That was the September 21 fault: when the token reached address 3, two controllers tried to use it, their replies collided, the next device in line never received a clean token, and the trunk spent its time recovering instead of carrying data. Every device beyond the collision appeared offline at the front end, on and off, for days.
How the token travels
The token passes in order of MAC address. Each master passes it to the next higher address it knows about, and the master with the highest address passes it back to the lowest, so the token goes round the trunk in a loop. When a master holds the token it may send up to Max_Info_Frames messages, a property in its Device object whose default is 1, and must then pass the token on. A master with a lot of traffic, such as the supervisory controller or router that serves the front end, is usually given a higher Max_Info_Frames so that it can send several requests per turn.
Masters must also find new devices. Every so often, instead of passing the token straight to the next known master, a master sends a Poll For Master message to an address in the gap between itself and the next known master. If a new device answers, it joins the loop. The highest-addressed master polls the addresses above it, up to the value of its Max_Master property, whose default is 127. A master never polls above Max_Master, and a device with an address above every master's Max_Master is never found.
If the token is lost, perhaps because the device holding it lost power, the trunk falls silent. After a set silence, called Tno_token and equal to 500 ms in the standard, the masters regenerate a token, the lowest address claiming it first, and the loop starts again. A trunk that keeps losing its token, from collisions, noise or a duplicate address, spends much of its time in this recovery.
The MS/TP frame
Every MS/TP message is a frame with a fixed header and, if it carries data, a data field and a data check. Each byte, called an octet in the standard, travels as ten bits on the wire: a start bit, eight data bits and a stop bit, with no parity.
55 FF preamble
00 frame type 0 = Token
17 destination MAC 23 (hex 17)
16 source MAC 22 (hex 16)
00 00 data length 0
hh header check
Frame types seen most often: 00 Token, 01 Poll For Master, 02 Reply To Poll For Master,
05 BACnet Data Expecting Reply, 06 BACnet Data Not Expecting Reply, 07 Reply Postponed| Baud rate (bits per second) | Time for one octet | Typical use |
|---|---|---|
| 9,600 | 1.04 ms | Old or very long trunks; the speed every device must support |
| 19,200 | 0.52 ms | Older equipment |
| 38,400 | 0.26 ms | The most common speed for terminal unit trunks |
| 76,800 | 0.13 ms | Newer trunks with good wiring |
Every device on a trunk must use the same baud rate. A device set to 9,600 on a 38,400 trunk hears only noise, and its attempts to answer corrupt other devices' frames. Many controllers can detect the trunk's speed automatically when they first power up, which is convenient until one detects it wrongly while someone is testing at another speed.
Worked problem
Timing on an MS/TP trunk
Ninefield's seventh-floor trunk runs at 38,400 bits per second. After the fault was fixed it had 24 masters: the router port at MAC 0 and 23 controllers, the highest at MAC 23. (a) How long does one token frame take on the wire? (b) If each master adds about 1 ms between receiving the token and passing it on, how long does the token take to go round when nobody has data to send? (c) A ReadProperty request of 27 octets and its 32-octet answer, including headers and checks: how long do they take on the wire?
Show solution
- (a) 8 octets × 10 bits = 80 bits; 80 ÷ 38,400 = 0.00208 s, about 2.1 ms.
- (b) 24 × (2.1 + 1.0) = 24 × 3.1 = 74 ms per rotation.
- (c) Request 27 × 10 ÷ 38,400 = 7.0 ms; answer 32 × 10 ÷ 38,400 = 8.3 ms.
Answer: An idle loop takes about 74 ms. A read costs about 15 ms on the wire, but the requester must also wait for its next turn with the token, so a busy trunk with dozens of devices can take hundreds of milliseconds to answer one question. Multiply that by hundreds of points and the case for ReadPropertyMultiple and change of value is clear.
Max_Master and why it matters
Max_Master is set in every master, and leaving it at the default of 127 on a small trunk wastes time. The highest master polls every empty address above it up to 127, one address per turn, and each poll of an empty address waits for a reply that never comes, a wait the standard sets at 20 ms or a little more.
Worked problem
The cost of leaving Max_Master at 127
The highest master on Ninefield's seventh-floor trunk is the new box controller at MAC 23. With Max_Master at 127, how many empty addresses does it poll, and roughly how long does a full sweep of them take if each poll is a 2.1 ms frame plus a 20 ms wait? What if Max_Master is set to 31?
Show solution
- Empty addresses above 23 up to 127: 127 − 23 = 104.
- Time per empty poll: 2.1 + 20 = 22.1 ms; full sweep 104 × 22.1 = 2,298 ms, about 2.3 s, spread over 104 token rotations.
- With Max_Master 31: 31 − 23 = 8 empty addresses, 8 × 22.1 = 177 ms.
Answer: Setting Max_Master to just above the highest address in use, with a little room for growth, cuts the wasted polling by more than 90 in 100. Every master on the trunk must have a Max_Master at least as high as the highest address in use, or devices above it are never found.
Quillon's trunk rules followed from this. Prakash read them out from the company's standards sheet: plan MAC addresses before installation and write them on the drawings; never leave a replacement controller at its factory address; set Max_Master on every device to the planned value, typically the next multiple of eight or the highest planned address plus a few; give the router or supervisory controller a Max_Info_Frames of about 10 to 20 while terminal controllers stay at 1; keep trunks to about 32 to 50 devices even when the electrical limits allow more; and use the same baud rate everywhere on a site unless there is a reason not to.
Unit loads, segments and repeaters
BAS-210 explained that EIA-485 limits the electrical load on a segment, traditionally 32 unit loads, and that many modern transceivers present a quarter or an eighth of a unit load so that more devices can share a segment. A repeater joins two segments electrically, extending the length and the load limit, but the segments remain one MS/TP network with one token and one set of MAC addresses. A router, by contrast, starts a new network with its own token and addresses, which lesson 5 covers.
The electrical limit is rarely the real limit. A trunk with 100 devices at a quarter unit load each is electrically legal, but its token rotation is long and its throughput per device is small. Response times, the number of change-of-value subscriptions the trunk must carry and the number of points the front end trends decide how many devices a trunk can sensibly hold. Quillon's limit of about 32 to 50 was a rule of thumb from experience, not a figure from the standard.
Recognizing MS/TP problems
| Symptom at the front end | Likely causes on the trunk |
|---|---|
| Devices drop offline and come back, often the same group | Duplicate MAC address, missing or extra termination, a stub, a loose shield or polarity reversal |
| One new device is never found | Address above Max_Master, wrong baud rate, reversed polarity or a duplicate device instance |
| Everything works but responses are slow | Too many devices, Max_Master left at 127, too much polling, low Max_Info_Frames on the router |
| The whole trunk is silent | A shorted pair, a device holding the line, or a failed router port |
Callie asked how Prakash had known on September 21 that the problem was an address, not only the wiring. He had read the MAC address of every device the router could see and found two answers at 3 in the router's diagnostics, and his capture showed the token dying at 3 again and again. The 41 ohm reading across the pair, instead of about 60, told him there was a third terminator. Lesson 11 returns to that capture.
A trunk checklist
Quillon checks every new or extended MS/TP trunk against the same short list before handover, with the results recorded on the trunk's sheet in the job file.
| Check | Pass condition |
|---|---|
| Termination | Terminators on only at the two physical ends; resistance across the pair with power off near half of one terminator's value |
| Biasing | Bias provided at one point, usually the router or the first controller, as the product instructions say |
| Shield | Continuous along the trunk and grounded at one point only |
| MAC addresses | Unique, recorded, and below Max_Master on every device |
| Baud rate | The same on every device, confirmed in each device rather than assumed |
| Token loop | Every device discovered, and a capture showing no lost tokens over several minutes |
Common mistakes
MistakeLeaving a replacement controller at its factory MAC address.
InsteadSet the planned address before connecting it to the trunk.
MistakeLeaving Max_Master at 127 on every device.
InsteadSet it just above the highest address in use, the same on every master.
MistakeMixing baud rates on one trunk.
InsteadUse one baud rate on the whole trunk and check every device.
MistakeTreating a repeater as if it starts a new network.
InsteadA repeater extends one network; only a router starts a new one.
MistakeFilling a trunk to its electrical limit.
InsteadSize trunks by response time and traffic, not only by unit loads.
Summary and key terms
- MS/TP is BACnet over EIA-485 twisted pair, using a token so that only one device talks at a time.
- MAC addresses 0 to 127 are masters, 128 to 254 slaves and 255 broadcast; addresses must be unique on the trunk.
- The token passes in address order; each master may send up to Max_Info_Frames messages per turn.
- Masters poll for new devices up to Max_Master; a lost token is regenerated after about 500 ms of silence.
- Each octet takes ten bit times; every device on a trunk must use the same baud rate.
- Max_Master set too high wastes time polling empty addresses; set too low, it hides devices.
- Duplicate addresses, bad termination, stubs and polarity cause most intermittent trunk problems.
- MS/TP
- Master-Slave/Token-Passing, BACnet's network type for EIA-485 twisted pair.
- Token
- A short message that gives its holder permission to send on an MS/TP trunk.
- MAC address
- A device's address on one network; on MS/TP, 0 to 127 for masters and 128 to 254 for slaves.
- Master
- An MS/TP device that takes part in passing the token.
- Slave
- An MS/TP device that only answers when asked and never holds the token.
- Max_Master
- The highest MAC address a master polls when looking for new devices.
- Max_Info_Frames
- The number of messages a master may send each time it holds the token.
- Poll For Master
- A frame a master sends to an empty address to find new devices.
- Repeater
- A device that joins two EIA-485 segments into one network.
Practice problems
Work each problem on paper first, then reveal the answer to check.
How long does a 50-octet frame take at 76,800 bits per second?
Show answer
50 × 10 ÷ 76,800 = 6.5 ms.
The highest master is at MAC 40 and Max_Master is 127. How many empty addresses are polled?
Show answer
127 − 40 = 87.
A new device at MAC 60 is never found; all masters have Max_Master 47. Why?
Show answer
No master polls above 47, so address 60 is never discovered.
Two devices are both at MAC 12. What happens?
Show answer
They answer and pass the token together, their frames collide and the trunk keeps losing the token.
Why does the router usually get a higher Max_Info_Frames than a VAV controller?
Show answer
It carries the front end's requests for every device and needs to send several per turn.
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.