Selasa, 07 Agustus 2018

simor for substation Gunung sari






monitoring beban dengan sensor arus non invasive

#include <SPI.h>
#include <Ethernet.h>

#include "Mudbus.h"

#include "EmonLib.h"                   // Include Emon Library
EnergyMonitor emon1;                   // Create an instance
EnergyMonitor emon2;
EnergyMonitor emon3;


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, 0, 10 };
  uint8_t gateway[] = { 192, 168, 0, 254 };
  uint8_t subnet[]  = { 255, 255, 255, 0 };
  Ethernet.begin(mac, ip, gateway, subnet);
  //Avoid pins 4,10,11,12,13 when using ethernet shield
  emon1.current(0, 70);            
  emon2.current(1, 68);
  emon3.current(2, 68);
  delay(3000);
  Serial.begin(9600);
 
}

void loop()
{
  Mb.Run();
  double IrmsR = emon1.calcIrms(1480);  // Calculate Irms only
  double IrmsS = emon2.calcIrms(1480);
  double IrmsT = emon3.calcIrms(1480);
  int IR;
  int IRt;
  IR = IrmsR *80;
  if(IR<18){
    IRt = IR * 0;
  }
  else {
    IRt = IR * 1;
  }
 
  int IS;
  int ISt;
  IS = IrmsS *80;
   if(IS<18){
    ISt = IS * 0;
  }
  else {
    ISt = IS * 1;
  }
 
  int IT;
  int ITt;
  IT = IrmsT *80;
 
  if(IT<18){
    ITt = IT * 0;
  }
  else {
    ITt = IT * 1;
  }

  Mb.R[0] = IRt;
  Mb.R[1] = ISt;
  Mb.R[2] = ITt;
  Mb.R[3] = 87;
  Mb.R[4] = 7818;
 


}


Tidak ada komentar:

Posting Komentar

Cara membuat datalogger blynk di spreadsheet / googlesheet menggunakan akun versi Free

  silahkan video di atas. semoga bermanfaat. jika masih kurang jelas bisa kontak saya