WEIGHING TECHNOLOGY · IN-HOUSE DEVELOPMENT · SUPPORT
+386 2 320 33 46info@preciz.si

PRACTICAL GUIDE · PRECIZ

How to connect a RAVAS 3200 forklift scale to SAP over Wi-Fi

CloudScaleLink Neutron translates RAVAS ASCII over RS-232 into selected MT-SICS commands over TCP/IP to connect an existing scale to SAP.

1. A solution for IT teams and integrators

In this installation, the forklift scale and its RAVAS 3200 indicator remain in use. A JavaScript application in Neutron AppEngine translates communication for a SAP weighing interface that expects MT-SICS over TCP. Neutron joins the Wi-Fi network using WPA3-Enterprise and acts as the TCP server.

You need a RAVAS 3200 indicator with bidirectional RS-232, CloudScaleLink Neutron with AppEngine API 1 and a TCP client in the target system. This guide is for IT teams, developers and weighing-system integrators. Prepared by PRECIZ.

The existing weighing system stays in place. Neutron handles the network connection and protocol translation.

2. Connect RS-232 and the network

  1. Set RAVAS 3200 to PC → bidir: 9600 baud, 8 data bits, no parity, 1 stop bit and no hardware flow control. RAVAS messages end in CR.
  2. Connect CloudScaleLink Neutron to WPA3-Enterprise Wi-Fi using authentication settings supplied by IT. SAP must be able to reach the Neutron IP address. Neutron manual.
  3. Set Serial redirect → Disabled and the built-in TCP mode → Disabled; disable conflicting TCP bridges. Under Scale, leave RS-232/UART and TCP unselected as built-in weighing interfaces. AppEngine will claim the ports.

RS-232 settings: Serial redirect is disabled; the application sets 9600 8N1 and handles CR framing itself.

The built-in TCP mode is disabled. The application starts its own server on port 5000.

RS-232/UART and TCP are not selected for the built-in weighing protocol.

3. Upload and run the application

Download the JavaScript application (.js)

Set serialNumber to the number on the indicator plate, set its fixed weighing unit and change tcpPort if needed (default 5000). An empty serialNumber produces I4 I. Example settings:

tcpPort: 5000,
unit: "kg",
serialNumber: "1234"

In AppEngine, select Upload, upload the JS and select Run. After testing, you can enable Run automatically at device startup. The application runs on Neutron, not in the browser. AppEngine installation.

AppEngine: upload, run and the log showing RS-232 claimed and a TCP client connected.

4. Read a weight from SAP or a TCP client

Connect a TCP client to the Neutron IP address and port 5000, or your configured port. Send I4\r\n, then SXI\r\n. Terminate every command with CRLF and wait for the full reply. For I0, the line beginning with I0 A completes the reply.

SX S G       12.5 kg N       10.0 kg T        2.5 kg

SX S means stable and SX D dynamic. G is gross, N net and T tare. Gross and net come from one GW frame; tare is their difference. Units and decimal precision follow the indicator configuration.

5. Application commands and responses

Table 1

Command

Function

Example response

I0

Lists supported commands and levels; I0 B marks intermediate lines and I0 A the final line.

I0 B …; I0 A 2 "SXI"

I4

Returns the serial number entered in the application configuration.

I4 A "1234"

S

Reads stable net weight; waits approximately five seconds, then returns S I if stability is not confirmed.

S S 10.0 kg / S I

SI

Reads current net weight; S S is stable and S D dynamic.

S S 10.0 kg / S D 10.0 kg

Z

Zeros the scale and confirms that active tare has cleared.

Z A

T

Tares the current load and reads back the resulting tare.

T S 2.5 kg

TA

Reads tare; TA 2.5 kg sets a preset tare within the supported decimal format.

TA A 2.5 kg

TAC

Clears active tare; TAC I means the application could not confirm the result.

TAC A / TAC I

SXI

Reads gross, net and tare without waiting for stability; SX S is stable and SX D dynamic.

SX S G 12.5 kg N 10.0 kg T 2.5 kg

