Hi again Ricky,
I too have not had any success with official Arduino examples relating to modbus and the Portenta Machine Control, so you are not alone on that point.
I think the past path is to use a USB serial device connected to your computer which you are already working on
Also which one of my examples did you use? The old or the new portenta machine control library? Maybe I could write you an even more ābare bonesā code snippet to see if we can get you up and running?
Kind regards / Einar
Thank you for your reply,
The problem has been identified but not yet resolved. Here are the details:
opened 02:24PM - 13 Dec 25 UTC
type: imperfection
I tried to establish Modbus RTU communication between Arduino Portenta Machine C⦠ontrol and a device, but without success.
I wanted to follow the example given here to the letter:
https://docs.arduino.cc/tutorials/portenta-machine-control/user-manual/#modbus-rtu
I discovered that this line of the tutorial's code:
```cpp
MachineControl_RS485Comm.begin(baudrate, preDelay, postDelay);
```
had not been updated to reflect the change made by https://github.com/arduino-libraries/Arduino_PortentaMachineControl/pull/27.
I added the missing the config argument:
```cpp
MachineControl_RS485Comm.begin(baudrate, SERIAL_8N1, preDelay, postDelay);
```
I submitted a correction for the tutorial: https://github.com/arduino/docs-content/pull/2779
I ran the tests in both half and full duplex without success. Even with the correction, the problem persists. This is the error:
```text
- Writing coil values ... - Failed! Error code: Connection timed out
- Writing coil values ... - Failed! Error code: Connection timed out
- Writing coil values ... - Failed! Error code: Connection timed out
- Writing coil values ... - Failed! Error code: Connection timed out
```
I don't understand where the problem lies. We have purchased many Portenta Machine Controls for this purpose, so if it does not work, we need to figure out how to solve the problem.
This is my PlatformIO ini file:
```ini
[env:portenta_h7_m7]
platform = ststm32@~19.4.0
board = portenta_h7_m7
framework = arduino
build_flags = -Os -flto
lib_deps =
arduino-libraries/ArduinoBLE@^1.4.1
bblanchon/ArduinoJson@^7.4.2
arduino-libraries/ArduinoRS485@^1.1.1
arduino-libraries/Arduino_PortentaMachineControl@^1.0.4
arduino-libraries/ArduinoMqttClient@^0.1.8
mobizt/ESP_SSLClient@^2.2.3
arduino-libraries/ArduinoModbus@^1.0.9
```
### Additional context
Related discussion:
https://forum.arduino.cc/t/arduinomodbus-rs485-with-portenta-machine-control-basic-guide-updated-for-the-new-arduino-portentamachinecontrol-library/1030490/18
Thatās fine, but Iām using the Modbus RTU RS485 on the PMC daily proffessionally and have it working, so you should be able to get it to work without Arduino making some change to their library/libraries. When you get your USB serial device maybe let me know and I can give you a sketch?
Today I'm going to try downgrading as suggested in the issue.
The user who recommended downgrading says it works!
I hope so, because my client needs this feature.
For now, thank you very much for your help!
1 Like
Good luck!
Let me know if you need any help or want to an up-to-date example sketch to go along with an computer modbus testing software.
Hi all!
This PR should fix the issue
main ā leonardocavagnis:fix_rs485
opened 11:38AM - 19 Dec 25 UTC
1 Like