A .NET library for communicating with Allen-Bradley MicroLogix PLCs. Built on libplctag for reliable industrial automation communication.
$ dotnet add package SoftBetaMxLogixA powerful .NET library for communicating with Allen-Bradley MicroLogix PLCs
Simplify industrial automation with easy-to-use PLC communication in .NET
dotnet add package SoftBetaMxLogix
Install-Package SoftBetaMxLogix
using SoftBetaMxLogix;
// Connect to PLC at 192.168.0.100 with 5 second timeout
var plc = new logix("192.168.0.100", 5000);
// Read integer from N7:0
string intValue = plc.read("N7:0");
Console.WriteLine($"N7:0 value: {intValue}");
// Read bit from B3:0
string bitValue = plc.read("B3:0");
Console.WriteLine($"B3:0 value: {bitValue}");
// Write to output O:0/0
plc.write("O:0/0", "1"); // Turn ON
// Write to bit B3:0
plc.write("B3:0", "0"); // Turn OFF
// Write to integer N7:0
plc.write("N7:0", "100");
// Read timer preset value
string timerPre = plc.readTimer("T4:0", logix.dataTimer.PRE);
Console.WriteLine($"Timer T4:0 PRE: {timerPre}");
// Read timer accumulated value
string timerAcc = plc.readTimer("T4:0", logix.dataTimer.ACC);
Console.WriteLine($"Timer T4:0 ACC: {timerAcc}");
using SoftBetaMxLogix;
var plc = new logix("192.168.0.100", 5000);
while (true)
{
string temp = plc.read("N7:10"); // Temperature sensor
string level = plc.read("N7:11"); // Level sensor
string motor = plc.read("B3:0"); // Motor status
Console.WriteLine($"Temp: {temp}C, Level: {level}%, Motor: {(motor == "1" ? "ON" : "OFF")}");
Thread.Sleep(1000);
}
using SoftBetaMxLogix;
var plc = new logix("192.168.0.100", 5000);
// Start production line
plc.write("O:0/0", "1"); // Conveyor motor
plc.write("O:0/1", "1"); // Indicator light
plc.write("N7:20", "150"); // Set target speed
Console.WriteLine("Production line started");
// Monitor until complete
while (plc.read("B3:5") != "1") // Wait for complete signal
{
string progress = plc.read("N7:21");
Console.WriteLine($"Progress: {progress}%");
Thread.Sleep(500);
}
// Stop production line
plc.write("O:0/0", "0");
plc.write("O:0/1", "0");
Console.WriteLine("Production line stopped");
using SoftBetaMxLogix;
var plc = new logix("192.168.0.100", 5000);
string preset = plc.readTimer("T4:0", logix.dataTimer.PRE);
Console.WriteLine($"Cycle time set to: {preset} seconds");
while (true)
{
string elapsed = plc.readTimer("T4:0", logix.dataTimer.ACC);
int percentage = (int)((double.Parse(elapsed) / double.Parse(preset)) * 100);
Console.WriteLine($"Cycle progress: {percentage}% ({elapsed}/{preset}s)");
Thread.Sleep(100);
}
public logix(string ip, int timeout)
Parameters:
ip - IP address of the PLC (e.g., "192.168.0.100")timeout - Connection timeout in milliseconds (default: 5000)public string read(string tagName)
Reads a value from the specified PLC tag.
Supported tag types:
N7:x - Integer filesB3:x - Binary/Bit filesT4:x - Timer filesC5:x - Counter filesO:x/x - Output filesI:x/x - Input filespublic void write(string tagName, string value)
Writes a value to the specified PLC tag.
Parameters:
tagName - The PLC tag addressvalue - The value to write (as string)public string readTimer(string tagName, dataTimer dataType)
Reads timer preset (PRE) or accumulated (ACC) values.
Parameters:
tagName - Timer tag address (e.g., "T4:0")dataType - logix.dataTimer.PRE or logix.dataTimer.ACCvar plc = new logix("192.168.0.100", 5000); // 5 second timeout
// Or modify timeout after creation
plc.Timeout = 10000; // 10 second timeout
try
{
var plc = new logix("192.168.0.100", 5000);
string value = plc.read("N7:0");
}
catch (Exception ex)
{
Console.WriteLine($"PLC communication error: {ex.Message}");
}
Need help? Contact us:
This project is licensed under the MIT License - see the LICENSE.txt file for details.
Made with love by SoftBetaMX
Copyright 2026 SoftBetaMX. All rights reserved.