MODBUS protocol.

Dear all,

I have some data to be send on SCADA system . Data like date/time. angle of motor, gps data , wind speed ,. I wanted to send the parameter through modbus protocol.Initially We use Serial.print and printing on Serial monitor or we used python to get data from Serial using (USB to TTl )level.

Now We have SCADA system, and Two arduino slaves. The scada system works on Modbus protocol. The Data has to be send from SLAVES to SCADA system via modbus protocol . Let me know how to implement modbus protocol over the Arduino Platform. How communication occur here. Please share wiring diagram for modbus protocol for arduino UNO.

This code i am writing RTC . Whatever value return in to RTC send to master via Modbus protocol.

Below data to be sent via modbus instead of serialmonitor

Serial.print(year);
Serial.print(month);
Serial.print(monthDay );
Serial.print(hour);
Serial.print(minute);
Serial.println(second);

#include "Wire.h"
#define DS1307_ADDRESS 0x68
byte zero = 0x00; //workaround for issue #527

void setup(){
  Wire.begin();
  Serial.begin(9600);
  setDateTime(); //MUST CONFIGURE IN FUNCTION
}

void loop(){
  printDate();
  delay(1000);
}

void setDateTime(){

  byte second =  45; //0-59
  byte minute =01; //0-59
  byte hour = 13; //0-23
  byte weekDay =2; //1-7
  byte monthDay =24; //1-31
  byte month = 2; //1-12
  byte year  =       14; //0-99

  Wire.beginTransmission(DS1307_ADDRESS);
  Wire.write(zero); //stop Oscillator

  Wire.write(decToBcd(second));
  Wire.write(decToBcd(minute));
  Wire.write(decToBcd(hour));
  Wire.write(decToBcd(weekDay));
  Wire.write(decToBcd(monthDay));
  Wire.write(decToBcd(month));
  Wire.write(decToBcd(year));

  Wire.write(zero); //start

  Wire.endTransmission();

}

byte decToBcd(byte val){
// Convert normal decimal numbers to binary coded decimal
  return ( (val/10*16) + (val%10) );
}

byte bcdToDec(byte val)  {
// Convert binary coded decimal to normal decimal numbers
  return ( (val/16*10) + (val%16) );
}

void printDate(){

  // Reset the register pointer
  Wire.beginTransmission(DS1307_ADDRESS);
  Wire.write(zero);
  Wire.endTransmission();

  Wire.requestFrom(DS1307_ADDRESS, 7);

   int second = bcdToDec(Wire.read());
  int minute = bcdToDec(Wire.read());
  int hour = bcdToDec(Wire.read() & 0b111111); //24 hour time
  int weekDay = bcdToDec(Wire.read()); //0-6 -> sunday - Saturday
  int monthDay = bcdToDec(Wire.read());
  int month = bcdToDec(Wire.read());
  int year = bcdToDec(Wire.read());

 /*  int second = 11;
  int minute =18;
  int hour = 18;
  int weekDay = 1;
  int monthDay = 2;
  int month = 11;
  int year = 12;
*/
  //print the date EG   3/1/11 23:59:59
  Serial.print(monthDay);
  Serial.print("/");
  
  
  Serial.print(month);
  Serial.print("/");
  
  Serial.print(year);
  Serial.print(" ");
  Serial.print(hour);
  Serial.print(":");
  Serial.print(minute);
  Serial.print(":");
  Serial.println(second);
  
 // Serial.print("Week Day Of week");
//  Serial.println(weekDay);
  

}

Arduino Playground - ModbusMaster Library - result of a 15 second effort with google ...

And the hard work if this library doesnt do what you need to : http://www.modbus.org/docs/Modbus_Application_Protocol_V1_1b.pdf (another 15 seconds with Google)

Good luck.

I could not able to download Modbus library . Site under construction

GitHub - 4-20ma/ModbusMaster: Enlighten your Arduino to be a Modbus master works for me

Thanks . Since i am new to Learing modbus protocol. Let me know basic wiring diagram with arduino and Basic test program i can run over arduino with setup

Thanks . Since i am new to Learing modbus protocol. Let me know basic wiring diagram with arduino and Basic test program i can run over arduino with setup

Do not keep cross-posting the same question and references to the same question.

AWOL:
Do not keep cross-posting the same question and references to the same question.

SOrry for that. I didn't find protocol column initially . SO i pasted i many

That's the third account registered from the same IP address with very similar names.
Any comments?

We've completed the translation of our open source SCADA into English recently. It would be nice if Arduino developers use our SCADA, the source is here: GitHub - RapidScada/scada: Contains Rapid SCADA sources
Link for binaries: Rapid SCADA | Free, Open Source, Full Featured SCADA Software » Download