How to write multipule data ( byte) mesambccc
- AdelRTP
- Away
- New Member
-
Less
More
- Posts: 17
- Thank you received: 2
28 Jun 2025 16:58 #330963
by AdelRTP
How to write multipule data ( byte) mesambccc was created by AdelRTP
this is my code for reading and writing using MESAMBCCC
I can read and write data without problem in case i use one register but when i try to write on a multiple registers i faced a lot of problems i captured some of them on the attachments
<?xml version="1.0" encoding="UTF-8"?>
<mesamodbus baudrate="115200" parity="E" stopbits="1">
<devices>
<device address="0x02" name="mrje70a"/>
</devices>
<initlist>
</initlist>
<commands>
<command device="mrje70a" modbustype="U_AB" haltype="HAL_U32" function="R_REGISTERS" address="0x6099" count ="5" name="homingread"/>
<command device="mrje70a" function="W_REGISTERS" modbustype="U_AB" haltype="HAL_U32" address="0x6099" count="5" name="hommingwrite"/>
<!--<command device="mrje70a" function="W_REGISTERS" address="0x6099" >
<pin name= "hnumentries" modbustype="U_AB" haltype="HAL_U32" value="02"/>
<pin name= "hspeedss" modbustype="U_CDAB" haltype="HAL_U32"/>
<pin name= "hspeedsz" modbustype="U_CDAB" haltype="HAL_U32"/>
</command>-->
</commands>
</mesamodbus>
I can read and write data without problem in case i use one register but when i try to write on a multiple registers i faced a lot of problems i captured some of them on the attachments
<?xml version="1.0" encoding="UTF-8"?>
<mesamodbus baudrate="115200" parity="E" stopbits="1">
<devices>
<device address="0x02" name="mrje70a"/>
</devices>
<initlist>
</initlist>
<commands>
<command device="mrje70a" modbustype="U_AB" haltype="HAL_U32" function="R_REGISTERS" address="0x6099" count ="5" name="homingread"/>
<command device="mrje70a" function="W_REGISTERS" modbustype="U_AB" haltype="HAL_U32" address="0x6099" count="5" name="hommingwrite"/>
<!--<command device="mrje70a" function="W_REGISTERS" address="0x6099" >
<pin name= "hnumentries" modbustype="U_AB" haltype="HAL_U32" value="02"/>
<pin name= "hspeedss" modbustype="U_CDAB" haltype="HAL_U32"/>
<pin name= "hspeedsz" modbustype="U_CDAB" haltype="HAL_U32"/>
</command>-->
</commands>
</mesamodbus>
Attachments:
Please Log in or Create an account to join the conversation.
- PCW
-
- Online
- Moderator
-
Less
More
- Posts: 18784
- Thank you received: 5190
28 Jun 2025 17:14 #330964
by PCW
Replied by PCW on topic How to write multipule data ( byte) mesambccc
Can you attach your mesambccs file?
The following user(s) said Thank You: AdelRTP
Please Log in or Create an account to join the conversation.
- AdelRTP
- Away
- New Member
-
Less
More
- Posts: 17
- Thank you received: 2
28 Jun 2025 17:34 #330966
by AdelRTP
Replied by AdelRTP on topic How to write multipule data ( byte) mesambccc
<?xml version="1.0" encoding="UTF-8"?>
<mesamodbus baudrate="115200" parity="E" stopbits="1">
<devices>
<device address="0x02" name="mrje70a"/>
</devices>
<initlist>
</initlist>
<commands>
<command device="mrje70a" modbustype="U_AB" haltype="HAL_U32" function="R_REGISTERS" address="0x6099" count ="5" name="homingread"/>
<command device="mrje70a" function="W_REGISTERS" modbustype="U_AB" haltype="HAL_U32" address="0x6099" count="5" name="hommingwrite"/>
<!--<command device="mrje70a" function="W_REGISTERS" address="0x6099" >
<pin name= "hnumentries" modbustype="U_AB" haltype="HAL_U32" value="02"/>
<pin name= "hspeedss" modbustype="U_CDAB" haltype="HAL_U32"/>
<pin name= "hspeedsz" modbustype="U_CDAB" haltype="HAL_U32"/>
</command>-->
</commands>
</mesamodbus>
<mesamodbus baudrate="115200" parity="E" stopbits="1">
<devices>
<device address="0x02" name="mrje70a"/>
</devices>
<initlist>
</initlist>
<commands>
<command device="mrje70a" modbustype="U_AB" haltype="HAL_U32" function="R_REGISTERS" address="0x6099" count ="5" name="homingread"/>
<command device="mrje70a" function="W_REGISTERS" modbustype="U_AB" haltype="HAL_U32" address="0x6099" count="5" name="hommingwrite"/>
<!--<command device="mrje70a" function="W_REGISTERS" address="0x6099" >
<pin name= "hnumentries" modbustype="U_AB" haltype="HAL_U32" value="02"/>
<pin name= "hspeedss" modbustype="U_CDAB" haltype="HAL_U32"/>
<pin name= "hspeedsz" modbustype="U_CDAB" haltype="HAL_U32"/>
</command>-->
</commands>
</mesamodbus>
Please Log in or Create an account to join the conversation.
- AdelRTP
- Away
- New Member
-
Less
More
- Posts: 17
- Thank you received: 2
28 Jun 2025 18:49 #330968
by AdelRTP
Replied by AdelRTP on topic How to write multipule data ( byte) mesambccc
This is my complete code
<?xml version="1.0" encoding="UTF-8"?>
<mesamodbus baudrate="115200" parity="E" stopbits="1">
<devices>
<device address="0x02" name="mrje70a"/>
</devices>
<initlist>
</initlist>
<commands>
<command device="mrje70a" modbustype="U_AB" haltype="HAL_U32" function="R_REGISTERS" address="0x2b01" count ="2" name="cfp"/>
<command device="mrje70a" modbustype="U_AB" haltype="HAL_U32" function="R_REGISTERS" address="0x2b0f" count ="1" name="volt"/>
<command device="mrje70a" modbustype="U_AB" haltype="HAL_U32" function="R_REGISTERS" address="0x2b2d" count ="1" name="power"/>
<command device="mrje70a" modbustype="U_AB" haltype="HAL_U32" function="R_REGISTERS" address="0x2001" count ="2" name="rpa01"/>
<command device="mrje70a" function="R_REGISTERS" address="0x2801">
<pin name = "numbreent" modbustype="U_AB" haltype="HAL_U32"/>
<pin name = "position" modbustype="U_CDAB" haltype="HAL_U32" scale ="0"/>
<pin name = "speed" modbustype="U_AB" haltype="HAL_U32"/>
<pin name = "acce" modbustype="U_AB" haltype="HAL_U32"/>
<pin name = "dec" modbustype="U_AB" haltype="HAL_U32"/>
<pin name="dwell" modbustype="U_AB" haltype="HAL_U32"/>
<pin name="subfunc" modbustype="U_AB" haltype="HAL_U32"/>
<pin name="mcode" modbustype="U_AB" haltype="HAL_U32"/>
</command>
<command device="mrje70a" modbustype="U_AB" haltype="HAL_U32" function="R_REGISTERS" address="0x1010" count ="11" name="eeprom"/>
<command device="mrje70a" modbustype="U_AB" haltype="HAL_U32" function="R_REGISTERS" address="0x2c12" count ="9" name="input"/>
<command device="mrje70a" modbustype="U_AB" haltype="HAL_U32" function="R_REGISTERS" address="0x6041" count ="1" name="status"/>
<command device="mrje70a" modbustype="U_AB" haltype="HAL_U32" function="R_REGISTERS" address="0x6040" count ="1" name="rcontrolword"/>
<command device="mrje70a" modbustype="S_AB" haltype="HAL_S32" function="R_REGISTERS" address="0x6061" count ="1" name="mode"/>
<command device="mrje70a" modbustype="U_AB" haltype="HAL_U32" function="R_REGISTERS" address="0x2d60" count ="1" name="rtargetpt"/>
<command device="mrje70a" modbustype="U_AB" haltype="HAL_U32" function="R_REGISTERS" address="0x6099" count ="5" name="homingspeed"/>
<command device="mrje70a" function="W_REGISTERS" modbustype="U_AB" haltype="HAL_U32" address="0x6040" count="1" name="ctrlwordwt" resend="1"/>
<command device="mrje70a" function="W_REGISTERS" modbustype="S_AB" haltype="HAL_S32" address="0x6060" count="1" name="wopermode" resend="1"/>
<command device="mrje70a" function="W_REGISTERS" modbustype="U_AB" haltype="HAL_U32" address="0x2d60" count="1" name="wtargetpt" resend="1"/>
<command device="mrje70a" function="W_REGISTERS" address="0x6099" >
<pin name= "hnumentries" modbustype="U_ABCD" haltype="HAL_U32" resend="1"/>
</command>
</commands>
</mesamodbus>
as you see when i m using W_REGISTERS white registers 2 bytes (U_AB) it s work but i dont know how to us it with registers have 4 bytes or more
<?xml version="1.0" encoding="UTF-8"?>
<mesamodbus baudrate="115200" parity="E" stopbits="1">
<devices>
<device address="0x02" name="mrje70a"/>
</devices>
<initlist>
</initlist>
<commands>
<command device="mrje70a" modbustype="U_AB" haltype="HAL_U32" function="R_REGISTERS" address="0x2b01" count ="2" name="cfp"/>
<command device="mrje70a" modbustype="U_AB" haltype="HAL_U32" function="R_REGISTERS" address="0x2b0f" count ="1" name="volt"/>
<command device="mrje70a" modbustype="U_AB" haltype="HAL_U32" function="R_REGISTERS" address="0x2b2d" count ="1" name="power"/>
<command device="mrje70a" modbustype="U_AB" haltype="HAL_U32" function="R_REGISTERS" address="0x2001" count ="2" name="rpa01"/>
<command device="mrje70a" function="R_REGISTERS" address="0x2801">
<pin name = "numbreent" modbustype="U_AB" haltype="HAL_U32"/>
<pin name = "position" modbustype="U_CDAB" haltype="HAL_U32" scale ="0"/>
<pin name = "speed" modbustype="U_AB" haltype="HAL_U32"/>
<pin name = "acce" modbustype="U_AB" haltype="HAL_U32"/>
<pin name = "dec" modbustype="U_AB" haltype="HAL_U32"/>
<pin name="dwell" modbustype="U_AB" haltype="HAL_U32"/>
<pin name="subfunc" modbustype="U_AB" haltype="HAL_U32"/>
<pin name="mcode" modbustype="U_AB" haltype="HAL_U32"/>
</command>
<command device="mrje70a" modbustype="U_AB" haltype="HAL_U32" function="R_REGISTERS" address="0x1010" count ="11" name="eeprom"/>
<command device="mrje70a" modbustype="U_AB" haltype="HAL_U32" function="R_REGISTERS" address="0x2c12" count ="9" name="input"/>
<command device="mrje70a" modbustype="U_AB" haltype="HAL_U32" function="R_REGISTERS" address="0x6041" count ="1" name="status"/>
<command device="mrje70a" modbustype="U_AB" haltype="HAL_U32" function="R_REGISTERS" address="0x6040" count ="1" name="rcontrolword"/>
<command device="mrje70a" modbustype="S_AB" haltype="HAL_S32" function="R_REGISTERS" address="0x6061" count ="1" name="mode"/>
<command device="mrje70a" modbustype="U_AB" haltype="HAL_U32" function="R_REGISTERS" address="0x2d60" count ="1" name="rtargetpt"/>
<command device="mrje70a" modbustype="U_AB" haltype="HAL_U32" function="R_REGISTERS" address="0x6099" count ="5" name="homingspeed"/>
<command device="mrje70a" function="W_REGISTERS" modbustype="U_AB" haltype="HAL_U32" address="0x6040" count="1" name="ctrlwordwt" resend="1"/>
<command device="mrje70a" function="W_REGISTERS" modbustype="S_AB" haltype="HAL_S32" address="0x6060" count="1" name="wopermode" resend="1"/>
<command device="mrje70a" function="W_REGISTERS" modbustype="U_AB" haltype="HAL_U32" address="0x2d60" count="1" name="wtargetpt" resend="1"/>
<command device="mrje70a" function="W_REGISTERS" address="0x6099" >
<pin name= "hnumentries" modbustype="U_ABCD" haltype="HAL_U32" resend="1"/>
</command>
</commands>
</mesamodbus>
as you see when i m using W_REGISTERS white registers 2 bytes (U_AB) it s work but i dont know how to us it with registers have 4 bytes or more
Please Log in or Create an account to join the conversation.
- PCW
-
- Online
- Moderator
-
Less
More
- Posts: 18784
- Thank you received: 5190
28 Jun 2025 19:33 #330970
by PCW
Replied by PCW on topic How to write multipule data ( byte) mesambccc
This is different from your first example:
<command device="mrje70a" function="W_REGISTERS" address="0x6099" >
<pin name= "hnumentries" modbustype="U_ABCD" haltype="HAL_U32" resend="1"/>
Do you have the same error?
Have you tried setting hm2_modbus's debug value to get a more detailed error?
<command device="mrje70a" function="W_REGISTERS" address="0x6099" >
<pin name= "hnumentries" modbustype="U_ABCD" haltype="HAL_U32" resend="1"/>
Do you have the same error?
Have you tried setting hm2_modbus's debug value to get a more detailed error?
Please Log in or Create an account to join the conversation.
- AdelRTP
- Away
- New Member
-
Less
More
- Posts: 17
- Thank you received: 2
28 Jun 2025 19:40 #330972
by AdelRTP
Replied by AdelRTP on topic How to write multipule data ( byte) mesambccc
Yes the second work perfect but when i want to add W_REGISTERS more then 2 byte i get hm2_modbus.0: error: Build data frame failed in write_flush for command 15, disabling
<command device="mrje70a" function="W_REGISTERS" address="0x2801">
<description>Write Point Table Data</description>
<pin name="wnumentries" modbustype="U_AB" haltype="HAL_U32"/>
<pin name="wposition" modbustype="U_CDAB" haltype="HAL_U32"/>
<pin name="wspeed" modbustype="U_AB" haltype="HAL_U32"/>
<pin name="wacceleration" modbustype="U_AB" haltype="HAL_U32"/>
<pin name="wdeceleration" modbustype="U_AB" haltype="HAL_U32"/>
<pin name="wdwell" modbustype="U_AB" haltype="HAL_U32"/>
<pin name="wsubfunction" modbustype="U_AB" haltype="HAL_U32"/>
<pin name="wmcode" modbustype="U_AB" haltype="HAL_U32"/>
</command>
Idont know how to use debug
<command device="mrje70a" function="W_REGISTERS" address="0x2801">
<description>Write Point Table Data</description>
<pin name="wnumentries" modbustype="U_AB" haltype="HAL_U32"/>
<pin name="wposition" modbustype="U_CDAB" haltype="HAL_U32"/>
<pin name="wspeed" modbustype="U_AB" haltype="HAL_U32"/>
<pin name="wacceleration" modbustype="U_AB" haltype="HAL_U32"/>
<pin name="wdeceleration" modbustype="U_AB" haltype="HAL_U32"/>
<pin name="wdwell" modbustype="U_AB" haltype="HAL_U32"/>
<pin name="wsubfunction" modbustype="U_AB" haltype="HAL_U32"/>
<pin name="wmcode" modbustype="U_AB" haltype="HAL_U32"/>
</command>
Idont know how to use debug
Please Log in or Create an account to join the conversation.
- PCW
-
- Online
- Moderator
-
Less
More
- Posts: 18784
- Thank you received: 5190
28 Jun 2025 20:20 #330973
by PCW
Replied by PCW on topic How to write multipule data ( byte) mesambccc
debug is described in the hm2_modbus manual page.
Please Log in or Create an account to join the conversation.
Time to create page: 0.141 seconds