raman00084
Full Member level 6
What is L M H in the attached modbus screen short.
How to compute the value
How to compute the value
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Can you please help me how to compute the 3 bytes of data to convert into 24 bit valueHi,
3 bytes of a 24 bit value.
L = low byte
M = mid byte
H = high byte
Klaus
Yes, you could, but the result would be wrong.You can calculate using the following formula: H * 0x1000 + M * 0x100 + L
I mean bitwise it is:
* H-Byte: HHHHHHHH
* M-Byte: MMMMMMMM
* L-Byte: LLLLLLLL
so in total: HHHHHHHHMMMMMMMMLLLLLLLL
Code C - [expand] 1 encoderval = reg_read(0x4202) + (uint32)(reg_read(0x4203) & 0xff) << 16;
The documentation states that H M L are bytes (0-255), so my formula will work without any problem with these conditions.Yes, you could, but the result would be wrong.
****
I did not expect the OP (as a long term member) to ask this basic question.
It has been discussed with formulae, with mathematics, with code examples for decades and many million times. ... in basic coding documents.
Thus I´m not sure what to answer.
Code:I mean bitwise it is: * H-Byte: HHHHHHHH * M-Byte: MMMMMMMM * L-Byte: LLLLLLLL so in total: HHHHHHHHMMMMMMMMLLLLLLLL
Klaus
You have a typo.The documentation states that H M L are bytes (0-255), so my formula will work without any problem with these conditions.
I don´t think so:The documentation states that H M L are bytes (0-255), so my formula will work without any problem with these conditions.
LLLLLLLL = 0000000000000000LLLLLLLL
MMMMMMMM x 0x0100 = 00000000MMMMMMMM00000000
HHHHHHHH x 0x1000 = 0000HHHHHHHH000000000000
========================
Added: = 000?????????MMMMLLLLLLLL