Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugs in Example "RS485_Halfduplex" #166

Open
noiasca opened this issue Jan 3, 2022 · 0 comments
Open

Bugs in Example "RS485_Halfduplex" #166

noiasca opened this issue Jan 3, 2022 · 0 comments

Comments

@noiasca
Copy link

noiasca commented Jan 3, 2022

ModbusMaster version

2.0.0

Arduino IDE version

1.8.13

Arduino Hardware

Arduino Mega

Platform Details

W10

Scenario:

retrieved data from EPSolar solar charge controller is not correct

Steps to Reproduce:

Compile the included example

Expected Result:

code should print data from

chargingEquipmentOutputVoltage = 0x3104
dischargingEquipmentOutputVoltage = 0x310C
and 32bit value from
dischargingEquipmentOutputPower = 0x310e + 0x310f

Actual Result:

a)
getResponseBuffer(0xC0) is not valid, as only 16 registers were requested. The correct offset from 0x3100 is +0x0C
b)
offset 0x0D and 0x0E don't fit together.
0x3100 + 0x0D is the dischargingEquipmentOutputCurrent and is a single 16bit value.
if you consider "Pload" as beeing dischargingEquipmentOutputPower than you should use the offset 0x0E and 0x0f.
Furthermore, the shift of 16 bits will need a cast on the Arduino Mega.

Feature Request

consider something like:

Serial.print("Vbatt: "); Serial.println(node.getResponseBuffer(0x04)/100.0f); Serial.print("Vload: "); Serial.println(node.getResponseBuffer(0x0C)/100.0f); // adopted Serial.print("Pload: "); Serial.println((node.getResponseBuffer(0x0E) + ((uint32_t)node.getResponseBuffer(0x0F) << 16))/100.0f); // cast and brackets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant