Sei sulla pagina 1di 36

PERKENALAN

FUAD HASAN
Citra Harmoni Blok Stamford ST11 No.30
Sidoarjo – Jawa Timur
SIDOARJO, 10 JUNI 1987
0815 5530 5255
fuad.hasan1987@gmail.com
puaks.blogspot.com
Pengalaman Kerja:
2006 - 2007 : unilever
2009 – sekarang : PLN
Inovasi:
SIMOR
PENGENALAN ARDUINO
ARDUINO

Arduino adalah pengendali


mikro single-board yang
bersifat OPEN SOURCE,
diturunkan dari Wiring
platform, dirancang untuk
memudahkan penggunaan
elektronik dalam berbagai
bidang. Perangkat kerasnya
memiliki prosesor Atmel AVR
dan softwarenya memiliki
bahasa pemrograman sendiri.
JENIS-JENIS
ARDUINO

 ARDUINO UNO
 ARDUINO NANO
 ARDUINO MEGA 2560
 ARDUINO PRO MICRO
 ARDUINO PRO MINI
 ARDUINO LEONARDO
 ARDUINO VIO
 ARDUINO LILYPAD
 ARDUINO ESPLORA
PINOUT ARDUINO
MEGA
PINOUT ARDUINO
UNO
MODBUS ARDUINO
PORT FISIK MODBUS ARDUINO

RS232 RS485

SERIAL ETHERNET
KARAKTERISTIK
MODBUS

NO TIMETAG

DATA DIKIRIM YANG DIMINTA


POLLING
WIRING
MODBUS SLAVE

RS485

KABEL DATA
WIRING
MODBUS MASTER
SOFTWARE
MODBUS SLAVE

SLAVE 1 SLAVE 2 SLAVE 3

ETHERNET
RS485
MODBUS MASTER
SCRIPT MODBUS RTU

#include <ModbusRtu.h>
#define ID 1 //slave ID
#define SERIALNUMBER 25120 //slave ID
#define TXEN 3 //pin tx enable RS485
#define PS 0 //port serial 0,1,2,3 (1-3 for mega 2560, uno 0
only)
Modbus slave(ID, PS, TXEN);
uint16_t au16data[10]; // jumlah address yang dibuat
SCRIPT MODBUS RTU
void setup() {
io_setup(); // I/O settings
slave.begin( 9600 ); // baudrate
}
void loop() {
slave.poll( au16data, 10 );
io_poll();
}
void io_setup() {
// define i/o
//DIGITAL INPUT
pinMode(2, INPUT);
//DIGITAL OUTPUT
pinMode(5, OUTPUT);
digitalWrite(5, LOW );
//ANALOG OUTPUT
analogWrite(6, 0 );
}
SCRIPT MODBUS RTU
void io_poll() {
// get digital inputs -> au16data[0] HOLDING REGISTER 40001 di modscan,
display options BINARY
bitWrite( au16data[0], 0, digitalRead( 2 ));

// set digital outputs -> au16data[1] HOLDING REGISTER 40002 di modscan,


display options BINARY
digitalWrite( 5, bitRead( au16data[1], 0 ));

// set analog outputs, HOLDING REGISTER 40003 dan 40004 di modscan,


display options unsign desimal
analogWrite( 6, au16data[2] );

// read analog inputs, HOLDING REGISTER 40005 dan 40006 di modscan,


display options unsign desimal
au16data[3] = analogRead( A0 );
SCRIPT MODBUS TCP IP

#include <SPI.h>
#include <Ethernet.h>
#include "Mudbus.h"
Mudbus Mb;
//Function codes 1(read coils), 3(read registers), 5(write coil), 6(write register)
//signed int Mb.R[0 to 125] and bool Mb.C[0 to 128] MB_N_R MB_N_C
//Port 502 (defined in Mudbus.h) MB_PORT

void setup()
{
uint8_t mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x51, 0x06 };
uint8_t ip[] = { 192, 168, 1, 8 };
uint8_t gateway[] = { 192, 168, 1, 1 };
uint8_t subnet[] = { 255, 255, 255, 0 };
Ethernet.begin(mac, ip, gateway, subnet);
//Avoid pins 4,10,11,12,13 when using ethernet shield
delay(5000);
Serial.begin(9600);
pinMode(7, INPUT);
pinMode(8, OUTPUT);
}
SCRIPT MODBUS TCP IP

void loop()
{
Mb.Run();

//Analog inputs 0-1023


Mb.R[0] = analogRead(A0); //pin A0 to Mb.R[0]
Mb.R[1] = analogRead(A1);
Mb.R[2] = analogRead(A2);

//Analog outputs 0-255


analogWrite(6, Mb.R[6]); //pin ~6 from Mb.R[6]

//Digital inputs
Mb.C[7] = digitalRead(7); //pin 7 to Mb.C[7]

//Digital outputs
digitalWrite(8, Mb.C[8]); //pin 8 from Mb.C[8]
}
MODBUS

WIRING MODBUS SLAVE


MASTER

ETHERNET KABEL DATA


SCRIPT MODBUS
MASTER

#include <SPI.h>
#include <Ethernet.h>
#include "Mudbus.h"
#include <SimpleModbusMaster.h>
#include <avr/wdt.h>
#define baud 19200
#define timeout 3000
#define polling 300 // the scan rate ms
#define retry_count 100
#define TxEnablePin 2
#define TOTAL_NO_OF_REGISTERS 70
SCRIPT MODBUS
MASTER

enum
{
PACKET1,// power meter1
PACKET2,// power meter2
PACKET3,//
PACKET4,//
PACKET5,//
PACKET6,//
PACKET7,//
TOTAL_NO_OF_PACKETS // leave this last entry
};
Packet packets[TOTAL_NO_OF_PACKETS];
unsigned int regs[TOTAL_NO_OF_REGISTERS];
Mudbus Mb;
SCRIPT MODBUS
MASTER
void setup()
{
uint8_t mac[] = { 0x96, 0xA2, 0xDA, 0x00, 0x51, 0x06 };
uint8_t ip[] = { 192, 168, 201, 10 };
uint8_t gateway[] = { 192, 168, 201, 1 };
uint8_t subnet[] = { 255, 255, 255, 0 };
Ethernet.begin(mac, ip, gateway, subnet);
//Avoid pins 4,10,11,12,13 when using ethernet shield
delay(2000);
modbus_construct(&packets[PACKET1], 1, READ_HOLDING_REGISTERS, 0, 4, 0);//
modbus_construct(&packets[PACKET2], 1, PRESET_SINGLE_REGISTER, 1, 1, 5);
modbus_construct(&packets[PACKET3], 1, PRESET_SINGLE_REGISTER, 2, 1, 6);
modbus_construct(&packets[PACKET4], 2, READ_HOLDING_REGISTERS, 0, 4, 7);//
modbus_construct(&packets[PACKET5], 2, PRESET_SINGLE_REGISTER, 1, 1, 11);
modbus_construct(&packets[PACKET6], 2, PRESET_SINGLE_REGISTER, 2, 1, 12);
modbus_construct(&packets[PACKET7], 3, READ_HOLDING_REGISTERS, 0, 12, 20);//
modbus_configure(&Serial3, baud, SERIAL_8N1, timeout, polling, retry_count,
TxEnablePin, packets, TOTAL_NO_OF_PACKETS, regs);
}
SCRIPT MODBUS
MASTER
void loop()
{
modbus_update();
Mb.Run();
//device 1 & 2
Mb.R[0] = (regs[0]);//digital input 1
Mb.R[1] = (regs[7]);//digital input 2
Mb.R[2] = (regs[3]);// analog input 1
Mb.R[3] = (regs[10]);//analog input 2
regs[5] = Mb.R[4];//Digital output 1
regs[11] = Mb.R[5]; //digital output 2
regs[6] = Mb.R[6]; //analog output 1
regs[12] = Mb.R[7];//analog output2

//ied modbus
Mb.R[8] = (regs[20]);//
Mb.R[9] = (regs[21]);//
Mb.R[10] = (regs[22]);//
Mb.R[11] = (regs[23]);//
}
MODBUS TO BLYNK

MODEM ROUTER
IOT BLYNK

BLYNK adalah platform untuk aplikasi OS Mobile (iOS


dan Android) yang bertujuan untuk kendali module
Arduino, Raspberry Pi, ESP8266, WEMOS D1, dan module
sejenisnya melalui Internet.

MODEM ROUTER
CARA
MENGGUNAKAN
BLYNK

Bagaimana cara menggunakan BLYNK?


1. Download dan install aplikasi melalui “PlayStore“
2. Buka aplikasi, dan silahkan sign up new account atau login
menggunakan “Facebook“
3. Buat new project, dan pilihlah salah satu module yang akan Anda
gunakan maupun aksesoris module yang berfungsi sebagai
sarana terhubung ke Internet.
4. Setelah itu drag and drop rancangan proyek Anda
5. Kemudian klik Blynk untuk mengirimkan Token Auth melalui email
6. Dan terakhir cek inbox email Anda dan temukan Auth Token yang
dimana ini akan digunakan untuk program yang di downloadkan
ke module
BUILD PROJECT
BLYNK

Pilih Hardware Token dikirim ke


Buat New Project email
yang dipakai
Cek Token
di email
BUILD PROJECT
BLYNK

Klik + untuk Pilih salah klik object Edit pin yang Klik Play
Add I/O satu yang sudah digunakan
dipilih
SCRIPT MODBUS
BLYNK
#include <SPI.h>
#include <Ethernet.h>
#include "Mudbus.h"
#define BLYNK_PRINT Serial
#include <BlynkSimpleEthernet.h>
#include <SimpleModbusMaster.h>
#include <avr/wdt.h>
#define baud 9600
#define timeout 3000
#define polling 300 // the scan rate ms
#define retry_count 100
#define TxEnablePin 2
#define TOTAL_NO_OF_REGISTERS 70
enum
{
PACKET1,//
PACKET2,//
PACKET3,//
PACKET4,//
PACKET5,//
PACKET6,//
PACKET7,//
TOTAL_NO_OF_PACKETS // leave this last entry
};
Packet packets[TOTAL_NO_OF_PACKETS];
unsigned int regs[TOTAL_NO_OF_REGISTERS];
Mudbus Mb;
char auth[] = "wCulz4wlqvzOAwHKHmrZBCHJDjjhJDPQ";
BlynkTimer timer;
SCRIPT MODBUS
BLYNK
void sendSensor()
{
Mb.R[0] = (regs[0]);//digital input 1
Mb.R[1] = (regs[7]);//digital input 2
Mb.R[2] = (regs[3]);// analog input 1
Mb.R[3] = (regs[10]);//analog input 2
regs[5] = Mb.R[4];//Digital output 1
regs[11] = Mb.R[5]; //digital output 2
regs[6] = Mb.R[6]; //analog output 1
regs[12] = Mb.R[7];//analog output2

//ied modbus
Mb.R[8] = (regs[20]);//volt
Mb.R[9] = (regs[21]);//current
Mb.R[10] = (regs[22]);// freq
Mb.R[11] = (regs[23]);//power

//blynk
Blynk.virtualWrite(V0, regs[3]); //AI SLAVE1
Blynk.virtualWrite(V1, regs[4]); //AI SLAVE2
Blynk.virtualWrite(V2, regs[20]); //VOLT
Blynk.virtualWrite(V3, regs[21]); //CURRENT
Blynk.virtualWrite(V4, regs[22]); //FREQ
Blynk.virtualWrite(V5, regs[23]); //POWER

}
SCRIPT MODBUS
BLYNK
void setup()
{
Serial.begin(9600); // See the connection status in Serial Monitor
byte arduino_mac[] = { 0xC0, 0x15, 0xC0, 0xFF, 0xEE, 0x81 };
IPAddress arduino_ip ( 192, 168, 201, 10);
IPAddress dns_ip ( 8, 8, 8, 8);
IPAddress gateway_ip ( 192, 168, 201, 1);
IPAddress subnet_mask(255, 255, 255, 0);
Blynk.begin(auth, "blynk-cloud.com", 8080, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
modbus_construct(&packets[PACKET1], 1, READ_HOLDING_REGISTERS, 0, 4, 0);//
modbus_construct(&packets[PACKET2], 1, PRESET_SINGLE_REGISTER, 1, 1, 5);
modbus_construct(&packets[PACKET3], 1, PRESET_SINGLE_REGISTER, 2, 1, 6);
modbus_construct(&packets[PACKET4], 2, READ_HOLDING_REGISTERS, 0, 4, 7);//
modbus_construct(&packets[PACKET5], 2, PRESET_SINGLE_REGISTER, 1, 1, 11);
modbus_construct(&packets[PACKET6], 2, PRESET_SINGLE_REGISTER, 2, 1, 12);
modbus_construct(&packets[PACKET7], 3, READ_HOLDING_REGISTERS, 0, 12, 20);//
modbus_configure(&Serial2, baud, SERIAL_8N1, timeout, polling, retry_count, TxEnablePin, packets,
TOTAL_NO_OF_PACKETS, regs);
timer.setInterval(1000L, sendSensor);
}

void loop()
{
Blynk.run();
modbus_update();
timer.run();
Mb.Run();
}
modbus

RTU 1
LAN

Wifi router RTU 2

Virtuino modbus
VIRTUINO modbus
Adalah software aplikasi android berbasis
SCADA dan komunikasinyda dengan hardware
menggunakan protocol modbus tcp IP
Download
CARA MENGGUNAKAN MASUKKAN IP
RTU DAN PORT

KONFIGURASI RTU

Klik

Klik

ADD
MODULE

Klik
USER MANUAL

KONFIGURASI DATABASE RTU

MASUKKAN ADDRES
DAN PILIH
ADD DATABASE PILIH SALAH SATU FUNCTIONNYA CONNECT

Klik
Klik

Klik Klik
KONSEP KONEKSI
wifi
LAN

Wifi router
IMPLEMENTASI Arduino with protocol
Modbus TCP IP

Virtuino modbus wifi


wifi

Wifi router
Software Modbus
SIMULASI Slave