Modifying the Modbusmaster library

Hi all, I'm using a nano 33 iot and have connected it (via RS485) to my solar inverter and have successfully written to and received valid data from the inverter. I would now like to modify one of the registers onboard the inverter and normally using a standard modbus library the correct function code can be chosen (in this case 0x06) to change the contents of a chosen R/W register.
However, in my case to write and change the contents of a register on my inverter, a function code of 0x13 (which to my knowledge is non-standard) is needed. Can anybody help me understand what parts of the modbusmaster library need to be changed to be able to do this?
My thoughts are to modify the library and rename it to say Modbusmasterm.h and then include this 'new' library in my sketch.
Any help would be greatly appreciated!

Do you mean an ASCII carriage return?
(Actual 13 decimal)

Are you sure your inverter uses a non-standard function code? If you are, post a link to the manual describing that function because every function needs a special implementation, so the manual must provide details about that function code otherwise you won't succeed.

Hi Pylon, thank for taking the time to reply. Unfortunately, I can't share a link as I was sent the protocol directly from the manufacturer (Sofar) and have looked to see if a link was available but had no joy finding one. I have attached a couple of screen shots and as you can see the write function code is 0x13 for a select range of registers. I have since looked into this and discovered that the register I am trying to write to is 0x120A, is actually outside of the range of addresses that Sofar specify that can be written to (see second pic), which is super daft as 0x120A is a R/W register. I had tried using the standard 0x06 function code but code not change its contents.

I'm going to put an oscilloscope on the comms line and see if I can see if I get a response from the inverter as in my efforts so far I get a 226 timeout error, so whatever I'm 'sending' to the inverter is not being acknowledged.. Note that I have been reading from the inverter successfully for a while, and this is the first real issue I have run into.

I would be grateful for any suggestions you have. If you need any other info, or suggest a way of me being able to upload the whole manual please let me know.
Cheers!


I have some doubts that Modbus function codes are listed here. The use the function codes 0x01 and 0x02 (which are defined in the standard) for a functionality not available in the standard. No standard compliant device would be able to communicate with that device.

Post the manual to this forum. I almost cannot believe that a company can be such crazy as to claim to implement a standard but actually using almost nothing from the standard.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.