Some mini problems with code (modbus).

Hello,

I have some problems with my code, here it is:

#include <AFMotor.h>
#include <ModbusSlave.h>
AF_Stepper motor(48, 2);

void setup() {
Serial.begin(9600);
motor.setSpeed(400);
init_mb_slave(9600, ‘n’, 0);
}

void loop() {
start_mb_slave(MB_SLAVE, regs, MB_REGS);
if(regs[MB_REG1]==1)
{
motor.step(regs[MB_REG0], FORWARD, SINGLE);
delay(3000);
}
}

I use modbus rtu protocol and controll stepper motor. When i write to MB_REG = 1 then my modbus communication writes “Time out” “Time out” and doing steps what i wrote in to MB_REG0 addresses. :slight_smile: so where can be a problem that modbus communication timed outs?

Thanks for all :slight_smile: