IMDHMIControls LibraryShop main store

How-to

Read HART transmitter parameters from PLC code over PROFIBUS

PLC programming Published 8 min read

Short answer

Yes. The analog input word carries only the process value; the transmitter's upper range, lower range and units arrive only as HART records. On the 331-7TF01 you write the request to record 80 and read the response from record 81 with WRREC and RDREC, then check the record transfer and the HART response status separately before you store the values in a DB.

On this page
  1. Why the analog input word never shows the ranges
  2. Confirm the instrument answers before you write code
  3. Map the module's records before you build anything
  4. Choose the record access functions
  5. The read sequence, step by step
  6. Check the two completion layers separately
  7. Worked example: counting the record set for a 644H on the 331-7TF01
  8. Store the decoded values in a DB
  9. The decisions
  10. Questions asked

Yes — your program can read the transmitter's upper range, lower range and units itself. The cyclic analog input word carries only the converted loop current, so the configuration never appears there; it travels as HART data records between the CPU and the 331-7TF01. The program writes a HART request into the module's request record, reads the reply record back, decodes it and stores the values in a DB. Reads run through SFC 59 RD_REC or SFB 52 RDREC, writes through SFB 53 WRREC or SFC 58 WR_REC. The check that decides whether a read is real: a completed record transfer is not the instrument answering, so you verify the two layers separately.

Why the analog input word never shows the ranges #

HART is a digital signal superimposed on the same two wires as the 4–20 mA loop current. The module converts the current and hands the CPU one cyclic value per channel plus its own channel diagnostics. That path needs no program work, and a broken loop shows up in it long before HART matters — detecting a failed analog input channel and reporting it to SCADA covers that side. What the current never tells you is how the transmitter is ranged. The lower range value, the upper range value and the engineering units sit in the transmitter's memory and move only when something speaks HART to it.

What the program needs Where it comes from Success looks like
Process value cyclic analog input word converted value tracks the loop current
Transmitter ranges and units HART request and reply records reply with a successful HART status
Module and channel parameterization parameter records record content matches the configured settings

So the first decision: read the cyclic word for the measurement, and open a record transaction only when the program needs configuration data.

Confirm the instrument answers before you write code #

You have Simatic PDM on this station, so use it as the independent test. Go online to the connected device, confirm it identifies as the Rosemount 644H on the channel you expect, and write down the live lower range, upper range and units. Those three values become the reference your decoded DB values must match. PDM and your program share one transport: the module carries HART commands from a client such as PDM or the STEP 7 user program as jobs over its data records. If PDM cannot get a fresh answer, your program will not either — fix the loop, the channel assignment or the module diagnostics first. Keep the PDM session closed while the program polls, and after any PDM configuration change, run a fresh read.

Map the module's records before you build anything #

Chapter 7 of the SIMATIC ET 200M HART analog modules manual is the contract between the CPU and the 6ES7 331-7TF01-0AB0: it defines every record the CPU can read or write, and their layouts. Record numbers belong to this module interface — they are not HART command numbers, and they do not transfer to another module type. Three groups matter here:

  • Records 0 and 1, the module parameter records. Record 1 is the parameter record filled from the device configuration, and it has its own write function.
  • Records 131 to 138, the parameter records for the module's HART channels, one per channel.
  • Records 80 and 81, the instrument request and reply pair. A write to 80 hands the module a HART job for the transmitter; a read of 81 brings the reply back to the CPU.

If the same CPU also touches drives or other slaves, the RDREC and WRREC data record index number reference keeps the index conventions per device family straight.

Choose the record access functions #

For reads, use SFC 59 RD_REC or SFB 52 RDREC. For writes, use SFB 53 WRREC or SFC 58 WR_REC, with one documented special case: SFC 55 WR_PARAM writes parameter record 1 and nothing else, and SFC 58 WR_REC must not be used on record 1. The SFB forms run as multi-scan jobs from their own instance DBs, which suits a polled HART read; on the 416 CPU both forms are available. Siemens documents restrictions on active record jobs over PROFIBUS DP and PROFINET IO, so hold the design to one transaction in flight per module and queue the channels behind it.

