You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been running code successfully on a Adafruit Feather RP2040 with PlatformIO's standard Raspberry Pi pico platform. However, once I changed over to using earlephilhower's arudino-pico on the same exact board, a strange behavior began:
Everything seems totally fine when testing 1 ModbusRTUServer physical device at a time. However, if the same code is run on two slaves connected on the same bus (for example, with modbus address/id 1 and 2, respectively) I can only read from 1 device. The requests from the second device will time out unless I wait a few seconds to issue the new request.
Computer w/ RS485 to USB adapter running python, polling both devices for their holding register values
Result
A. With PlatformIO's standard Raspberry Pi pico platform, works totally fine
B. earlephilhower's arudino-pico on the exact same setup, only 1 device can be polled at a time, without waiting seconds between devices
If I just poll one device at a time, the responses happen within a few milliseconds, and I can poll constantly for days without a comms issue. It is only when two devices are introduced that the issue occurs.
Any thoughts on what could be going on here? Thank you!
MVP main.cpp example code for Adafruit Feather RP2040:
#include<Arduino.h>
#include<ArduinoRS485.h>
#include<ArduinoModbus.h>constint MODBUS_ADDRESS = 1; //change between 1 and 2, per simultaneous devicevoidsetup()
{
Serial.begin(115200);
//slave id 1if ( !ModbusRTUServer.begin(MODBUS_ADDRESS,115200,SERIAL_8N1) )
{
Serial.println("Failed to start Modbus RTU Server!");
while (1);
}
// configure 50 holding registers, starting at address 1
ModbusRTUServer.configureHoldingRegisters(1,50);
}
voidloop()
{
// poll for Modbus RTU requestsif (ModbusRTUServer.poll() )
{
Serial.println("Received request!");
}
}
I'm wondering if this could somehow be an issue of a pin being left low/high, hogging the bus? Weird that it eventually resets. Any ideas of some things to try, and can anyone else try this as well to replicate?
per1234
changed the title
Library only working for 1 simultaneous Server on RP2040 using earlephilhower's arudino-pico
Library only working for 1 simultaneous Server on RP2040 using earlephilhower's arduino-pico platform
Sep 7, 2024
Hello! Strange issue for you all:
I have been running code successfully on a Adafruit Feather RP2040 with PlatformIO's standard Raspberry Pi pico platform. However, once I changed over to using earlephilhower's arudino-pico on the same exact board, a strange behavior began:
Everything seems totally fine when testing 1 ModbusRTUServer physical device at a time. However, if the same code is run on two slaves connected on the same bus (for example, with modbus address/id 1 and 2, respectively) I can only read from 1 device. The requests from the second device will time out unless I wait a few seconds to issue the new request.
Here's an illustration of the setup
Result
If I just poll one device at a time, the responses happen within a few milliseconds, and I can poll constantly for days without a comms issue. It is only when two devices are introduced that the issue occurs.
Any thoughts on what could be going on here? Thank you!
MVP main.cpp example code for Adafruit Feather RP2040:
platform.ini file for PlatformIO compilation:
FYI: For RS485.h to compile I had to make a couple
#define
and pinmapping changes, which may be necessary depending on your pinout as well for testingThe text was updated successfully, but these errors were encountered: