MB2HAL float to binary conversion

More
22 Dec 2023 18:04 - 22 Dec 2023 18:07 #288829 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!
 
Attachments:
Last edit: 22 Dec 2023 18:07 by Sandro.

Please Log in or Create an account to join the conversation.

More
23 Dec 2023 07:20 #288866 by roland
take a look at the bitslice component.
linuxcnc.org/docs/html/man/man9/bitslice.9.html
 

Please Log in or Create an account to join the conversation.

More
23 Dec 2023 15:33 #288919 by Sandro
Thank you so much roland!

That did it! Completely missed that component.

 

Merry Christmas to ya!
 
Attachments:

Please Log in or Create an account to join the conversation.

Time to create page: 0.415 seconds
Powered by Kunena Forum