
Alex (Customer) asked a question.
I am trying to read and write registers through my python code and using the DO-More Simulator as the Modbus Server. Can someone tell me where can I add registers and how to read write to them?

Alex (Customer) asked a question.
I am trying to read and write registers through my python code and using the DO-More Simulator as the Modbus Server. Can someone tell me where can I add registers and how to read write to them?

This is one place the Do-More help is not so much helpful. Now if you wanted to use the Do-More as a client there seem to be more information and a few videos, but as far as server goes about all I could find is: (note, copy paste from help file messed up formating)
"Devices that connect to a Do-more CPU using Modbus/TCP protocol will only have access to the following blocks of memory (these blocks are numbered in decimal):
Block Name
Description
Default Range
MI
Modbus Inputs
MI0 - MI1023
MC
Modbus Control Relays
MC0 - MC1023
MIR
Modbus Input Registers
MIR0 - MIR2047
MHR
Modbus Holding Registers
MHR0 - MHR2047"
I have never used the modbus server capability, using the D0-More protocol on a C-More one can just directly access the typical elements (C, D, V, R etc), it looks to me that for the MODBUS server one has to use the special registers Then I presume one could copy to/from the more usual objects as needed (for example for the python client to read and X bit or write a Y bit, one would have a rung on the Do-More that copied the appropriate MI or MC bit. At least that is my guess, again the "help" is not so much.

1) Go to System Configuration and under CPU Configuration make sure the Enable Modbus/TCP Server box is checked.
2) To read and write is then a matter of reading and writing to the pre-defined Modbus registers in DmD.
For example (to Read): Use MOVE to place V10 into MHR10. Your device can then read MHR10 which will be equivalent to reading one holding register at address 40010 (the address might be offset by 1).
To Write: Use your client device to write an integer into 40100. This will show up in MHR100 (again, potentially offset by 1). MHR100 is then available to do whatever you need to do with it.
Modbus servers are sandboxed in Do-more for security reasons.
The 4 sandbox blocks correspond to Modbus Inputs (MI), Coils (MC), Input Resisters (MIR), and Holding Resisters (MHR). Addresses are one-to-one. Reading Modbus Input Register 1 accesses MIR1 in the PLC.

For eg, for Coils(MC), I use the OUT Coil element, what element should I use to access the MIR and MHR?
Many ways. COPY, MOVE, INIT, MATH. You might COPY WX0-WX7 to MIR1-8, and MHR1-8 to WY0-7. That'll allow you to use the simulator's sliders to change inputs and the bars to see output changes.

But then how will I be able to control that with my Python code? What you are suggesting is control the values using sliders on the simulator.

I basically just want to read or write an array of number through my python code. How could I do this?
I assume you are using both inputs and outputs. Your Python code would be reading inputs. The sliders are just a convenient was of changing the input value.

I have 2 questions:
1) I had used coils that were getting ON/OFF by my python commands "read_coils()" and "write_coils()". Now using the COPY function as you said, I entered the ranges as you said, but where is the physical presence of these registers (comparing it with coils that I can see ON/OFF).
2) My goal was to read the register values and also write those registers with my code. Is this possible?
I'm not sure what you are asking, but maybe this will answer your question.
You are using Modbus from Python to communicate with the Modbus/TCP server in the Do-more Simulator, correct?
Modbus function 1 is Read Coils, which in Do-more maps to memory block MC. If you requested Modbus coil address 00001, Do-more will return the value of MC1.
Modbus function 2 is Read Discrete Inputs, which in Do-more maps to memory block MI. If you requested Modbus input 10001, Do-more will return the value of MI1.
Modbus function 3 is Read Holding Register, which in Do-more maps to memory block MHR. If you requested Modbus holding register 40001, Do-more will return the value of MHR1.
Modbus function 4 is Read Input Register, which in Do-more maps to memory block MIR. If you requested Modbus input register 30001, Do-more will return the value of MIR1.
Modbus functions 5 and 15 are for writing Modbus Coils. They will write to memory block MC, just like function 1 reads MC.
Modbus functions 6 and 16 are for writing Modbus Holding Registers. They will write to memory block MHR, just like function 3 reads MHR.
All of the those blocks (MC, MI, MHR, and MIR) are sandboxed for security. We don't want unsecured protocols like Modbus/TCP to have direct access to critical internal memories like X, Y, WX, and WY, which are read and written directly to physical I/O.
In the simulator, X0-X15 are tied to buttons. They can be used to toggle the memory state without using DmD. You might try copying X0-X15 to MI1-MI16, and then reading MI with function code 2. I left out MI0 because the Modbus/TCP server cannot access it.
In the simulator, Y0-Y15 are tied to LED indicators. They can be used to observe the memory state without using DmD. You might try copying MC1-16 to Y0-Y15. When you write to MC using function code 5 or 15, you'll be able to see the result on the simulator.
Same pattern for WX (copy to MIR) and WY (copy from MHR).
Copyright © 1999-2023 AutomationDirect. ALL RIGHTS RESERVED
I'm not sure what you are asking, but maybe this will answer your question.
You are using Modbus from Python to communicate with the Modbus/TCP server in the Do-more Simulator, correct?
Modbus function 1 is Read Coils, which in Do-more maps to memory block MC. If you requested Modbus coil address 00001, Do-more will return the value of MC1.
Modbus function 2 is Read Discrete Inputs, which in Do-more maps to memory block MI. If you requested Modbus input 10001, Do-more will return the value of MI1.
Modbus function 3 is Read Holding Register, which in Do-more maps to memory block MHR. If you requested Modbus holding register 40001, Do-more will return the value of MHR1.
Modbus function 4 is Read Input Register, which in Do-more maps to memory block MIR. If you requested Modbus input register 30001, Do-more will return the value of MIR1.
Modbus functions 5 and 15 are for writing Modbus Coils. They will write to memory block MC, just like function 1 reads MC.
Modbus functions 6 and 16 are for writing Modbus Holding Registers. They will write to memory block MHR, just like function 3 reads MHR.
All of the those blocks (MC, MI, MHR, and MIR) are sandboxed for security. We don't want unsecured protocols like Modbus/TCP to have direct access to critical internal memories like X, Y, WX, and WY, which are read and written directly to physical I/O.
In the simulator, X0-X15 are tied to buttons. They can be used to toggle the memory state without using DmD. You might try copying X0-X15 to MI1-MI16, and then reading MI with function code 2. I left out MI0 because the Modbus/TCP server cannot access it.
In the simulator, Y0-Y15 are tied to LED indicators. They can be used to observe the memory state without using DmD. You might try copying MC1-16 to Y0-Y15. When you write to MC using function code 5 or 15, you'll be able to see the result on the simulator.
Same pattern for WX (copy to MIR) and WY (copy from MHR).