Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading 32 bits number from two registers #177

Open
Fluxanode opened this issue Aug 18, 2022 · 5 comments
Open

Reading 32 bits number from two registers #177

Fluxanode opened this issue Aug 18, 2022 · 5 comments

Comments

@Fluxanode
Copy link

Fluxanode commented Aug 18, 2022

I need to get a single value from a holding or input reg that is in two reg addresses.
I want to read 8006 (8007) as the date then read 8006 (time) to store in two separate vars.

Floating Point (FP) 4bytes 2 registers

Holding Reg
REG DES Datatype
8006 Real-Date FP
8008 Real-Time FP

Can you give me an example how this is coded using your lib?

@fuzonmedia
Copy link

@Fluxanode
Do you able to solve this ? I need to know the same

@Fluxanode
Copy link
Author

I have not been working on this lately and never received an answer. Sorry. It would be nice if someone bothered to answer...

@phaelbotelho
Copy link

phaelbotelho commented Nov 28, 2022

So, this it's not a issue to be solved, but follow the solution. This is not a resource of the library, Is just C ways to access memory.
Take the value from the reception buffer variable and write in a multiple type variable. You can just copy the value to a variable able to read as 2 ways. Like the code below:
union floatto16bits{ float value_32; uint16_t value_16[2]; };
or
union uint32_tto16bits{ uint32_t value_32; uint16_t value_16[2]; };
This type of variable, alloc the same size of memory and allow you to read as you need.

When write the two 16 bis value use this name:
Uint32_tto16bits.value_16[0]
Uint32_tto16bits.value_16[1]

When read as a 32 type use this:
Uint32_tto16bits.value_32

@mftadvantage
Copy link

Olá alguem pode me ajudar, estou tentando ler dados de um medidor e recebo o padrão (IEEE 32-bit floating point). Não consigo de maneira alguma converter esse padrão em decimal. no exemplo do fabricante ele fala que 0x00007042 (IEEE 32-bit floating point) é = 60 em decimal. Mas não consigo entender nem criar um programa que faça essa conversão.

@fuzonmedia
Copy link

@mftadvantage Email me your issue [email protected] I can help out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants