Sunday, May 10, 2015

Communication between SCADA and Arduino Microcontroller with Modbus Protocol




This application about how to use SCADA for Arduino Microcontroller.
Communication between SCADA and Arduino using Modbus Protocol.
Example for this application about Water Storage Tank in SCADA and for in Arduino about Ultrasonic Sensor.
Ultrasonic sensors as Air / Liquid Level Sensors non-contact and the water level is shown in SCADA application.
For SCADA software using free SCADA software with the product name IGSS FREE50 from igss.schneider-electric.com




Communication between SCADA and Arduino Microcontroller with Modbus Protocol

Hardware required for this SCADA application:
1. Arduino UNO
2. Adaptor DC 9V for Arduino Power
3. Ultrasonic Sensor, I use HC-SR04
4. TTL to RS232 Female Connector
5. USB to RS232 Converter, If the computer does not have a rs232 connector
6. Computer / Laptop
About Ultrasonic Sensor: http://program-plc.blogspot.com/2015/01/programmable-logic-controller-plc.html

Hardware for Communication between SCADA and Arduino


Hardware Connections for SCADA and Arduino Application:

Hardware Connections for SCADA and Arduino Application


Download Project File for SCADA and Arduino Application:
1. FREE SCADA Software (Click Submit to download): http://igss.schneider-electric.com/products/igss/download/free-scada.aspx
2. Arduino libraries, click here
Copy-Paste folder MODBUS into Folder C:\Program Files (x86)\Arduino\libraries
3. Arduino project file, click here
4. SCADA project file, click here

Video about How to make Water Storage Tank and Modbus Setup in SCADA software:



Arduino code for SCADA Application:
#include <modbus.h>
#include <modbusDevice.h>
#include <modbusRegBank.h>
#include <modbusSlave.h>
modbusDevice regBank;
modbusSlave slave;

#define Trig 13
#define Echo 12

const float CmFactor = 29.0;
const float InFactor = 73.746;

void setup()
{   
  pinMode(Trig, OUTPUT);
  pinMode(Echo, INPUT); 
 //Assign the Modbus Slave ID.
//Set in SCADA for IGSS node Number=1 
  regBank.setId(1);
 //Add Analog Output registers 40001 & 40002 to the register bank 
  regBank.add(40001);  
  regBank.add(40002);  
  slave._device = &regBank; 
 // Initialize the baudrate serial port 
 // Set in SCADA: Baud rate=9600,Data bits=8,Stop bits=1,Parity=None,Flow control=None
  slave.setBaud(9600);   
}

void loop()
{
  long durationMicroseconds, distanceCentimeters,distanceInches;
  digitalWrite(Trig, LOW);  
  delayMicroseconds(2); 
  digitalWrite(Trig, HIGH);
  delayMicroseconds(10); 
  digitalWrite(Trig, LOW);
  durationMicroseconds = pulseIn(Echo, HIGH);
  distanceCentimeters = (durationMicroseconds/2) / CmFactor;
  distanceInches = (durationMicroseconds/2) / InFactor;   
  regBank.set(40001, (word) distanceCentimeters);
  regBank.set(40002, (word) distanceInches);
  slave.run();
  delay(100);
}



Labels:








Newer Post Older Post Home

You may also like these ebook:

Get Free PLC eBook directly sent to your email,
and email subscription to program-plc.blogspot.com




We hate SPAM. Your information is never sold or shared with anyone.

Your Email Will Be 100% Secured !

Your email is stored safely on Google FeedBurner