ES: unknown command or invalid arguments. EL: queue limit reached. TA L: unsupported tare value, precision or unit. I in a reply means the request could not be completed; + and - indicate overload or an invalid range reported by the reading. This application supports the command set listed above.

6. Understand the application functions

start()

Claims RS-232, sets 9600 8N1 and starts an exclusive TCP server.

exchange()

Sends a RAVAS command ending in CR, assembles the reply and blocks further requests after a timeout so late replies are not assigned to a different command.

readWeight()

For S and SI, combines decimal precision from GN with checked status and values from GW.

readExtendedWeight()

For SXI, uses one GW frame for gross and net, calculates tare and checks decimal precision before and after the reading.

clearTare() and presetTare()

Checks tare clearing using the GW status bit; validates the unit and allowed precision for preset tare.

respond() and drainQueue()

Maps MT-SICS commands to RAVAS operations and executes them sequentially to avoid overlapping serial requests.

7. Complete application code and JS download

Download the complete JavaScript application (.js)

The complete supplied application appears below. The download contains the same code. Edit the configuration before running it; pollMs: 100 is the delay while waiting for stability or operation confirmation, not an automatic stream to SAP.

/*
 * Neutron AppEngine API 1 | SAP (TCP client) <-> RAVAS 3200 (RS-232)
 * RAVAS serial setup: PC -> bidir, 9600 8N1, no handshake, CR terminator.
 * Neutron: disable the system RS-232 function, I_TCP weighing protocol and
 * TCP bridges so AppEngine can claim both interfaces. Use an unused TCP port.
 * Keep the RAVAS display unit fixed. Set unit and serialNumber below.
 * SAP: send ASCII commands ending in CRLF and wait for the full reply.
 */
