MB2HAL float to binary conversion

More
2 years 10 months ago - 2 years 10 months ago #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!
 
Last edit: 2 years 10 months ago by Sandro.
The following user(s) said Thank You: besriworld

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

More
2 years 10 months ago #288866 by roland
take a look at the bitslice component.
linuxcnc.org/docs/html/man/man9/bitslice.9.html
 
The following user(s) said Thank You: Leo90

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

More
2 years 10 months ago #288919 by Sandro
Thank you so much roland!

That did it! Completely missed that component.

 

Merry Christmas to ya!
 

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

More
2 years 2 months ago #308166 by Leo90
Hi Sandro!

Can you please post an example of this hal?

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

More
2 years 2 months ago #308538 by Sandro
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?
The following user(s) said Thank You: besriworld, Leo90

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

Time to create page: 0.351 seconds
Powered by Kunena Forum