Disconnected status with Modbus TCP + Arduino MEGA + Ethernet Shield W5100 through Ignition

Hi! First post here so I suppose I am a bit of a noob with Ignition. At least this is my first Modbus TCP communication with Ignition:

I want to send information of a flowmeter received through the digital input of my Arduino MEGA to Ignition through Modbus TCP protocol. I am using the ModbusIP.h library of Arduino, and I seem to successfully launch my Arduino as the server:

#include <SPI.h>
#include <Ethernet.h>
#include <Modbus.h>
#include <ModbusIP.h>

// ModbusIP object
ModbusIP mb;

// Ethernet settings
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; 
byte ip[] = { 192, 168, 0, 177 };

// Flowmeter settings
const int flowPin = 2;            // Digital pin connected to flowmeter
volatile unsigned int pulseCount = 0;
unsigned long lastTime = 0;       // Last time flow rate was calculated
float flowRate = 0.0;             // Flow rate in liters/min
float calibrationFactor = 477;    // Pulses per liter

// Modbus register address
const int flowRateRegister = 0;   // Modbus address for flow rate data

// Interrupt service routine to count pulses
void countPulses() {
  pulseCount++;
}

void setup() {
  // Start serial monitor
  Serial.begin(9600);
  while (!Serial) {
    ; // Wait for serial port to connect (only needed for some boards)
  }

  // Initialize Ethernet and Modbus
  Ethernet.begin(mac, ip);
  mb.config(mac, ip);
  mb.addHreg(flowRateRegister); // Add holding register for flow rate

  // Print IP and Port
  Serial.println(Ethernet.localIP());

  // Initialize flowmeter input
  pinMode(flowPin, INPUT_PULLUP); // Use internal pull-up resistor
  attachInterrupt(digitalPinToInterrupt(flowPin), countPulses, FALLING);

  // Initialize timing
  lastTime = millis();
}

void loop() {
  // Modbus handling
  mb.task();

  // Time calculation
  unsigned long currentTime = millis();
  unsigned long timeDiff = currentTime - lastTime;

  // Every second, calculate flow rate
  if (timeDiff >= 1000) {
    float frequency = pulseCount / (timeDiff / 1000.0); // Pulses per second
    flowRate = frequency / calibrationFactor;          // Convert to liters/min
    pulseCount = 0;                                    // Reset pulse count
    lastTime = currentTime;

    // Debug output
    Serial.println(flowRate, 2); // 2 decimal places

    // Update Modbus register
    mb.Hreg(flowRateRegister, (uint16_t)(flowRate * 100)); // Send scaled value
  }
}

I say successfully because once launched, the ping to the created IP address answers, and NetCat connects to the 502 port.

Nonetheless, when configuring a simple Modbus TCP device into my Ignition I get Disconnected status. The gateway is also located at the same subnet as the Modbus server I create (0). So I really do not see what could be happening here.

Noteworthy: I am using MacOS, hence I sadly do not have access to ModbusPoll and I cannot check if I am properly writing my registers yet. But I suppose that Ignition should connect anyway.

I tried to be as clear as possible, I am glad to further clarify my problem if needed.

1 Like

What happens if you comment out this line?

Ethernet.begin(mac, ip);

I think it’s unnecessary, mb.config(mac, ip) is sufficient to startup the interface.

If that’s doesn’t change anything, then it’s probably a networking issue. What do the gateway logs say?

Sorry that line of code was from another try. I removed it but the problem still remains. I leave some screenshots of the Logs, the nc to my IP, and the ping.

Expand this log entry (click "+") and copy/paste the stack trace here.

image

Thank you for the fast reply Kevin, glad to have the OG of Modbus from all the forums. Here is the screenshot:

That's weird.

What does your Modbus device configuration look like in Ignition?

It is quiet straightforward, I am using Maker though...

Hmm, I have no idea. Maybe try setting "Local Address" to the IP address of whatever network adapter in your mac can reach the Modbus server.

This is the second time this week I've seen a "No route to host" error when connecting from somebody on a Mac. I don't know if there's some configuration or permissions or firewall problem with the latest update or what...

Yeah there is very limited control of these kind of things with Macbook. I will try with Windows whenever I have the opportunity.

Thank you for your attention, merry christmas and happy new year :+1:t3:

Pretty convinced this has something to do with Sequoia's Local Network Privacy and some missing entitlements on our side that would cause Ignition to show up here:

tagging @jcoffman for after the holidays, he might know more.

3 Likes

To second Kevin, I have seen that Mac OS Sequoia has changed some permissions here, but this specific setting isn't user adjustable AFAICT at the moment. Im still looking into this a bit to see if there is a workaround or a way to add that entitlement, but my google foo is coming up short at the moment. Ill spend some more time looking into this

This is confirmed to be a new issue in Sequoia. In order to work around this there are a few options:

If using the binary installer don't install the gateway as a service

  • If installing as a service is required, comment out the ignition.sh line for RUN_AS_USER=. This will install the service as the root user which does not require giving access to the Local Network permission.

The zip installer defaults to installing the service as root

This issue looks to only affect launchd services which are set to run as a user other than root at this point in time. I have already reached out to Apple about this and hopefully we get a better solution or a fix soon.

Hope that helps,
Jonathan C

1 Like