Receive RS232 ASCII Weight Data on S7-1200 CM 1241 in TIA Portal

David Krause19 min read
S7-1200SiemensTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Overview

Connecting an industrial weighing scale to a SIMATIC S7-1200 PLC over RS232 requires the CM 1241 RS232 communication module, the Freeport/ASCII protocol instructions in TIA Portal, and a clearly documented serial protocol from the scale vendor. This reference walks through port configuration, point-to-point receive programming, ASCII-to-numeric conversion, and HMI tag linkage for a CPU 1212C AC/DC/Relay with a CM 1241 RS232 and a KP600 mono HMI on PROFINET, all in TIA Portal V13. The same procedure applies to TIA Portal V13 SP1, V14, V15, V15.1, V16, V17, and V18 because the underlying PtP instruction set has remained stable since V13.

System Identification and Required Components

Before any program code is written, confirm the hardware in the control cabinet. The reference system used in this guide consists of:

Component Designation Order Number Function
CPU S7-1200 CPU 1212C AC/DC/Relay 6ES7212-1BE40-0XB0 PLC central processing unit with PROFINET, 8 DI / 6 DQ / 2 AI onboard
PtP module CM 1241 RS232 6ES7241-1AH32-0XB0 RS232 point-to-point communication, single DB9 DTE
Analog input SM 1231 AI4 6ES7231-4HD32-0XB0 Optional analog scaling backup or transducer readout
HMI KP600 mono 6AV3 647-6K... series Operator display over PROFINET, 6" monochrome
Engineering TIA Portal V13 (or V13 SP1) Siemens ES Project, hardware, and program editor

Verify the CM 1241 RS232 firmware revision in the TIA Portal device properties. CM 1241 RS232 modules with article number 6ES7241-1AH32-0XB0 are the standard variant introduced with SIMATIC S7-1200 FW 4.0 and are fully supported by the Freeport/ASCII instructions described below. Earlier 6ES7241-1AH30-0XB0 modules share the same instruction set but report a slightly different diagnostic bit layout. The 6ES7241-1AH32-0XB0 module can be identified by the label "RS232" above the DB9 connector and the orange terminal block retainer.

TIA Portal V13 is the original SIMATIC release that introduced unified project handling for S7-1200, S7-1500, and ET 200. Point-to-point instructions are located in the "Instructions" task card under "Communication > PtP". If TIA Portal V13 SP1, V14, or later is used, the instruction icons and ordering may differ slightly but the configuration parameters and STATUS word layout are identical.

CM 1241 RS232 Module Electrical and Protocol Specifications

The CM 1241 RS232 module provides one isolated RS232 port to the PLC backplane. The official specifications are documented in the SIMATIC S7-1200 manual collection.

Parameter Value
Order number 6ES7241-1AH32-0XB0
Connector Sub-D (DB9) male, DTE pinout
Baud rates 300; 600; 1200; 2400; 4800; 9600; 19200; 38400; 57600; 76800; 115200 bit/s
Data bits 7 or 8
Parity None, Even, Odd, Mark, Space
Stop bits 1 or 2
Flow control None, software (XON/XOFF), hardware (RTS/CTS)
Receiver input voltage ±30 V DC maximum
Transmitter output voltage ±5 V DC minimum into 3 kΩ load (RS232 compliant)
Galvanic isolation RS232 signals to chassis ground; RS232 signals to CPU logic common: 707 V DC
Surge protection 15 kV ESD (HBM) on signal lines per IEC 61000-4-2
Maximum cable length 15 m (RS232 standard limit, EIA/TIA-574)
Internal power Supplied via S7-1200 backplane bus, 250 mA typ.
Module width 30 mm (single slot)

Source: CM 1241 RS232 specifications - SIMATIC S7-1200 Manual Collection.

For a general overview of the RS232, RS422, and RS485 family of communication modules, refer to the RS232, RS422, and RS485 - SIMATIC S7-1200 Manual Collection page. For deeper study of the same CM PtP mechanism on S7-1500 (same instruction principles, different module form factor), the official Siemens support entry is the S7-1500 CM PtP sample project: Communication via the CM PtP RS232 of the SIMATIC S7. The S7-1500 sample applies to the S7-1200 in the Freeport/ASCII message-framing portion.

DB9 Pin Assignment and Cable Wiring to a Scale Indicator

