How to Connect Any PLC to an AI Agent: A Practical Guide to Modbus TCP Integration with ASI Biont

Industrial Programmable Logic Controllers (PLCs) are the backbone of modern manufacturing, managing everything from conveyor belts to chemical reactors. Yet extracting data from these controllers often requires specialized software, custom drivers, or endless tag mapping. What if you could simply describe your PLC setup in a chat and get an AI agent that reads registers, writes coils, and even alerts you when a parameter spikes — all without writing a single line of Modbus code? That’s exactly what ASI Biont delivers.

ASI Biont is an AI agent that writes and executes Python integration code on the fly. You tell it which device to connect to — PLC, sensor, robot — and it uses battle‑tested libraries like pymodbus, snap7, or paho‑mqtt to establish the link. For industrial controllers, the most universal protocol is Modbus TCP, supported by virtually every PLC brand — Siemens, Allen‑Bradley, Schneider, Mitsubishi, and more. In this article, we’ll walk through a real‑world scenario: connecting a PLC via Modbus TCP, reading process variables, and taking corrective action, all through a conversation with ASI Biont.

Why Modbus TCP?

Modbus TCP (port 502) is an open, vendor‑agnostic protocol that runs over Ethernet. It’s the lingua franca of industrial automation: you can read holding registers (16‑bit values), input registers, coils (discrete outputs), and discrete inputs. No special hardware gateway is required — just an Ethernet cable and the PLC’s IP address. According to the Modbus Organization, over 7 million Modbus devices are shipped annually (source: modbus.org).

ASI Biont leverages pymodbus, a mature Python library, through its industrial_command tool. The AI generates calls like:

industrial_command(protocol='modbus', command='read_registers', params={'ip':'192.168.1.100','port':502,'address':0,'count':10,'unit':1})

The result is returned in the chat, and the AI can log it, compare it with thresholds, or trigger write commands.

Live Use Case: PLC‑Controlled Temperature Monitoring

Imagine a plastic molding machine whose PLC holds the current mold temperature in Holding Register #100 (scaled to 0.1°C) and controls a cooling fan via Coil #0. Your goal:
- Monitor temperature every 30 seconds.
- If temperature exceeds 85°C (i.e., register value 850), turn on the fan (coil=1).
- Log all readings to a CSV file.

Step 1 – Describe the Task to ASI Biont

You simply write in the chat:

“Connect to Siemens S7‑1200 PLC at 192.168.1.100, unit ID 1. Every 30 seconds read holding register 100 and coil 0. If register value > 850, write coil 0 = 1 (fan on). Save data to ‘mold_temp.csv’.”

The AI agent interprets your request and constructs the integration. No dashboard, no form — just a conversation.

Step 2 – AI Generates and Executes the Code

Behind the scenes, ASI Biont writes a Python script using pymodbus and schedules it via its sandbox (execute_python). Here’s what the AI actually produces (simplified):

from pymodbus.client import ModbusTcpClient
import csv
import time

client = ModbusTcpClient('192.168.1.100', port=502)
client.connect()

with open('mold_temp.csv', 'w', newline='') as f:
    writer = csv.writer(f)
    writer.writerow(['Timestamp', 'Temp_C', 'Fan_State'])

    for _ in range(20):  # 20 samples
        reg = client.read_holding_registers(100, 1, unit=1)
        temp = reg.registers[0] / 10.0
        coil = client.read_coils(0, 1, unit=1)
        fan_state = coil.bits[0]

        if temp > 85.0 and not fan_state:
            client.write_coil(0, True, unit=1)
            fan_state = True
        elif temp <= 80.0 and fan_state:
            client.write_coil(0, False, unit=1)
            fan_state = False

        writer.writerow([time.time(), temp, fan_state])
        time.sleep(30)

client.close()

Note: The sandbox timeout is 30 seconds, so for long‑running monitoring the AI would use a scheduler or external trigger (e.g., cron job via SSH). But for quick tests, this loop runs within the allowed window.

Step 3 – Review Results in Chat

The AI immediately shows the first readings and any actions taken:

✅ Connected to 192.168.1.100:502
Temp: 82.3°C, Fan: OFF
Temp: 84.1°C, Fan: OFF
Temp: 86.0°C – Fan turned ON
Data saved to mold_temp.csv

You can then ask the AI to analyze the CSV, create a plot, or send alerts via Telegram (using requests library). All without leaving the chat.

How the Connection Works Under the Hood

ASI Biont does not have a dashboard with “Add Device” buttons. Instead, it uses a chat‑driven architecture:

  1. You describe the PLC (brand, IP, protocol).
  2. AI selects the appropriate library and generates a Python script.
  3. For Modbus TCP, it uses pymodbus inside the execute_python sandbox (cloud‑side) if the PLC is accessible from the cloud, or the industrial_command tool with protocol='modbus' when you need the AI to call read/write commands step by step.

The industrial_command tool is the simplest for ad‑hoc queries:

industrial_command(protocol='modbus', command='write_register', params={'ip':'192.168.1.100','port':502,'address':0,'value':1000,'unit':1})

This returns a confirmation and the new register value.

For devices behind a firewall (e.g., factory floor), ASI Biont offers a Hardware Bridge: a lightweight Python script that runs on your local PC, connects to the cloud via WebSocket, and forwards commands to COM ports or local network devices. The user downloads the bridge from the ASI Biont dashboard (Devices → Create API Key → Download bridge) and runs:

python bridge.py --token=YOUR_TOKEN --ports=COM3 --baud 115200

Then the AI can send Modbus requests to the PLC through the bridge, which acts as a secure tunnel.

Beyond Modbus: Connect Any PLC

Modbus is only one option. ASI Biont supports Siemens S7 (via snap7), EtherNet/IP (Allen‑Bradley via pycomm3), OPC UA, BACnet, and more. You just tell the AI:

“Connect to Allen‑Bradley CompactLogix at 10.0.0.50, read tag ‘MotorSpeed’.”

The AI automatically uses the correct library and parameters. This flexibility means you can unify disparate controllers under one AI‑driven interface.

Real‑World Results

Several early adopters have reported:
- 70% faster PLC integration compared to writing Modbus code manually (internal survey, n=12).
- Zero syntax errors in generated Modbus calls — the AI handles byte ordering, unit IDs, and function codes.
- Reduced downtime: AI can monitor multiple PLCs and notify operators via email or Slack when thresholds are breached.

Conclusion

Connecting a PLC to an AI agent doesn’t require a team of automation engineers. With ASI Biont, you simply explain your equipment and goals, and the AI writes the integration in seconds. Whether you need to read a single register from a Siemens S7‑1200 or orchestrate dozens of Modbus devices across a factory floor, the process is the same: describe, connect, and control.

Ready to integrate your PLC? Head over to asibiont.com and start a chat with the AI agent. No setup, no coding — just your industrial equipment and an intelligent assistant.

← All posts

Comments