Write signed Integer

Hi,
I'm trying to get my inverter to charge battery from grid thru modbus tcp/ip.
I finally got an answer from Fronius support, what values to which registers I need to write.
Writing to single registers works fine, but I have difficulties in figuring out two things:

  1. How do I write a Negative value (-5000) to a register?
  2. How do I write to multiple (4) registers, that is not in a sequence right after eachother (register 40349, 40356, 40357, 40361)?

I have attached an email snip from Fronius support and the relevant register map.

Email snip_Fronius

Ps. I'm able to write with FC16 successfully to single registers + multiple registers in a sequence (just not negative values or registers out of sequence)

Thanks in advance,
Peter

As modbus is unsigned 16bit integer, convert the value -5000 to unsigned integer

You can do this with buffer-maker and buffer-parser nodes.

Or if you are comfortable in a function node, the easiest way is with a Buffer

image

You will need to write them individually. I would suggest you write a subroutine using link-call node.

link-in node "write signed-integer" → function node (convert msg.payload to UINT) → modbus write node → link-out node (set to return mode)

then call it 3 times in 1 flow/sequence...

inject node →
  change node (set msg.addr="40349" & msg.payload=2) → link-call "write signed-integer" →
  change node (set msg.addr="40356" & msg.payload=-5000) --> link-call "write signed-integer" →
  change node (set msg.addr="40357" & msg.payload=0) --> link-call "write signed-integer" →
 done!

Hi Steve,
Exactly WHAT I made differently - I'm honnestly now quite sure (I'll figure it out) :slight_smile:
The main thing is - It finally Works !!

I used the Buffer Maker - Buffer Parser and write it with FC6 for the individual registers.
I'll try the Link Out / In / Call, so I can sequence it all and create a Boolean trigger in Home Assistant to fire off all the Modbus Writes.

Thanks ALOT - how/where do I "buy you a coffee"?
Cheers,
Peter

1 Like

Thanks for the offer Peter. The only thing I would accept is your future contributions to node-red and it's community :slight_smile:

PS: You could always contribute to the OpenJS Foundation as a way of saying thanks. It has some benefits too: JavaScriptLandia - OpenJS Foundation

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