LearnSCADA Articles
All articles

Modbus

LearnSCADA Articles

Model the Compressor Before You Commission the Screen

A compressor package modeled from the vendor’s Modbus map in the LearnSCADA PLC Simulator, with the HMI reading it over Modbus TCP before the real panel is ever powered.
A compressor package modeled from the vendor’s Modbus map in the LearnSCADA PLC Simulator, with the HMI reading it over Modbus TCP before the real panel is ever powered.

We built a compressor package in the PLC Simulator from the vendor's Modbus map, pointed the HMI at it, and proved the connection, the alarms and the limits before the real panel was ever powered.

Every HMI job has the same awkward stretch. The screens are drawn, the tags are bound, and the equipment they talk to is still on a truck, or sitting in a fabrication yard, or powered up somewhere you can't reach. The screen looks finished, but nothing on it has read a real value. You find out whether your addressing, data types and scaling are right on startup day, with the field crew waiting.

On a recent screen for a pair of engine-driven, four-stage reciprocating compressor packages, I decided not to wait. The packager had supplied a Modbus register map for the unit control panel. That map is a complete description of what the panel will put on the wire, which is exactly what a simulator needs. So I typed the map into a workbook, loaded it into the LearnSCADA PLC Simulator, and connected the HMI to it as if it were the panel.

The work, in order

  1. Turn the vendor map into a simulator workbook, one row per register.
  2. Give the important tags behavior, so the model starts, runs, trips and resets like a compressor instead of sitting at fixed numbers.
  3. Upload and activate the workbook, then point the HMI's Modbus TCP connection at the simulator.
  4. Walk every value, alarm and limit on the screen against the simulator, and fix what doesn't match.

From vendor map to workbook

A vendor map is a table: register, description, data type, units, scaling. The simulator's Registers sheet is also a table, and the columns line up almost one for one. Each tag needs a Tag name, a Table (coil, discrete, input or holding) and an Address. The rest, Type, Scale, Initial, Min, Max, Units and Description, comes straight off the map.

Three settings decide whether the model matches the real panel, and they are the same three that cause most startup trouble:

  • Address base. Many vendor maps number registers from 40001 or from 1. The simulator is zero-based by default, but the Settings sheet takes address_base = 1. Set it to match the map and every row can be checked against the vendor document line by line, with no mental subtraction.
  • Data type and word order. Compressor panels lean on 32-bit floats for temperatures and pressures. A float32 takes two registers, so the addresses step by two. The word_order setting (big for ABCD, little for CDAB) has to match what the vendor says. Get it wrong and a 125.1 degF discharge temperature reads as a huge or tiny number.
  • Scale. Where the map stores integers times 10, the workbook's Scale column does the same, so the raw register holds exactly what the panel will send.

A slice of the Registers sheet looks like this. The addresses here are illustrative, not the vendor's.

TagTableAddressTypeScaleBehaviorUnits
run_cmdcoil1boolstatic
alarm_resetcoil2boolstatic
eng_speedholding101float321exprRPM
eng_oil_pressholding103float321exprpsig
disch1_tempholding105float321exprdegF
disch1_hi_spholding201int1610staticdegF
suction_pressholding107float321walkpsig
unit_statusholding301int161expr

Most of the map can stay static or walk. Suction pressure, jacket water and auxiliary water temperatures, and the lube oil values are fine drifting inside their normal band. That alone proves the read path for every one of them.

Making it behave like a compressor

Static values prove addressing. They don't prove the screen. A compressor screen has a status line, run and stop commands, shutdown indicators and alarm lamps, and those only get exercised if the model moves. The simulator's expr behavior is enough to give the unit a believable life with a handful of rows:

