Hello Guest it is October 26, 2025, 09:09:05 PM

Author Topic: Need some help with the inital setup  (Read 94 times)

0 Members and 1 Guest are viewing this topic.

Need some help with the inital setup
« on: October 26, 2025, 04:46:05 AM »
Hello,

i have some trouble with the inital setup of my modus setup.
I want to connect an Arduino Uno to my mach3 via modbus to instal some external periphery.
- the mist sprayer and the pump
- feed override and start/stop

In my fist setup I only want to switch the LED (PIN13) on the UNO on and off using M7 and M9.
I write the Arduino code:
Code: [Select]
#include <ModbusRtu.h>

#define LED1_PIN 13    // Ausgang 1 (z. B. Luft)
#define LED2_PIN 12    // Ausgang 2 (z. B. Flüssigkeit)

Modbus slave(1, Serial, 0);   // Slave-ID 1
uint16_t au16data[2];         // Zwei Register: 0 und 1

void setup() {
  pinMode(LED1_PIN, OUTPUT);
  pinMode(LED2_PIN, OUTPUT);
  digitalWrite(LED1_PIN, LOW);
  digitalWrite(LED2_PIN, LOW);

  Serial.begin(115200);
  slave.begin(115200);
}

void loop() {
  slave.poll(au16data, 2);   // 2 Register abfragen

  // LED 1 steuern
  digitalWrite(LED1_PIN, au16data[0] ? HIGH : LOW);
  // LED 2 steuern
  digitalWrite(LED2_PIN, au16data[1] ? HIGH : LOW);
}
I can test this with the Test Modbus.
If I read the holding register I get back an 0000. If I write 0001 to it, the LED goes on, if I write 0000 to the holding register the LED goes off.
The the UNO and the modbus is correct.

But now I can do what I want, I can not switch the LED on by M7.
I think there es some error, but I did not find it. Please help my.

My M7
Code: [Select]
SetModOutput(0, 1)
And the ModBusConfigration Screen
Re: Need some help with the inital setup
« Reply #1 on: October 26, 2025, 04:50:51 AM »
Image
Re: Need some help with the inital setup
« Reply #2 on: October 26, 2025, 04:54:31 AM »
image2