adapun langkah-langkah integrasikan adam 4055 ke SIMOR
1. cek register addres dan kenali type datanya.
2. test dulu pakai modscan dengan usb to rs485
3. setelah sukses di modscan, pindah kabel ke modul simor.
4. mapping datanya
#include <SPI.h>
#include <Ethernet.h>
#include "Mudbus.h"
#define BLYNK_PRINT Serial
//#include <TimeLib.h>
//#include <WidgetRTC.h>
#include <BlynkSimpleEthernet.h>
#include <SimpleModbusMaster.h>
#include <avr/wdt.h>
#define baud 9600
#define timeout 3000
#define polling 100 // the scan rate ms
#define retry_count 100
// used to toggle the receive/transmit pin on the driver
#define TxEnablePin 2
// The total amount of available memory on the master to store data
#define TOTAL_NO_OF_REGISTERS 70
enum
{
PACKET1,//
PACKET2,//
PACKET3,//
PACKET4,//
PACKET5,//
PACKET6,//
PACKET7,//
TOTAL_NO_OF_PACKETS // leave this last entry
};
// Create an array of Packets to be configured
Packet packets[TOTAL_NO_OF_PACKETS];
// Masters register array
unsigned int regs[TOTAL_NO_OF_REGISTERS];
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
char auth[] = "your token";//
BlynkTimer timer;
WidgetLED led0(V6);//
WidgetLED led1(V7);//
//WidgetRTC rtc;
int ledStatus0;
int ledStatus1;
#define BLYNK_GREEN "#23C48E"
#define BLYNK_BLUE "#04C0F8"
#define BLYNK_YELLOW "#ED9D00"
#define BLYNK_RED "#D3435C"
#define BLYNK_DARK_BLUE "#5F7CD8"
void simor()
{
ledStatus0 = (regs[0]);
if (ledStatus0 > 0) {
led0.setColor(BLYNK_RED);
} else {
led0.setColor(BLYNK_GREEN);
}
ledStatus1 = (regs[1]);
if (ledStatus1 > 0) {
led1.setColor(BLYNK_RED);
} else {
led1.setColor(BLYNK_GREEN);
}
}
BLYNK_WRITE(V8)
{
int do1 = param.asInt();
Serial.print(do1);
Serial.println();
if ( do1 == 1){
regs[5] = 0xFF00;
}
else {
regs[5] = 0x0000;
}
}
BLYNK_WRITE(V9)
{
int do2 = param.asInt();
Serial.print(do2);
Serial.println();
if ( do2 == 1){
regs[6] = 0xFF00;
}
else {
regs[6] = 0x0000;
}
}
void setup()
{
Serial.begin(9600); // See the connection status in Serial Monitor
Blynk.begin(auth);
5. upload sketch ke SIMOR
6. sambungkan kabel lan ke simor dan router yang sudah ada koneksi internetnya
7. bikin HMI di blynk
Tidak ada komentar:
Posting Komentar