The CM 1241 RS232 presents a DB9 male connector wired as a DTE device. The most common scale interface is also a DB9 male wired as DCE. A straight-through cable (pin-to-pin) is therefore NOT correct for the data lines because it would connect the two TD outputs together and the two RD inputs together. A null-modem (crossover) cable is required, swapping TD/RD and RTS/CTS.

Pin Signal (CM 1241 DTE) Direction at CM 1241 Connect to scale DCE pin
2 RD (Received Data) Input 3 (TD)
3 TD (Transmitted Data) Output 2 (RD)
4 RTS (Request To Send) Output 5 (CTS)
5 CTS (Clear To Send) Input 4 (RTS)
7 Signal ground Common 5 (Signal ground) on scale

Pin 1 (DCD), pin 6 (DSR), and pin 8 (RI) on the CM 1241 are not connected inside the module and should be left open or jumpered to satisfy the scale's input biasing as required by the scale manual.

If the scale uses hardware handshake (RTS/CTS), use a fully populated null-modem cable with all four crossed data lines. If the scale is set to "no handshake", tie RTS to CTS on the CM 1241 side by shorting pins 4 and 5 of the cable at the CM 1241 end. Always connect signal ground (pin 7) to the scale ground to avoid floating common and intermittent character corruption. Floating grounds are the single most common cause of "garbled" ASCII frames on RS232.

Use shielded twisted-pair cable (for example Belden 9925 or Lapp ETHERLINE RS232) with the shield bonded to the cabinet ground at one end only. Maximum cable length is 15 m. For runs longer than 15 m, use RS422 or RS485 with a converter, or use a serial-Ethernet converter and an S7-1200 CP 1243-1 (which adds TCP/IP serial tunneling).

Documenting the Weighing Scale Protocol

The PLC programmer must obtain the exact serial protocol from the scale vendor manual before opening TIA Portal. At a minimum, capture the following information and paste it into the project documentation:

  • Baud rate, data bits, parity, stop bits, flow control
  • Message terminator (CR, LF, CR+LF, ETX, custom two-character sequence)
  • Optional start-of-message delimiter (STX, colon, custom character)
  • Frame layout (text header, weight field, sign, decimal point, units, status bits)
  • Update interval (continuous mode or on-demand by command)
  • Whether the scale transmits continuously or only after a "Print" command
  • Checksum method, if any (BCC, XOR, CRC, none)

Common vendor protocols include Mettler Toledo "Standard Interface" (continuous), CAS "Continuous Mode", Cardinal "Stream Mode", and generic "Send/Receive ASCII". A typical continuous frame is:

ST,GS,+0012.34kg\r\n

where ST is the status word, GS is the gross/net indicator, the sign and decimal point are literal ASCII characters, and the frame ends with carriage return + line feed. A second common variant is:

US,NT,+ 12.34 kg\r\n

with leading spaces to align the weight field. A third variant, used by Avery Berkel and some Sartorius scales, is a fixed-length binary-style frame with STX and ETX delimiters and a two-character checksum. Each variant requires a different parsing strategy, which is why the raw bytes must be captured in advance.

A USB-RS232 converter plus a serial-monitor utility (for example a terminal with "show non-printing" enabled) is the fastest way to confirm the exact bytes transmitted by the scale before the PLC is connected. Engineering effort drops by a factor of ten if the raw bytes are known in advance. Save the captured frames as a text file in the TIA Portal project folder under "Documents" so that commissioning engineers can reproduce the test sequence.

Creating the TIA Portal V13 Project and Configuring the CM 1241 RS232 Port

  1. Open TIA Portal V13, choose "Create new project", and select a path on the local hard drive. Confirm the project name. The project name should follow the site tag, for example PLANT01_S71200_SCALE.
  2. Open "Devices & Networks" and add the CPU 1212C AC/DC/Relay (article number 6ES7212-1BE4x-xXB0). The slot 1 SM 1231 analog module and slot 1 CM 1241 RS232 should be inserted in their correct slots, matching the physical hardware. The CM 1241 must be inserted in a free slot to the left of the CPU (slot 101 to 105 range in the S7-1200 numbering) or to the right of the CPU in the signal board slot. The CM 1241 cannot be used as a signal board.
  3. For the CM 1241 RS232, navigate to "Properties > Port configuration". Set the transmission rate, parity, data bits, and stop bits to match the scale. Leave "Flow control" set to "None" or "RTS/CTS" according to the scale manual. Click "Compile" in the project tree before downloading.
  4. Add the KP600 HMI to the same project. Connect the HMI PROFINET port to the CPU PROFINET port. The HMI will be online through the CPU and will read HMI tags from the PLC tags without additional routing. Set the HMI IP address to the same subnet as the CPU (default 192.168.0.1 for CPU, 192.168.0.10 for HMI).
  5. Compile and download the hardware configuration to the CPU. The CM 1241 RS232 diagnostic LEDs should be off until the PLC is in RUN and the port is active. The yellow "Tx" and "Rx" LEDs blink when characters are transmitted and received.
