ESP8266 modbus library - server to write register

I am using the ESP8266 modbus TCP library here. I would like the client to set a register in the server and the server acknowledge it by changing the value back to 0.

How do I get the server to set the value of a register?

You gave way not enough informations about your project

What you really want to do? What board are you going to use? Do you even know how to make a master and a slave with this modbus lib?

Yes, very familiar with Modbus for PLC's and this has been going fine so far. I've got a Maple HMI talking to this library loaded onto a Teknic ClearCore board. I can get the Mapl HMI (acting as client) to set the value of registers on the ClearCore server. I assume there is a function in the library I attached that allows a server to set the value of a register, I just haven't been able to find it.

You write server code to ask a client for a new value, retrieve that value and then put it into the server register.

Interesting, there's no way to get it to write it itself? PLC servers can write to their own coils/registers. Its very beneficial when the PLC executes some logic in response to a command.

jBenni6

Can you post your code for the working example of the Teknic ClearCore Modbus example?
I converted the Teknic ClearCore Modbus RTU example to work on MicroChip Studios.
I also converted the ArduinoModbus example to compile on MicroChip Studios. ArduinoModbus - Arduino Reference

OMG it has hundreds of error and required changing all 23 files in that example.
I can share that with you too. If you could please test it against your converted example.

I figured it out. The function is just Hreg(Address, value). For instance, if you want the server to set the value of one of its registers 5 to a value of 10, you would do the following.

Hreg(5, 10);

Now the client can poll this register to the get the updated value.
@jeffmartin77 I messaged you. I don't want to hijack this thread so please message me if you still have questions.

@jbenni6 Hi I''m trying to link a plc and a clearcore controller via modbus how cann establish communication between the two and also read and write data I read or write data?

@allenmup This is a pretty generic question. What are you having trouble with specifically? What have you tried? What isn't working the way you expect?

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