IMDHMIControls LibraryShop main store

Explainer

Why an S7-300 analog input reads 0 to 27648 counts

PLC programming Published 7 min read By IMDHMI controls team

Short answer

An S7-300 analog input digitizes a 0-10 V signal into a signed 16-bit integer in the peripheral input word: 0 V reads 0 and 10 V reads 27648, the rated full-scale count. Readings continue to 32767 as overrange before overflow. The program reads the raw word directly and scales it to engineering units with the Standard Library block FC105.

On this page
  1. What does an analog voltage input look like inside an S7-300 program?
  2. Why does full scale read 27648 and not 32767?
  3. How do I read the raw count from an S7-300 analog input?
  4. What raw count should a known voltage produce?
  5. How do I scale the raw count to engineering units?
  6. How do I write an analog output the same way?
  7. Where should scaled analog values be stored?
  8. Questions asked

A voltage sensor on an S7-300 analog input never reaches the program in volts. The card hands over a signed 16-bit integer in the peripheral input word, 0 at the bottom of the range and 27648 counts at 10 V, and everything downstream, from the HMI display to the PID loop, is a scaling step you add on top of that number, normally with the FC105 block from the Standard Library. This article walks the number end to end: where the rated count comes from, why readings continue past it toward the signed limit, how to check the raw value at the terminals, and how FC105 turns counts into bar.

What does an analog voltage input look like inside an S7-300 program? #

An analog input on an S7-300 card arrives in the program as a signed 16-bit integer in the peripheral input word, with the bottom of the range reading 0 and the rated full-scale count of 27648 at the top; everything downstream of that number is scaling you add.

The converter on the card digitizes the voltage at its terminals and returns a number proportional to the configured measuring range, not to the process variable. Half scale is therefore a count, not a unit: it means nothing until you map it onto a transmitter span. The range is set per channel in the hardware configuration, and the common voltage ranges map like this:

Configured range Count at the low end Count at the high end
0 to 10 V, unipolar 0 27648
Bipolar, symmetric about zero -27648 +27648

Every nominal range in the S7 value format ends at the same rated count; an 80 mV range and the largest voltage range both reach it, only the physical span differs. Confirm your card's configured range in the hardware configuration before trusting any count.

Why does full scale read 27648 and not 32767? #

27648 is the rated maximum of the S7 analog value representation, not the largest number the card can deliver: counts continue up to the signed 16-bit limit of 32767, and the band between the two is overrange, not a fault in your scaling.

The headroom between the rated count and the signed ceiling lets the program tell a real overrange from a saturated channel. Counts stay proportional to the signal, so 32767 is about 1.185 times the rated count, which on this unipolar range puts the top of the overrange band near 11.9 V; past that the value overflows. A count pinned at the ceiling usually means the signal exceeds the nominal span or the channel is misconfigured, so find the cause before doing anything in logic. One safety note: do not suppress an overrange alarm before someone has looked at the field device, because the count may be reporting a genuine overpressure or overvoltage. Route the fault upward as described in detecting a failed analog input channel and reporting it to SCADA.

How do I read the raw count from an S7-300 analog input? #

Read it as a word through peripheral access, for example PIW256, because S7-300 analog modules sit outside the process image and the program must address them directly rather than through the image.

Peripheral access reads the module the moment the instruction executes instead of going through the process image, which is why analog words are addressed this way. The 256 in PIW256 is an example; the real word address comes from where the module sits in the hardware configuration. In the English mnemonic set the input word is PIW and the output word is PQW; the German set uses PEW and PAW for the same addresses.

Open a watch table, monitor the word as a decimal integer, and put a moving process signal on the terminals. A count that tracks the transmitter means wiring and range are right. A value stuck at zero, negative, or at the ceiling is a hardware or configuration fault, and no scaling code can repair it.

What raw count should a known voltage produce? #

The count is proportional to the voltage across the card's terminals, so half the span belongs to half the counts: 5.00 V at the terminals must read about 13824, which is the rated count divided by two.

Put a meter on the terminals and compare it with the watch table. Then read the mismatches by symptom: a channel that reads correctly at 0 V but falls short of the rated count at full span is configured for a different range than the transmitter delivers; negative counts on a nominally unipolar signal point to a bipolar range selected in the hardware configuration; a count near zero with the sensor at mid-span means an open circuit or a missing supply to a two-wire transmitter. One count works out to about 0.36 mV on this range, so a few counts of jitter at the terminals is normal noise rather than drift. When the meter and the count agree, move on to scaling.

How do I scale the raw count to engineering units? #

Use the Standard Library block FC105 (SCALE): it takes the raw integer on IN, the span ends on LO_LIM and HI_LIM, a BIPOLAR flag, and writes the engineering-unit REAL to OUT, with RET_VAL reporting an out-of-range input.