The mechanism is not HART-specific. The same record pattern reads fault and alarm codes from a MICROMASTER 440 over PROFIBUS, and on the PROFINET side the guide to configuring PROFINET WRREC, RDREC and I-Device covers the same functions.

One safety rule before you build the request: keep the running program to read commands. A request written as a configuration command re-ranges a transmitter that may be holding a live loop, and that is a maintenance action, not a poll.

The read sequence, step by step #

  1. Take the module's logical address from the hardware configuration — the same address the analog input uses — and keep it in one tag so the write and read jobs address the same module.
  2. Build the request bytes for the request record exactly as Chapter 7 lays them out: the channel selection and the HART command code, with the command chosen from the 644H's HART documentation as the one that returns the range and unit fields. Copy the layout from the manual; do not guess offsets.
  3. Trigger the write with WRREC or WR_REC once, on a rising edge of REQ. A steady REQ re-fires the job every scan.
  4. Wait for the write to end with DONE set and no ERROR, or RETVAL reporting success, before anything else runs.
  5. Read the reply record with RDREC or RD_REC into a buffer sized from the manual's reply record length. Let the job run across scans and poll BUSY; do not expect the reply inside one cycle.
  6. Accept the transfer only when VALID is set with no ERROR, and check LEN, the length actually transferred, against the length the manual promises.
  7. Decode only after the HART status field inside the reply reports success. Then take the lower range value, the upper range value and the unit field from the documented offsets.
  8. Store the decoded values in the DB and set their validity flag. On any failure, clear the flag and keep the last good values.
  9. After any PDM session or transmitter configuration change, trigger a fresh read so the DB tracks the device again.

Check the two completion layers separately #

DONE on the write and VALID on the read prove the record bytes moved between CPU and module. That is layer one, and it fails on your side of the cable: a wrong logical address, a record index the module does not implement, a buffer shorter than the record, or a station fault on the DP link. A clean layer one says nothing about the instrument. Layer two is the HART status carried inside the reply; only a successful status means the bytes you hold are the transmitter's answer rather than an error frame. It is the same trap as why Complete on a serial communication block is not success: the transport finishing is not the peer agreeing. The split gives you the decision: a layer-one failure sends you to the call and the station; a layer-two failure sends you to the loop, the channel or the transmitter, and never to the analog scaling.

Worked example: counting the record set for a 644H on the 331-7TF01 #

Inputs, each with its source:

  • The module is an 8-channel HART analog input module — the 6ES7 331-7TF01-0AB0, listed as a HART 8 analog input module in its product support entry.
  • Chapter 7 of the ET 200M HART analog modules manual assigns the module's records: parameter records 0 and 1 for the module, parameter records 131 to 138 for the HART channels, and records 80 and 81 for the instrument request and reply.

Rule in words: the addressable records of this module are its module parameter records plus its channel parameter records plus the instrument pair, and the channel records run one per HART channel — eight channels, eight records.

Arithmetic: 2 module records + 8 channel records + 2 instrument records = 12 addressable records, of which instrument data moves through 2.

Result: twelve records in the Chapter 7 set, and exactly one pair among them — the request and the reply — carries anything from the transmitter.

Decision, with its threshold: if a read you intended as a parameter read returns bytes that decode as no range value and no unit, you read one of the other ten. Those ten complete cleanly as transfers while carrying module and channel configuration only. Point the program at the request/reply pair.

Store the decoded values in a DB #

Give the DB two zones. The raw zone holds the request and reply buffers exactly as transferred, so a failed or partial read can always be compared against the last good one. The decoded zone holds the values the rest of the program trusts, written only after both completion checks pass. As an example structure: urvReal : REAL := 0.0, lrvReal : REAL := 0.0, unitsCode : BYTE := 0, valid : BOOL := FALSE, and a sequence counter you increment on every accepted reply so downstream logic can see stale data. Decode the unit field with the HART unit code list from the transmitter documentation instead of assuming the units PDM displays. Set valid on success, clear it on any layer-one or layer-two failure, and let the alarm or logging logic judge what a stale configuration is worth.

