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

Half reading 32 bit register #2

Closed
sandroxGH opened this issue Jul 25, 2020 · 2 comments
Closed

Half reading 32 bit register #2

sandroxGH opened this issue Jul 25, 2020 · 2 comments

Comments

@sandroxGH
Copy link

The current power and energy have 32 bit register with "nodeX.getResponseBuffer(0xXX)" can read only 16 bit is correct?
I think it looking the energy counter some time restart from 0 after have count 66.

@Renato-REDS
Copy link

Renato-REDS commented Jul 27, 2020

Olá @sandroxGH,

você está certo, eu também tive o mesmo problema.
Para você ter a leitura completa dos valores de potência, energia e corrente em 16 bits, troque as linhas:

current_usage_1 = (node2.getResponseBuffer(0x01) / 1000.000f);
active_power_1 = (node2.getResponseBuffer(0x03) / 10.0f);
active_energy_1 = (node2.getResponseBuffer(0x05) / 1000.0);

para:
current_usage_2 = (node2.getResponseBuffer(0x01) | (node1.getResponseBuffer(0x02)) << 16) / 1000.000f;
active_power_2 = (node2.getResponseBuffer(0x03) | (node1.getResponseBuffer(0x04)) << 16) / 10.0f;
active_energy_2 = (node2.getResponseBuffer(0x05) | (node1.getResponseBuffer(0x06)) << 16) / 1000.0f;

assim quando os valores forem maiores, você irá conseguir ler sem problema. (sem o falso 0).

Espero ter ajudado.

@sandroxGH
Copy link
Author

sandroxGH commented Jul 28, 2020 via email

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

2 participants