hola a todo estoy haciendo un proyecto con arduino uno y una pantalla HMI Delta DOP-B07S411, con el protocolo modbus RTU utilizo el arduino uno como maestro con la ayuda de la biblioteca modbusmaster.h y la pantalla HMI como esclavo.
el codigo que utilizo es este
/*
RS485_HalfDuplex.pde - example using ModbusMaster library to communicate
with EPSolar LS2024B controller using a half-duplex RS485 transceiver.
This example is tested against an EPSolar LS2024B solar charge controller.
See here for protocol specs:
http://www.solar-elektro.cz/data/dokumenty/1733_modbus_protocol.pdf
Library:: ModbusMaster
Author:: Marius Kintel <marius at kintel dot net>
Copyright:: 2009-2016 Doc Walker
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include <ModbusMaster.h>
//#include <SoftwareSerial.h>
/*!
We're using a MAX485-compatible RS485 Transceiver.
Rx/Tx is hooked up to the hardware serial port at 'Serial'.
The Data Enable and Receiver Enable pins are hooked up as follows:
*/
#define MAX485_DE 3
#define MAX485_RE_NEG 2
// instantiate ModbusMaster object
ModbusMaster node;
void preTransmission()
{
digitalWrite(MAX485_RE_NEG, 1);
digitalWrite(MAX485_DE, 1);
}
void postTransmission()
{
digitalWrite(MAX485_RE_NEG, 0);
digitalWrite(MAX485_DE, 0);
}
void setup()
{
pinMode(MAX485_RE_NEG, OUTPUT);
pinMode(MAX485_DE, OUTPUT);
// Init in receive mode
digitalWrite(MAX485_RE_NEG, 0);
digitalWrite(MAX485_DE, 0);
// Modbus communication runs at 115200 baud
Serial.begin(9600);
// Modbus slave ID 1
node.begin(1, Serial);
// Callbacks allow us to configure the RS485 transceiver correctly
node.preTransmission(preTransmission);
node.postTransmission(postTransmission);
}
bool state = true;
void loop()
{
uint8_t result;
uint16_t data[6];
// Toggle the coil at address 0x0002 (Manual Load Control)
result = node.writeSingleCoil(0x0001, state);
Serial.print("Error 1: ");
Serial.println(result, HEX);
state = !state;
// Read 16 registers starting at 0x3100)
result = node.readInputRegisters(0x4001, 1);
if (result == node.ku8MBSuccess)
{
Serial.print("slider: ");
Serial.println(node.getResponseBuffer(0x00));
}
else
{
Serial.print("Error 2: ");
Serial.println(result, HEX);
}
delay(1000);
}
pero no he logrado comunicarlos y la respuesta que consigo es esta.
para la pantalla HMI DOP-B07S411 estoy programando la pantalla con el software DOPSoft (Version: 2.00.07 Build: 2.00.07.04) y la configuración de la pantalla es esta para el modo esclavo en modbus RTU
y la configuración de los registros y contactos los muestro en este video.
la pantalla de la HMI trae un manual para su configuración en modo esclavo RTU. Le muestro algunos pantallazos y documentación.
I also uploaded a link to see how I have connected everything