The decisions #

  • Process value: the cyclic analog input word, no records involved.
  • Ranges and units in a DB: write the request record, read the reply with the record access functions, decode after the HART status reports success.
  • Module or channel parameterization: records 0, 1 and 131 to 138, with record 1 written through WR_PARAM and the channel records through WR_REC or WRREC.
  • Layer-one failure: logical address, record index or buffer length, or a DP station fault.
  • Layer-two failure: loop, channel or transmitter — confirm with PDM before changing code.
  • PDM fails too: hardware first; the program cannot succeed where PDM fails.

Questions asked

Do I still need Simatic PDM if the program can read the parameters?

Keep it. PDM is the engineering tool: it configures the device, loads its parameter set and gives you the device-level diagnostics you cannot reach from your own decode of a reply record. The program's record reads are for runtime: confirming the installed range matches the control recipe, logging configuration drift, alarming when the ranges change. They complement each other; they do not replace each other.

Does the same record method work for a HART module installed on PROFINET?

The record access functions are documented for central and remote modules on both PROFIBUS DP and PROFINET IO, and the HART interface in TIA Portal also transports commands as external HART jobs over data records. What changes is the record set: numbers and layouts belong to the installed module's own manual, so take the request and reply definitions from that manual rather than from the ET 200M HART module chapter.

Can the program write new ranges to the transmitter the same way?

The record interface carries writes too, and a HART command that writes configuration travels the same request and reply pair as a read. Keep it out of the running logic, though. A range write changes what the transmitter reports while it is controlling a loop, so treat configuration writes as a maintenance action under change control, with the loop on bypass or otherwise supervised, and keep routine program traffic to read commands.

The record job ends without error, but the bytes are not range values. What happened?

You almost certainly read one of the module's parameter records instead of the reply to a HART request. Records for the module and its channels return module and channel configuration, and they succeed as record transfers even though they carry nothing from the instrument. Only the reply produced by your request record holds instrument data, and only when the HART status inside that reply reports success.

Can the program query several transmitters at once?

Build it as one request and reply pair in flight at a time. Siemens documents restrictions on active record jobs over PROFIBUS DP and PROFINET IO, and each HART channel transaction is a full command and response with the instrument. Queue the channels in your logic, start the next write only when the previous reply is accepted or failed, and treat a full sweep of all channels as a background task rather than something the scan must finish.

Keep reading

  • Troubleshooting

    Reading IO-Link ISDU parameters over PROFINET acyclic record data

    If cyclic IO-Link process data exchanges normally, leave out the connect section of IOL_CALL and address the identification and ISDU calls with the hardware ID of the proxy submodule for the target port, read straight from the PROFINET device configuration. A valid connect result such as 8 proves only that a lookup succeeded, not that it selected your port's submodule.

    PLC programming

  • Troubleshooting

    Why MELSECNET II data reads zeros after adding a Modbus card

    The zeros are not a network fault. The QJ71MB91 occupies 32 I/O points, and inserting it ahead of the MELSECNET II module moved that module's start I/O number, so the access code reads the wrong position. Diff the I/O assignment against the map from before the change, re-address the assignment so the MELSECNET II module sits at 0070, and update every instruction that targets it.

    PLC programming

  • Troubleshooting

    Connecting a PLC-5/80E to SINAMICS S120 drives over PROFIBUS

    A PLC-5/80E has no PROFIBUS interface, so a SINAMICS S120 connects only through the PLC-5 PROFIBUS coprocessor documented in Rockwell publication 1785-UM041, run with its legacy configuration toolchain. Set the drive to telegram 999 (p0922 = 999) with one word in and one word out, set STW1 bit 10 so the drive accepts network control, and prove byte order with a 16#00FF probe before writing control values. Without that coprocessor already in hand, no documented PROFIBUS path exists for this CPU.

    Drives and motion