(function () {
    "use strict";

    const config = {
        tcpPort: 5000,
        unit: "kg",
        serialNumber: "", // Enter the serial number from the indicator plate.
        readTimeoutMs: 650,
        operationTimeoutMs: 5500,
        stableTimeoutMs: 5000,
        pollMs: 100,
        queueLimit: 16
    };
    const commands = ["I0", "I4", "S", "SI", "Z", "T", "TA", "TAC", "SXI"];
    const serialPort = serial.rs232;
    let pending = null;
    let serialBlockedUntil = 0;
    let serialLine = "";
    let discardSerialLine = false;
    let session = null;
    let busy = false;

    function receiveSerial(event) {
        for (const byte of event.data) {
            if (byte === 13) {
                const line = serialLine.trim();
                const request = pending;
                if (!discardSerialLine && request &&
                    (request.accept(line) || /^(?:ERR|[NG]?=+|[NG]-[ -]+)$/.test(line))) {
                    pending = null;
                    request.resolve(line);
                }
                serialLine = "";
                discardSerialLine = false;
            } else if (byte !== 10 && !discardSerialLine) {
                if (byte < 32 || byte > 126 || serialLine.length >= 64) {
                    discardSerialLine = true;
                } else {
                    serialLine += String.fromCharCode(byte);
                }
            }
        }
    }

    async function exchange(command, accept, timeoutMs = config.readTimeoutMs) {
        if (Date.now() < serialBlockedUntil) {
            throw new Error("RS-232 is waiting for late replies to clear");
        }
        serialLine = "";
        discardSerialLine = false;
        let timer;
        const response = new Promise((resolve, reject) => {
            pending = { accept, resolve };
            timer = setTimeout(() => reject(new Error("No RAVAS reply to " + command)), timeoutMs);
        });
        try {
            // Install the response handler first. The reply may arrive before write resolves.
            const results = await Promise.all([
                response,
                serialPort.write(command + "\r", { timeoutMs: 500 })
            ]);
            if (results[1] !== command.length + 1) throw new Error("Incomplete serial write");
            return results[0];
        } catch (error) {
            serialBlockedUntil = Date.now() + config.operationTimeoutMs;
            throw error;
        } finally {
            clearTimeout(timer);
            pending = null;
        }
    }

    function parseDecimal(line, prefix) {
        const match = /^([NTP])([+-])(\d{1,5})(?:\.(\d{0,4}))?$/.exec(line);
        if (!match || match[1] !== prefix) return null;
        const integer = match[3].replace(/^0+(?=\d)/, "");
        const fraction = match[4] || "";
        const counts = Number(match[2] + match[3] + fraction);
        return {
            text: (counts < 0 ? "-" : "") + integer + (fraction ? "." + fraction : ""),
            counts,
            decimals: fraction.length
        };
    }

    function parseStatus(line) {
        const match = /^W([+-]\d{5})([+-]\d{5})([0-9A-F]{2})([0-9A-F]{2})$/i.exec(line);
        if (!match) return null;
        let sum = 0;
        for (let i = 0; i < line.length - 2; i++) sum += line.charCodeAt(i);
        if (((~sum) & 255) !== parseInt(match[4], 16)) return null;
        return { net: Number(match[1]), gross: Number(match[2]), flags: parseInt(match[3], 16) };
    }

    function weightReply(id, status, value) {
        return id + " " + status + " " + value.text.padStart(10, " ") + " " + config.unit;
    }

    async function status() {
        const line = await exchange("GW", value => value.startsWith("W"));
        const frame = parseStatus(line);
        if (!frame) return { error: /^N?-[ -]+$/.test(line) ? "-" : "I" };
        if (frame.flags & 0x04) return { error: "+" };
        if (frame.flags & 0x80) return { error: "I" };
        return frame;
    }

    async function decimal(command, prefix) {
        return parseDecimal(await exchange(command, line => line.startsWith(prefix)), prefix);
    }

    async function readWeight(stableOnly, source) {
        const deadline = Date.now() + config.stableTimeoutMs;
        do {
            if (session !== source) return "S I";
            const before = await status();
            if (before.error) return "S " + before.error;
            if (!stableOnly || (before.flags & 0x10)) {
                const net = await decimal("GN", "N");
                if (!net) return "S I";
                const after = await status();
                if (after.error) return "S " + after.error;
                // GN supplies the decimal point. GW supplies checked status and raw counts.
                const stable = (before.flags & after.flags & 0x10) &&
                    before.net === net.counts && after.net === net.counts &&
                    before.gross === after.gross &&
                    ((before.flags ^ after.flags) & 0x40) === 0;
                if (stable) return weightReply("S", "S", net);
                if (!stableOnly) return weightReply("S", "D", net);
            }
            const remaining = deadline - Date.now();
            if (remaining <= 0) break;
            await new Promise(resolve => setTimeout(resolve, Math.min(config.pollMs, remaining)));
        } while (Date.now() < deadline);
        return "S I";
    }

    async function readExtendedWeight() {
        const before = await decimal("GN", "N");
        const frame = await status();
        if (frame.error) return "SXI " + frame.error;
        const after = await decimal("GN", "N");
        // GW carries gross and net in one frame. GN supplies the decimal position.
        // Reject the snapshot if the displayed precision changed across the GW query.
        if (!before || !after || before.decimals !== after.decimals) return "SXI I";

        const stable = (frame.flags & 0x10) &&
            before.counts === frame.net && after.counts === frame.net;
        const scale = 10 ** after.decimals;
        const fields = [["G", frame.gross], ["N", frame.net], ["T", frame.gross - frame.net]];
        return "SX " + (stable ? "S" : "D") + " " + fields.map(([tag, counts]) =>
            tag + " " + (counts / scale).toFixed(after.decimals).padStart(10, " ") +
            " " + config.unit
        ).join(" ");
    }

    async function acknowledge(command) {
        return await exchange(command, line => line === "OK", config.operationTimeoutMs) === "OK";
    }

    async function readTares() {
        const regular = await decimal("GT", "T");
        const preset = await decimal("GP", "P");
        if (!regular || !preset) throw new Error("RAVAS tare is unavailable");
        return { regular, preset };
    }

    async function currentTare() {
        const { regular, preset } = await readTares();
        if (regular.counts === 0) return preset;
        if (preset.counts === 0 || regular.text === preset.text) return regular;
        const frame = await status();
        if (!frame.error) {
            const active = frame.gross - frame.net;
            const matchesRegular = regular.counts === active;
            const matchesPreset = preset.counts === active;
            if (matchesRegular !== matchesPreset) return matchesRegular ? regular : preset;
        }
        throw new Error("RAVAS reported two ambiguous tare values");
    }

    async function tareIsCleared(timeoutMs) {
        const deadline = Date.now() + timeoutMs;
        do {
            const frame = await status();
            if (!frame.error && !(frame.flags & 0x40)) return true;
            const remaining = deadline - Date.now();
            if (remaining <= 0) return false;
            await new Promise(resolve => setTimeout(resolve, Math.min(config.pollMs, remaining)));
        } while (true);
    }

    async function clearTare() {
        if (await tareIsCleared(0)) return true;

        const preset = await decimal("GP", "P");
        if (preset && preset.counts !== 0) {
            await acknowledge("RP");
            if (await tareIsCleared(1000)) return true;
        }

        // A stored preset value can remain visible through GP even with no active tare.
        // Use the GW tare-active bit to verify the result, allowing for the update delay.
        await acknowledge("RT");
        return await tareIsCleared(1000);
    }

    async function presetTare(argument) {
        const match = /^\+?(\d{1,10})(?:\.(\d{1,8}))? +([A-Za-z]+)$/.exec(argument);
        if (!match || match[3] !== config.unit) return "TA L";
        const format = await decimal("GP", "P");
        if (!format) return "TA I";
        const integer = match[1].replace(/^0+(?=\d)/, "");
        const fraction = (match[2] || "").replace(/0+$/, "");
        // RAVAS requires a decimal point even when the display has no decimals.
        const integerWidth = 5 - format.decimals;
        if (integer.length > integerWidth || fraction.length > format.decimals) return "TA L";
        const value = integer.padStart(integerWidth, "0") + "." +
            fraction.padEnd(format.decimals, "0");
        if (!await acknowledge("SP" + value)) return "TA I";
        return weightReply("TA", "A", await currentTare());
    }

    async function respond(line, source) {
        const match = /^([A-Z][A-Z0-9]*)(?: +(.+))?$/.exec(line.trim());
        if (!match || !commands.includes(match[1])) return "ES";
        const [, command, argument] = match;
        if (argument && command !== "TA") return "ES";
        try {
            switch (command) {
                case "I0":
                    return commands.map((name, index) =>
                        "I0 " + (index === commands.length - 1 ? "A" : "B") +
                        " " + (name === "SXI" ? "2" : index < 5 ? "0" : "1") +
                        ' "' + name + '"').join("\r\n");
                case "I4":
                    return config.serialNumber ? 'I4 A "' + config.serialNumber + '"' : "I4 I";
                case "SI":
                case "S":
                    return await readWeight(command === "S", source);
                case "SXI":
                    return await readExtendedWeight();
                case "Z":
                    if (!await acknowledge("SZ")) return "Z I";
                    return await clearTare() ? "Z A" : "Z I";
                case "T":
                    if (!await acknowledge("SR")) return "T I";
                    return weightReply("T", "S", await currentTare());
                case "TAC":
                    return await clearTare() ? "TAC A" : "TAC I";
                case "TA":
                    return argument
                        ? await presetTare(argument)
                        : weightReply("TA", "A", await currentTare());
            }
        } catch (error) {
            console.warn(command + ": " + error.message);
            return (command === "SI" ? "S" : command) + " I";
        }
    }

    async function drainQueue() {
        if (busy) return;
        busy = true;
        try {
            while (session && (session.queue.length || session.rejected)) {
                const source = session;
                const line = source.queue.shift();
                if (line === undefined) source.rejected--;
                const reply = line === undefined ? "EL" : await respond(line, source);
                if (source !== session) continue;
                try {
                    await tcp.write(reply + "\r\n", { connectionId: source.id });
                } catch (error) {
                    console.warn("TCP reply failed: " + error.message);
                    source.queue.length = 0;
                    source.rejected = 0;
                }
            }
        } finally {
            busy = false;
        }
    }

    async function start() {
        if (!/^[\x20-\x21\x23-\x7e]{0,40}$/.test(config.serialNumber) ||
            !/^[A-Za-z]+$/.test(config.unit)) {
            throw new Error("Check the configured MT-SICS serial number and weight unit");
        }
        serialPort.on("data", receiveSerial);
        await serialPort.claim();
        await serialPort.configure({ baudRate: 9600, dataBits: 8, stopBits: 1, parity: "none" });
        tcp.on("connection", event => {
            if (event.role !== "server") return;
            if (event.connected) session = { id: event.connectionId, queue: [], rejected: 0 };
            else if (session && session.id === event.connectionId) session = null;
        });
        tcp.on("line", event => {
            if (!session || session.id !== event.connectionId || !event.line.trim()) return;
            if (session.queue.length >= config.queueLimit || session.rejected) {
                session.rejected = Math.min(session.rejected + 1, config.queueLimit);
            } else {
                session.queue.push(event.line);
            }
            drainQueue().catch(error => console.error(error.message));
        });
        await tcp.configure({
            mode: "server",
            server: { port: config.tcpPort, exclusive: true },
            delimiter: "\r\n",
            maxLineBytes: 128
        });
        await tcp.claim();
        console.info("RAVAS MT-SICS bridge configured on TCP port " + config.tcpPort);
    }

    start().catch(error => {
        console.error("RAVAS bridge startup failed: " + (error.code || "") + " " + error.message);
        app.stop();
    });
})();