eng_speed       clamp(prev + (100 if running else -200) * dt, 0, 1200)
eng_oil_press   eng_speed / 1200 * 55 + noise(0.3)
disch1_temp     clamp(prev + ((280 if running else 90) - prev) * 0.02 * dt, 60, 400)
disch1_temp_hi  disch1_temp > disch1_hi_sp or (prev and not alarm_reset)
oil_press_lo    eng_speed > 600 and eng_oil_press < 25
shutdown        disch1_temp_hi or oil_press_lo or (prev and not alarm_reset)
running         run_cmd and not shutdown
unit_status     2 if running else (3 if shutdown else 1)

Write run_cmd from the HMI and the engine ramps up, oil pressure follows speed, and discharge temperature climbs toward its running value. Write it off and everything coasts down. The alarm and shutdown rows use the latch pattern from the user guide, so a trip holds until the HMI writes alarm_reset. The unit_status code is what the panel would send for the status text on the screen, so the HMI's code-to-text mapping gets tested too.

Row order matters. Rows calculate top to bottom, and an expression sees rows above it from this scan and rows below it from the last one. Here eng_speed reads running from the previous scan, which is fine for a ramp and avoids a loop.

Connecting the HMI

The HMI's device connection got the simulator host, my simulator's port, and unit ID 1, with the same addressing convention the real panel will use. Once it connected, the dashboard's Connected clients panel showed the gateway's requests, function codes and poll rate. That is useful by itself: you can see the HMI's actual polling pattern before it ever meets the vendor's panel.

Because both compressors use the same map, the screen was built on one UDT with two instances. The simulator made that easy to prove. A second block of rows at the second unit's offset gave the second instance something different to read, so a binding that pointed at the wrong unit showed up immediately instead of hiding behind identical numbers.

Testing alarms and limits

This is where the simulator earned its keep. Alarms are the part of a screen most likely to be wrong and least likely to be tested before startup, because forcing a real high discharge temperature on a live compressor is not something anyone wants to do.

  • Analog alarms. With the unit running, I lowered disch1_hi_sp from the simulator dashboard below the current temperature. The latch tripped, the shutdown indicator lit, status went to the shutdown code, and the HMI's alarm went active. Raising the setpoint back proved the alarm stayed latched until reset, which is the behavior the panel will have.
  • Reset path. Writing alarm_reset from the HMI cleared the latch. The simulator's event log records every write with its tag name, so I could confirm the HMI wrote the right coil, once, and not some neighbor.
  • Limits. The Min and Max columns clamp every simulated value to the range on the vendor map. On the HMI side, setpoint entry fields were checked by writing values inside and outside their allowed range, to confirm the screen refuses what the panel would refuse, and that the simulator saw only the writes that should have gone through.
  • Forced values. Calculated tags can't be set from the dashboard, because the simulator overwrites them every scan. When I wanted to park a value at an exact number, I added a test override: a static holding register and a coil, and wrote the expression as test_temp if test_on else (normal expression).

What this proves, and what it doesn't

A simulator built from the vendor map proves your side of the wire. It proves the HMI's addressing, data types, word order and scaling against the map. It proves every binding on the screen, the UDT and its instances, the status text, the command writes, and the alarm and limit configuration. Those are the things that usually eat the first day of startup.

It does not prove the vendor's side. If the panel's firmware doesn't match the revision of the map you were given, or the map itself has a typo, you will have faithfully modeled the mistake. It doesn't reproduce the real network, a serial gateway in the path, or the panel's response time under load. Plan a short point-to-point check at startup for exactly those things. The difference is that the checkout becomes confirmation instead of discovery.

For this job, that difference was the whole point. When the screen went to the field, every value on it had already been read, every alarm had already tripped and reset, and every command had already been written and logged.

Try it yourself

The PLC Simulator has a free two-hour trial with a free account. Start from the water tank template, then replace its rows with your own vendor's map. The workbook format, behaviors and expression patterns are all in the user guide on the simulator dashboard. If you want the protocol underneath all of this, Understanding Modbus covers the data model, addressing and data types in depth.

Register addresses and tag names in this article are illustrative. They show the method, not any vendor's actual map.

0 views

Comments

    Leave a comment

    Comments are read before they appear. Your email is never shown.