Parameter Common scale value Notes
Baud rate 9600 Most weighing scales default to 9600. Use 19200 or 38400 for higher update rates.
Data bits 8 7 only for legacy 7-bit ASCII devices (rare on modern scales).
Parity None Set to Even if the scale requires 7E1.
Stop bits 1 Use 2 only if explicitly required by the scale manual.
Flow control None Use XON/XOFF or RTS/CTS only if specified.
Changing port parameters in TIA Portal while the module is communicating will trigger diagnostics and may stall the receive buffer. Stop the CM 1241 receive job, then re-download the hardware configuration. After the change, call RCV_CFG once on cold restart to refresh the firmware parameters.

Receive Configuration Block: RCV_CFG and RCV_P2P Programming

For the S7-1200 with TIA Portal V13, the point-to-point instructions are in the "Instructions > Communication > PtP Communication" task card. The relevant blocks are:

  • RCV_CFG (Receive configuration): defines start and end conditions for ASCII frames
  • RCV_P2P (Receive point-to-point): copies received bytes into a buffer DB
  • RCV_RESET (Receive reset): clears the receive buffer and status
  • SEND_CFG / SEND_P2P: used to send commands such as "P\r\n" to ask the scale to transmit a single weight

Create a global DB "RCV_CFG_DB" with the following structure for ASCII framing. The byte fields below match the Freeport/ASCII configuration structure used by the CM 1241 RS232.


DATA_BLOCK "RCV_CFG_DB"
{ S7_Optimized_Access := 'FALSE' }
VERSION : 0.1
NON_RETAIN
  STRUCT
    Mode     : BYTE := 16#04;  // ASCII mode, freeport
    Baud     : BYTE := 16#06;  // 9600 baud (see table)
    Parity   : BYTE := 16#00;  // 0=None, 1=Even, 2=Odd
    FlowCtrl : BYTE := 16#00;  // 0=None
    RXTimeout: WORD := W#16#64;  // 100 ms inter-character timeout
    Options  : BYTE := 16#00;  // No block-check character
    StartCnt : BYTE := 16#01;  // 1 start condition
    Start0   : BYTE := 16#53;  // 'S' (ASCII 0x53)
    Start1   : BYTE := 16#00;  // unused
    EndCnt   : BYTE := 16#01;  // 1 end condition
    End0     : BYTE := 16#0A;  // LF (0x0A) terminator
    End1     : BYTE := 16#00;  // unused
  END_STRUCT;
END_DATA_BLOCK

Baud encoding for the CM 1241 RS232 is non-obvious; the most common values are:

Code (hex) Baud rate
16#01 300
16#02 600
16#03 1200
16#04 2400
16#05 4800
16#06 9600
16#07 19200
16#08 38400
16#09 57600
16#0A 76800
16#0B 115200

Call RCV_CFG in OB100 (startup) or in OB1 once on cold restart. The instruction is edge-sensitive on the REQ input. The PORT input is a UInt and is auto-generated by TIA Portal from the module's symbolic name; in this guide it is "Local~CM1241_1".PtP_PortAddr.


// OB1 - one-shot on first scan
IF "FirstScan" THEN
  "RCV_CFG_DB".Baud := 16#06;       // 9600
  "RCV_CFG_DB".Start0 := BYTE#16#53; // 'S'
  "RCV_CFG_DB".End0   := BYTE#16#0A; // LF
  RCV_CFG(REQ := TRUE,
          PORT := "Local~CM1241_1".PtP_PortAddr,
          CONFIG_DB := "RCV_CFG_DB");
  "FirstScan" := FALSE;
END_IF;

Call RCV_P2P cyclically to pull complete ASCII frames out of the hardware FIFO. A complete frame is delivered only when the end condition (LF in the example above) has been received. The DONE output pulses true for one cycle when new data has been copied into the buffer.


