Arduino Modbus RTU Slave problem

Hi Guys,
I'm stuck in my project with arduino and ModBus protocol, I think that the solution is easy but I need help !

My project is composed by:

Arduino2009 with ModBus RTU Slave
RS485 I/O Shield
DC Motor Drive (MD03) connected with I2C
Industrial Encoder
PC With VB6 Software and ModBus RTU Master over 485 serial

Basically I need to control the motor and read encoder position, everithing work perfect but if I phisically disconnect the serial arduino continue to send commands to the drive, also the drive continue to spin if I phisically disconnect the I2C lines.

To avoid problems and increase security I decide to power the Drive logic with an arduino output through a relais, if Arduino read an error on I2C it switch off the drive.

The main problem is read the presence or errors of the RS485 comunication, if I send a flag from PC on a register doesnt work because if there is no request from master Arduino did not update the register and the flag remain On.

Any suggestion will be appreciated and sorry for my english ! :wink:

Matrix

Ok... let's see if I get the setup correct.

Your PC connects to the Arduino with Modbus.
The arduino controls the drive with I2C.
The arduino reads the encoder.

Is this correct?

A Drive with an i2c interface looks strange to me as, it is a communication protocol, so when you send a setpoint, it keeps that setpoint until a new one is sent. If there's not a new setpoint (cables disconnected) it keeps spinning... and because i2c is not like profibus or other current based protocol, there is no way for the drive to know that the cables have been disconnected. What drive is this? It's the first time ever that I heard of such thing.

Do you have more information? Maybe the code so we can understand a bit better what's going on?

Is this an industrial or heavy machinery project? And more importantly, are you qualified to design such machine?

Thanks for the reply Bublindo,
Yes the Drive is over I2C, MD03 is the name of the drive - MD03 Technical Documentation

This project is not for an heavy machine, is for a micro-cable-winch , there is no safety risk at all but I want to improve security as best as I can.

Exactly because the Drive is not able to read I2C failure I add a relay on Arduino that power the drive logic (+5V), With the realy I'm able to read I2C failure and switch off the Drive. It works perfectly.

For the same reason I need to read RS485 errors and presence, if I disconnect the serial line Arduino must disable the Drive.

Errors are handled by ModBus code and works ok but I dont know how to detect the presence of RS485 line to trig the relay.

Hope this help

I think the best is to create a "heartbeat" or "rolling counter" variable and keep them on both ends.

The PC sends a value to the board that is never the same... the board checks after each time if that value is the same as received before. If not, communication is good. If it is the same, then there's an error in the communication. It's a similar concept of the one you did on the drive, but at a higher level.

The board can do the same to the PC, that way they both know what's happening. It doesn't need to be something extraordinary... 8 or 16 bits every 2 or 3 seconds (depending on the application) will do.

By the way, I work with winches myself... the mega big ones though, but I'm thinking about creating a miniature of the mega big winch. Something that you can put on top of a table. Have you got any idea on where to get the drum with a gear to attach a motor?

Thanks again !
I'll try with "heartbeat" .
Today I had another Idea that maybe can work...

If I check Serial.available() every loop and if not I trig a timer, if timer reach 1 sec means that there is no request from pc

maybe work

Thanks again