Proper example for Modbus Register Frames

I am sitting with a brick on my desk. An Arduino Pro Portenta Machine Control (H7 M7 Core) device, I cannot use with modbus on HMI. There exists no clear concise examples out there of how to Start the Machine control as Modbus RTU/TCP Slave or Master. Nothing exists in the form of examples on registers and frames, reading/writing single or multiple coils, nor anything usable for the average developer to use. The standard Arduino libraries does nothing, and the built in examples of the device itself, as stated, is useless.
I don't know If I am looking in the wrong places, asking the wrong questions, asking the wrong forum, or what ever my problem is, but I need assistance. I have spent considerable amount of my personal money to obtain and research this device, but it is useless If I cannot get the device working with HMI or other modbus devices for the end user.

Please help.

Hello kwaaigone,

I am also learning about this board myself so I cannot offer you detailed assistance.
However, have you installed the Arduino_MachineControl library?
It can be installed with the library manager in the IDE.

I'm also assuming you've had a look at this: https://docs.arduino.cc/software/ide-v1/tutorials/getting-started/cores/arduino-mbed_portenta

I had an easy time getting the Digital_Output example from the Arduino_MachineControl library working, so I would suggest starting there.

Looking at the examples in this library and the keywords document will also help you understand how to reference pins with the Machine Control, which is a bit different from other boards (I think).

Hope this helps you
/ Einar

EDIT:
The Arduino_MachineControl library also comes with Modbus RTU half duplex (RS485) and full duplex (RS422) examples, which may be useful to you.

Hello einarbjorkman

Thank You Sir for your response. It is much appreciated. Indeed I have installed the library as well as any other I might have been able to use, yet I have no luck.
I can utilize mostly all functionality of the PMC, and I am aware of the RS485 capabilities that are documented and explained with examples in the libraries provided, but that is where it ends.

I am new to RS485 and Modbus but, by now I have enough experience and understand how the Modbus registers work and reading/writing to single and multiple coils, input & holding registers work, etc.

Unfortunately the info available on how to do exactly that, is not available anywhere I look. I need to do the following:

  1. Set the PMC as Modbus Slave with address (usually 1, where 0 is reserved for master)
  2. Determine parameters like Baud rate, Parity, Stop Bits, data length, com port
  3. Create registers arrays of 16 bit Unsigned decimals (Word) and populate these with info like thermocouple temp reading, analog input reading, digital input state, etc..
  4. Have an HMI read these registers and provide a visualization of the info in the registers for users and return input values to the PMC.

Thanks once again. I appreciate any help I can get!

Hello again kwaaigone!

It seems we are "sitting in the same boat" here, as I am also trying to figure out how to establish Modbus RS485 with the Machine Control.

I can maybe help you a little further by sharing a sketch which was shared with me by Arduino support team:
ModbusRTUTemperatureSensor.ino (1.8 KB)

This sketch uses the ArduinoModbus and RS485 libraries.
In the 'Setup' section you can see this line of code:

ModbusRTUClient.begin(comm_protocols.rs485, baudrate, SERIAL_8N1)

Here a client/master is started, baudrate (defined higher up) is selected, and data length, parity, and stop bits is selected.
SERIAL_8N1:
Size - 8 bits
Parity - None
Stop bits - 1.

Looking at this sketch and the ArduinoModbus documentation and comparing could be useful...

I have not successfully run any Modbus sketch yet with the Machine Control yet as I am a bit confused about the physical connections (this is not very clear from the pinout and schematics in my opinion), so I cannot confirm that this sketch works :sweat_smile:
However I assume it does because of the source.

If you do get the Machine Control to act as a slave a nice tool to read the registers from a pc is ModbusTool (http://modbusmaster.com/). Of course you need to connect pc to Machine Control with RS485 first.

/Einar

Thanks once again for your help Sir!

This is the most useful information I have been able to locate thus far for the PMC. I am using a WECON HMI, and have managed to interface it with Modbus to a CONTROLINO MAXI with no problems. If I manage to get this working with your help on the PMC, I will gladly share what I have.

Keep watching this space!

Hey kwaaigone,

Glad that I could be of some help :slight_smile:
I will keep watching this post and you can then share your results.

/ Einar

Hello again kwaaigone, I was able to solve the problem we were both having an have now written a short guide or "how-to" here:

Maybe it can be helpful if you have not sovled the problem already (?). :slight_smile:

Hello again Einarbjorkman!

A very big congratulations to You! I have been ploughing away but no luck as yet all though I made a little progress, It was not noteworthy.

I enlisted the help of a plc engineer I know but we have made no breakthrough yet.

Seeing Your solution here, I am hopeful for my projects with this for the future.

Once again thanks for your help and contribution to the opensource community! :grin::+1::+1:

Hey kwaaigone,

no problem at all, only happy if the Machine Control subsection of the forum gets a bit more activity and solutions! :wink: :smiley:

Hello Kwaaigone,

I been trying to get the Portenta machine control to talk to a Wecon HMI, first I used the IDE PLC, bust as you say very little or no information, and I cannot get to work. can you share more info on how you succeeded.