// OB1 - cyclic receive
RCV_P2P(REQ := "bReceiveTrigger",
        PORT := "Local~CM1241_1".PtP_PortAddr,
        BUFFER := "RxBuffer".bytes,
        LENGTH := "RxBuffer".length,
        DONE => "bRxDone",
        ERROR => "bRxError",
        STATUS => "wRxStatus");
The PORT input on a PtP block expects the symbolic name of the module followed by .PtP_PortAddr. In TIA Portal V13 this constant is auto-generated when the module is inserted. If the value is shown as 0 in the cross-reference, the hardware was compiled but not downloaded to the CPU yet. Download the hardware before testing any RCV_P2P call.

ASCII String Parsing and Conversion to REAL

Once a complete frame has been copied into the receive buffer, convert the raw bytes to a STRING and extract the numeric portion. The example below handles a frame of the form ST,GS,+0012.34kg\r\n and produces a REAL value of 12.34 in the HMI tag.


DATA_BLOCK "RxBuffer"
{ S7_Optimized_Access := 'FALSE' }
  STRUCT
    bytes  : ARRAY[1..64] OF BYTE;
    length : UINT;
    raw    : STRING[64];
    realKg : REAL;
    valid  : BOOL;
    sign   : INT;  // +1 or -1
    wdt    : INT;  // watchdog counter, 100 ms cycle
  END_STRUCT;
END_DATA_BLOCK

// OB1 - parse a complete ASCII frame
IF "bRxDone" THEN
  // Copy bytes into a STRING, stop at LF
  "RxBuffer".raw := '';
  FOR i := 1 TO "RxBuffer".length DO
    IF "RxBuffer".bytes[i] = 16#0A THEN
      EXIT;  // stop at LF
    END_IF;
    "RxBuffer".raw := CONCAT("RxBuffer".raw,
                              CHAR_TO_STRING(BYTE_TO_CHAR("RxBuffer".bytes[i])));
  END_FOR;

  // Determine sign
  "RxBuffer".sign := 1;
  IF FIND("RxBuffer".raw, '-') > 0 THEN
    "RxBuffer".sign := -1;
  END_IF;

  // Strip the "ST,GS," prefix (6 characters) if present
  IF LEN("RxBuffer".raw) >= 6 AND
     LEFT("RxBuffer".raw, 5) = 'ST,GS' THEN
    "TempStr" := MID("RxBuffer".raw, 7, LEN("RxBuffer".raw) - 6);
  ELSE
    "TempStr" := "RxBuffer".raw;
  END_IF;

  // Strip trailing units (kg, lb, g, t)
  kPos := FIND("TempStr", 'k');
  IF kPos = 0 THEN kPos := FIND("TempStr", 'K'); END_IF;
  IF kPos > 0 THEN
    "TempStr" := LEFT("TempStr", kPos - 1);
  END_IF;
  gPos := FIND("TempStr", 'g');
  IF gPos > 0 THEN
    "TempStr" := LEFT("TempStr", gPos - 1);
  END_IF;
  lPos := FIND("TempStr", 'l');
  IF lPos > 0 THEN
    "TempStr" := LEFT("TempStr", lPos - 1);
  END_IF;

  // Convert to REAL
  "RxBuffer".realKg := STRING_TO_REAL("TempStr") * INT_TO_REAL("RxBuffer".sign);
  "RxBuffer".valid := TRUE;
  "RxBuffer".wdt   := 0;  // reset watchdog
END_IF;

// Watchdog timer - 3 second timeout at 100 ms cycle
"RxBuffer".wdt := "RxBuffer".wdt + 1;
IF "RxBuffer".wdt > 30 THEN
  "RxBuffer".valid := FALSE;
  "RxBuffer".realKg := 0.0;
END_IF;

For production code, lock the parser with a flag that is reset on a watchdog timer, and feed the parser a watchdog timeout of 3× the scale update interval. If a new frame has not been received within that window, set the HMI weight tag to 0 and raise a "comm loss" alarm. This prevents a frozen display when the cable is unplugged. The same watchdog can be used to display a "Scale offline" message on the HMI in place of the numeric field.

STRING_TO_REAL accepts strings that contain a leading sign, digits, and exactly one decimal point. Strings such as "0012.34" parse correctly, but "+0012.34kg" do not; that is why the trailing unit characters must be stripped before conversion. The TIA Portal SCL compiler does not warn on this behavior; check the conversion result with a watch table before commissioning.

HMI Tag Configuration on the KP600 Comfort Panel

Once "RxBuffer".realKg holds a valid REAL, expose it to the HMI:

  1. In the PLC tag table, create an HMI-accessible tag "Scale_Weight_kg" with address %DB100.DBD0 (or any symbolic name pointing to the REAL field of the receive buffer). Check the "Accessible from HMI" box in the tag properties.
  2. In the HMI project tree, right-click "HMI Tags" and select "Add new tag". Set the connection to the S7-1200 PROFINET link, name the tag Weight_kg, and bind it to the PLC tag Scale_Weight_kg.
  3. Set the acquisition mode to "Cyclic in operation" with a 200 ms cycle. The HMI polls the value at 5 Hz, which is fast enough for a 1 Hz scale update.
  4. Insert a numeric output field on the KP600 screen. In the properties, set the "Process value" to Weight_kg, format to "99999.99 kg", and add a visibility animation that hides the field when RxBuffer.valid is false (showing a "No Data" text box instead).
  5. Add a status indicator LED that turns red on RxBuffer.valid == FALSE for more than 3 seconds. The result is a single-screen, self-diagnostic weighing display.
The KP600 mono supports PROFINET RT only. The HMI tag polling goes through the S7-1200 PROFINET interface, not through the CM 1241 RS232. The serial cable carries scale data, and the PROFINET cable carries HMI data. Keep the two buses physically separate to avoid ground loops. Do not route the RS232 cable parallel to any VFD motor cable for more than 0.5 m; cross at 90° if a crossing is unavoidable.

Reading the Scale on Demand with SEND_P2P

For applications that must read the weight only when the operator presses a button (for example, a batching system), use SEND_P2P to send a "Print" command. The Mettler Toledo and CAS scales both accept a "P" character followed by CR+LF as a single-shot trigger.


// OB1 - send "P\r\n" on operator button
IF "btnPrint" AND NOT "btnPrintOld" THEN
  "TxBuffer".bytes[1] := 16#50;  // 'P'
  "TxBuffer".bytes[2] := 16#0D;  // CR
  "TxBuffer".bytes[3] := 16#0A;  // LF
  "TxBuffer".length   := 3;
  SEND_P2P(REQ := TRUE,
           PORT := "Local~CM1241_1".PtP_PortAddr,
           BUFFER := "TxBuffer".bytes,
           LENGTH := "TxBuffer".length,
           DONE => "bTxDone",
           ERROR => "bTxError",
           STATUS => "wTxStatus");
  RCV_RESET(REQ := TRUE,
            PORT := "Local~CM1241_1".PtP_PortAddr);
END_IF;
"btnPrintOld" := "btnPrint";

After the SEND_P2P call, the receive buffer is cleared and the next RCV_P2P call will return only the new frame. The "Print" command works for Mettler Toledo, CAS, Cardinal, and most Sartorius scales with default settings. For Avery Berkel scales, the equivalent command is "T\r\n" or the ASCII character 0x05 (ENQ) followed by the scale address byte.

Verification, Commissioning Checklist, and Online Diagnostics

After the program is downloaded, go through the following steps with the scale powered and stable:

  1. Online > "Go online" with the CPU. Open the CM 1241 RS232 properties to confirm that the diagnostics view shows "No fault" and the configured baud rate. The yellow "Rx" LED on the module front should blink every time the scale transmits.
  2. Open a watch table on "RxBuffer".bytes and "RxBuffer".length. Apply a known test weight to the scale. The first byte of bytes should be 0x53 ('S') within the configured cycle time, and length should jump to a non-zero value each time a frame arrives. If length stays at 0, check the start and end characters in RCV_CFG_DB against the actual scale frame.
  3. Place a 10.00 kg calibrated mass on the scale. Confirm that Scale_Weight_kg reads 10.00 within ±0.02 kg (the typical scale repeatability of an industrial bench scale).
  4. Remove the test mass and confirm that the displayed weight returns to 0.00 ±0.02 kg. A sticky reading usually indicates the wrong end-character in RCV_CFG_DB, causing the parser to read two frames as one and concatenate the digits.
  5. Unplug the DB9 cable while the scale is still transmitting. Within 3 seconds the HMI status indicator should turn red and the numeric field should be hidden. Plug the cable back in; the indicator must clear on the next valid frame.
  6. Cycle the power on the scale. The PLC should re-acquire the weight reading within 5 seconds without manual intervention. If not, check that RCV_CFG is called again in OB100 (startup) so the port is re-initialized.

