Hello, or good evening, depending on the time zone... I think I'm posting in the right section...
I'm fairly new to Node-Red, but I'm enjoying it and making good progress with my project.
Basically, it's a solar router based on an RS485 bus. On this bus, there is a JSY-MK-333 meter, an LSA-H3PY40BM power variator, and a DS18B20 temperature sensor, all in Modbus on the RS485 bus at 19 200 baud.
The basic principle is to measure the energy exported to the grid and compensate for it by varying the power of the water heater. That's a simplified description.
So I've made progress on the project and on a ‘flow’ I read and write to the modules at staggered intervals. For my tests, this is enough to check that the requests are correct.
The nodes currently in use are Modbus-Read and Modbus-Write.
Now I would like to synchronise everything a little better. That is, to chain the different read and write requests as quickly as possible and avoid conflicts on the bus. So, I would like to ensure reliably that after each request, I have received the complete response before launching the next one, but I have not yet found a convincing solution. Basically, the end of the response triggers the next action/request.
What do you recommend for organising this sequencing?
To read the full set of data use Modbus Getter nodes, or Modbus Flex Getter rather than the basic Read node. Then you can trigger the first one with a Inject node firing at an appropriate rate. Move the result from that node into a message property such as msg.meter and then pass it on to another Getter node to read the second device. The result from that node will still have msg.meter in it and you can move the result from the second one to msg.temperature or whatever and then to the third one (if you are reading from three, I am not sure). At the end of the read sequence you will then have all the responses in one message. You can put a Delay node between the Getters if you want to make sure the bus has time to settle between the device reads.
Then you can do your calculations and do whatever modbus writes are required. Again do them in series if you need to write to multiple devices.
Obviously make sure that the repeat rate of the Inject node at the start is slow enough to allow for the complete sequence.
I have read and reread your proposal, and I will read it again tomorrow. I think I understand it. I need to think it over and run some tests. On the power variator, I request 28 registers every second, but only use a few of them. On the energy measurement module, I request roughly 55 every second, again to use only a few, but that works fine. On the temperature measurement, only one register every 10 minutes. I'll test it tomorrow, Sunday. It's late here in France, so I'm going to get some sleep!
Practice makes perfect. Thank you for confirming this approach with other more appropriate nodes. I have attached the progress made. Some nodes are there for testing purposes. But the result I was waiting for to move forward is there, namely that the loop is working well.
I no longer need the injection knot; the loop starts on its own.
I am continuing to work on and optimise it. Once I have made sure that it works as expected, I will then need to insert the module for calculating the power regulator output percentage.
Please do not close the thread, as I will likely return to request assistance once again. If anyone has any advice on how to optimise, I am interested. Thank you in advance.