MB2HAL float to binary conversion
22 Dec 2023 18:04 - 22 Dec 2023 18:07 #288829
by Sandro
MB2HAL float to binary conversion was created by Sandro
Hi everyone,
I'm currently working on integrating Modbus RTU into my milling machine setup, using Chinese AASD-Servos that support the protocol. So far, I've successfully read float values, such as spindle load, from the servos using mb2hal. However, I'm facing a challenge when it comes to reading the status of output pins on address 386 from the motor.
The motor provides the status of various output pins, which I currently read using MB2HAL with "MB_TX_CODE=fnct_03_read_holding_registers," returning a float value. However, I need this data in binary format to analyze each bit individually, as these bits indicate crucial information like motor readiness or alarms.
I refer to the servo manual, where, for instance, if the motor is online but not turning, I receive the float value 14900. I need to convert this to the binary value "11101001010100," where the first bit '1' indicates no alarm.
My question is whether there's a HAL component like CONV_S32_BIT that I can use for this purpose or if there's a simpler way to read bitwise information using MB2HAL.
Any help or guidance on this matter would be greatly appreciated. Thank you!
I'm currently working on integrating Modbus RTU into my milling machine setup, using Chinese AASD-Servos that support the protocol. So far, I've successfully read float values, such as spindle load, from the servos using mb2hal. However, I'm facing a challenge when it comes to reading the status of output pins on address 386 from the motor.
The motor provides the status of various output pins, which I currently read using MB2HAL with "MB_TX_CODE=fnct_03_read_holding_registers," returning a float value. However, I need this data in binary format to analyze each bit individually, as these bits indicate crucial information like motor readiness or alarms.
I refer to the servo manual, where, for instance, if the motor is online but not turning, I receive the float value 14900. I need to convert this to the binary value "11101001010100," where the first bit '1' indicates no alarm.
My question is whether there's a HAL component like CONV_S32_BIT that I can use for this purpose or if there's a simpler way to read bitwise information using MB2HAL.
Any help or guidance on this matter would be greatly appreciated. Thank you!
Last edit: 22 Dec 2023 18:07 by Sandro.
The following user(s) said Thank You: besriworld
Please Log in or Create an account to join the conversation.
23 Dec 2023 07:20 #288866
by roland
Replied by roland on topic MB2HAL float to binary conversion
The following user(s) said Thank You: Leo90
Please Log in or Create an account to join the conversation.
23 Dec 2023 15:33 #288919
by Sandro
Replied by Sandro on topic MB2HAL float to binary conversion
Attachments:
Please Log in or Create an account to join the conversation.
19 Aug 2024 20:33 #308166
by Leo90
Replied by Leo90 on topic MB2HAL float to binary conversion
Hi Sandro!
Can you please post an example of this hal?
Can you please post an example of this hal?
Please Log in or Create an account to join the conversation.
24 Aug 2024 14:34 #308538
by Sandro
Replied by Sandro on topic MB2HAL float to binary conversion
Hello Leo
It has been a while and I've opted out of modbus and using ethercat now. This is the last backup I have found. Does this help you?
It has been a while and I've opted out of modbus and using ethercat now. This is the last backup I have found. Does this help you?
The following user(s) said Thank You: besriworld
Please Log in or Create an account to join the conversation.
Time to create page: 0.102 seconds