Modbus, send REAL data
-
Hi,
I have some real values to send via modbus from Mervis.
Since REAL take 4 bytes, REAL should take two registers.
How can I combine the two registers values to make one real value in C program ?regards.
-
I find it!
Modbus data order: 1234.
Example:
In C program header:typedef unsigned long DWORD; typedef unsigned short WORD; union u_DWORD_TO_FLOAT{ DWORD i; float f; };and in the code:
union u_DWORD_TO_FLOAT AI01; ... AI01.i = (mb_mapping->tab_registers[20] << 16) + mb_mapping->tab_registers[21]; float value = AI01.f;Hope this help someone !
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login