4-20ma / ModbusMaster

Enlighten your Arduino to be a Modbus master
http://4-20ma.io/ModbusMaster/
Apache License 2.0
607 stars 354 forks source link

No communication with Delta PID controller ( DTB 4848 ) #94

Open aemtcprojects opened 7 years ago

aemtcprojects commented 7 years ago

Title - Is the System polling the Modbus Slave?

Provide the following information for all issues. Replace [brackets] and placeholder text with your responses. (QUESTIONS, BUG REPORTS, FEATURE REQUESTS) -->

ModbusMaster version

[Version of the project where you are encountering the issue]

Arduino IDE version

[Version of Arduino IDE in your environment]

Arduino Hardware

IDE latest version and Hardware is Uno

Platform Details

Windows 10


Scenario:

Trying to read register 1000H on the Delta PID controller

Steps to Reproduce:

Have confirmed that the RS 485 hardware is working through the default program and it reads the Delta controller.

aemtcprojects commented 7 years ago

My Baud rate is 9600, 8 , N , 1

aemtcprojects commented 7 years ago

include

/! 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(0x0002, state); //state = !state;

// Read 16 registers starting at 0x3100) result = node.readInputRegisters(0x1000, 6); if (result == node.ku8MBSuccess) { Serial.print("Vbatt: "); Serial.println(node.getResponseBuffer(0x04)/100.0f); Serial.print("Vload: "); Serial.println(node.getResponseBuffer(0xC0)/100.0f); Serial.print("Pload: "); Serial.println((node.getResponseBuffer(0x0D) + node.getResponseBuffer(0x0E) << 16)/100.0f); }

delay(1000); }