Set BIPOLAR to FALSE for the unipolar range and TRUE for the bipolar one; a wrong flag shifts every result by half the span. Call the block from the cyclic organization block or from a block it calls, and land the result in a named REAL. A worked example, with a transmitter that gives 0-10 V for 0-10 bar, so LO_LIM = 0.0, HI_LIM = 10.0, BIPOLAR = FALSE, and a watch table showing a raw value of 13824:

OUT = LO_LIM + (RAW / rated full-scale count) x (HI_LIM - LO_LIM)
OUT = 0.0 + (13824 / 27648) x (10.0 - 0.0)
OUT = 0.0 + 0.5 x 10.0
OUT = 5.0 bar

The same call is built step by step in an FC105 walkthrough for a unipolar voltage signal. Keep the arithmetic in floating point: FC105 computes in REAL internally, and a hand-rolled integer version truncates the ratio for every input below full scale. Check RET_VAL after the call, because a non-zero word means the raw input fell outside the range the block accepts and OUT was clamped, so use it to drive a signal-fault alarm.

How do I write an analog output the same way? #

Reverse the path: hold the setpoint in engineering units, convert it to a raw integer with FC106 (UNSCALE), which uses the same limits and BIPOLAR flag in the opposite direction, then transfer the result to the peripheral output word, PQW in English mnemonics.

The rated count span of the input side applies to the output side as well, and the conversion must land on a word-length integer before the transfer. Writing the engineering-unit REAL, or a percentage, straight to the output word produces the wrong current or voltage at the terminals; convert first, then transfer. If the terminals hold a fixed current no matter what the program writes, follow the S7-300 analog output stuck at 25 mA troubleshooting steps. If the write itself is the question, an S7-300 analog output that writes PQW but delivers no current covers that wiring path.

Where should scaled analog values be stored? #

Store scaled process values in a global data block that the HMI, alarm logic and PID loops all read, and give each channel its own instance data block when the scaling runs inside a reusable function block; marker memory is scratch space, not a home for process data.

A global data block names and types every element, so the example result lands as a REAL called Pressure_bar in a data block called DB_Analog; both names are examples chosen for this article. An instance data block belongs to one function block and holds that call's static data, which is what makes a per-channel scaling block practical: one block, one instance data block per channel. Marker words such as MW and MD are fast but describe themselves only to whoever assigned them, and two blocks using the same marker word collide silently, so keep them for intermediates. The decision: one or two channels run fine on a global data block and FC105; many identical channels deserve a function block with per-channel instance data blocks.

Questions asked

Does the same count mapping apply to 4-20 mA inputs?

Yes. A current range maps the transmitter span across the same rated count span on the same card: the 4 mA live zero sits at the bottom of the count span and 20 mA at the rated full-scale count. Set the channel to the current range in hardware configuration, keep BIPOLAR false for 4-20 mA, and scale with the same FC105 call.

What does a non-zero return value from FC105 mean?

RET_VAL reads zero after every successful call. A non-zero word means the raw input fell outside the range the block accepts, the output was clamped to a limit, and OUT is not a trustworthy scaled value. Treat it as a signal fault: check the transmitter and the configured measuring range, and alarm on the return value so the fault reaches an operator.

Why does an integer version of the scaling formula return zero?

Integer division truncates. Run in INT, 13824 divided by the full-scale count gives 0 rather than 0.5, so every input below full scale lands at the bottom of the span. Convert the raw value to REAL before dividing, or let FC105 do the work, because the block computes in floating point internally.

Do all Siemens analog cards use the same rated count?

The rated count span described here covers most S7-300 analog cards, but it is a property of the value representation and the configured range, not a constant for every family. Other series, S7-400 in particular, can map ranges differently, so confirm the measuring-range table for your exact module before hard-coding any limit into the scaling.

Keep reading

  • How-to

    S7-300 PID control for a modulating burner motor

    Run one FB41 CONT_C loop on the hottest hood's PT100, scale all five probes to °C, and turn the 0-100% output into open/close pulses that follow the M941B's 0-10 V pot feedback to a 2% deadband, through 24 VAC interposing relays. The gas management system keeps the burner start sequence and its permissives; the PID never touches them.

    PLC programming

  • Troubleshooting

    Why an S7-1200 analog output reads 3 mA at any command

    A 0-20 mA output that reads 3 mA at every command is not scaling wrong — the meter and the drive are in the circuit incorrectly, or the output stage has lost its 24 V DC supply. Confirm the channel is set to current mode and 20.4-28.8 V DC at L+, then command 0 and 27000 from a watch table with the drive disconnected and the meter in series. A healthy channel tracks both writes; a flat reading with the supply verified means a failed output stage.

    PLC programming

  • Troubleshooting

    Troubleshooting non-linear 4-20 mA readings on an S7-1200 analog input

    A 4-20 mA loop is linear by construction, so counts swinging between 10 and 30246 mean the current at the terminal is not what the sensor LCD shows. On the SM 1231, 27648 counts is the top of the 4-20 mA range and 30246 decodes to 21.5 mA over-range fault current. Check the loop with a series meter, split sensor from module with a calibrator, and anchor NORM_X to 0 and 27648.

    Controllers and I/O