8. Test the connection

  1. Use I4 to confirm identity, then compare SXI weight and decimal places with the indicator.
  2. Apply T, read the tare with TA and clear it with TAC.
  3. After TAC A, the next SXI should show zero tare and equal gross and net weights.
  4. Test stable and moving loads and reconnect the client.

The screenshots show a test environment. The displayed device ID, SSID, serial number 1234 and private IP address are examples illustrating the procedure.

TCP client: I4, SXI, T, TA and TAC responses with stable and dynamic status.

Need to connect a scale to your IT system?

Tell us the scale model, existing interface and target system. PRECIZ provides scale integration and communication adaptations for IT teams and integrators.

Open the contact form

Frequently asked questions

Can the scale also connect through WebSocket?
Yes. Neutron AppEngine supports WebSocket, so the RAVAS reading and parsing logic can be reused in an adapted application for a web interface or another system. Define the message format and command handling. The supplied application uses TCP; a WebSocket connection must be implemented separately. Neutron AppEngine · WebSocket
Can we connect through MQTT?
Yes. Neutron AppEngine supports MQTT connections to your own broker. An adapted application can publish weight, unit and stability for modern IT or IoT systems. Define topics, payloads and command rules. The supplied JS does not publish over MQTT; it implements the RS-232–TCP bridge. Neutron AppEngine · MQTT
Does this work with every SAP system?

This guide covers a SAP weighing interface that acts as a TCP client and expects the listed MT-SICS commands. The target interface must support this command set, CRLF and the agreed response format. A different SAP interface requires an appropriate integration adaptation.

Can we also connect ERP, MES, WMS or SCADA?

A system that can consume the demonstrated MT-SICS over TCP can act as the client. For other formats or protocols, the AppEngine application is adapted to the target system. PRECIZ can plan the connection around the scale model, existing interface and IT requirements.

Do we need to replace the existing RAVAS scale?

The demonstrated solution keeps the existing scale and RAVAS 3200 indicator. CloudScaleLink Neutron adds the network connection and translates RAVAS ASCII from bidirectional RS-232 into the listed MT-SICS responses over TCP.

Does repeated reading trigger printing or subtotal accumulation?

Weight reading in this application uses GN and GW requests. These readings do not trigger printing or add to the subtotal. Zero and tare operations run only when the client sends the corresponding command.

Need help?

Need help with software, connectivity or using a solution? Describe the issue so we can help with the next step.

Prepare a request →