Status word interpretation for the CM 1241 RS232 RCV_P2P block:

STATUS hex Meaning
16#0000 No error
16#8080 Receive buffer overflow - increase buffer size or reduce scale update rate
16#8081 Parity error - check parity setting in hardware and scale
16#8082 Framing error - check data bits and stop bits
16#8083 Overrun error - incoming bytes faster than firmware can service
16#8085 Configuration error - RCV_CFG_DB contents do not match port setup
16#80C0 Data length error - LENGTH parameter out of range
16#80C1 Pointer error - BUFFER pointer is invalid

Troubleshooting Matrix

Symptom Likely cause Remedy
No bytes received; STATUS 16#0000 and length = 0 Wrong baud rate, swapped TD/RD, no ground reference Check scale baud with terminal, swap pins 2/3, connect signal ground
Constant buffer overflow STATUS 16#8080 End condition never matches; RCV_P2P never called Verify end character matches scale terminator; check that RCV_P2P is in a cyclic OB
Garbled characters in "raw" Mismatched parity or stop bits Compare each byte with terminal capture; set hardware parameters to match exactly
Real value wrong by factor of 10 Scale transmits in different unit (g vs kg) Apply correct scaling factor; confirm unit with vendor manual
Real value stuck at last reading End character not in the buffer; parser reads last valid frame forever Use a watchdog to zero the displayed value if no new frame in 3 s
HMI field flickers between valid and "No Data" Some frames pass the parser, others fail; scale transmits occasional status frames Filter by start character or by checksum; ignore status frames
Status LED on CM 1241 RS232 lit red Port diagnostic; no valid parameters Recompile hardware, download again, power-cycle the CPU
Weight jumps by 100x on first reading STRING_TO_REAL parsed only the first numeric field, ignoring decimals Confirm decimal point was present in the frame; some scales send comma instead of period
RCV_P2P returns DONE immediately, but bytes are all zero Empty frame matched on inter-character timeout, not on end character Set RXTimeout shorter than the inter-frame gap of the scale
KP600 shows "Connection lost" periodically PROFINET watchdog setting too tight; HMI tag polling is too fast Increase HMI acquisition cycle to 500 ms; check PROFINET device name in CPU

Why does TIA Portal V13 not show the RCV_P2P block in the standard library?

PtP instructions are not in the default library. Open the "Instructions" task card and navigate to "Communication > PtP Communication". The blocks RCV_CFG, RCV_P2P, RCV_RESET, SEND_CFG, SEND_P2P, and SEND_RESET are grouped there. If the section is empty, the project is using an unsupported CPU type or the install was done without the PtP option.

What is the maximum length of a single ASCII frame the CM 1241 RS232 can buffer?

The receive buffer is sized in the BUFFER parameter of RCV_P2P. For the S7-1200 CM 1241, the practical maximum is 4096 bytes per frame. For weighing scales, 64 or 128 bytes is normally sufficient. Frames larger than 4096 bytes must be split manually in the program because the underlying FIFO cannot hold more.

Can the S7-1200 CPU 1212C directly read RS232 without the CM 1241 module?

No. The CPU 1212C does not include an onboard RS232 port. The only path to RS232 is through a CM 1241 RS232 or CB 1241 RS485 (note: RS485 is a different electrical standard and not RS232). Some third-party boards claim RS232 capability on the signal board slot, but the S7-1200 firmware only supports RS232 on the CM 1241 and RS485/RS422 on the CB 1241.

How do I trigger a single-shot weight reading instead of continuous mode?

Use the SEND_P2P block to transmit a "Print" command to the scale, for example 0x50 0x0D 0x0A ("P\r\n") for Mettler Toledo and many CAS scales. After the SEND_P2P DONE bit pulses, call RCV_P2P and the scale will return one weight frame. The HMI button can call a flag that triggers both blocks in sequence.

Why does STRING_TO_REAL return 0.0 for a valid-looking string?

STRING_TO_REAL expects digits, an optional sign, and a single decimal point. Leading or trailing non-numeric characters such as '+, 'kg, or any non-printable byte cause the conversion to return 0.0. Strip all unit and header characters using the LEFT, MID, and FIND instructions before the conversion, and verify the result against the known test mass before commissioning is signed off.

Back to blog