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

Is Peukert decoding right ? #403

Closed
ieb opened this issue May 7, 2023 · 2 comments
Closed

Is Peukert decoding right ? #403

ieb opened this issue May 7, 2023 · 2 comments

Comments

@ieb
Copy link

ieb commented May 7, 2023

.offset = 500, // = 1 / resolution

Take Peukert 1.25 (typical lead acid)

As per https://canboat.github.io/canboat/canboat.html
Range is 1 - 1.506
1 bit = 0.002
Offset = 500

1.25/0.002 = 625
625-500 = 125 = 0x7D

analyse produces

2023-05-07-09:12:54.231 6 26 255 127513 Battery Configuration Status: Instance = 1; Battery Type = AGM; Supports Equalization = No; Reserved = 00; Nominal Voltage = 12V; Chemistry = Pb (Lead); Capacity = 0 Ah; Temperature Coefficient = 5 %; Peukert Exponent = 0.250; Charge Efficiency Factor = 95 %

I dont think its a signed int vs unsigned int thing.

1.45/0.002 = 725
725-500 = 225 = 0xE1

2023-05-07-09:17:57.662 6 26 255 127513 Battery Configuration Status: Instance = 1; Battery Type = AGM; Supports Equalization = No; Reserved = 00; Nominal Voltage = 12V; Chemistry = Pb (Lead); Capacity = 0 Ah; Temperature Coefficient = 5 %; Peukert Exponent = 0.450; Charge Efficiency Factor = 95 %

What's the right way to encode Peukert ? Or is this a bug in the decoding ?
I tried to find out where it might be in decoding, but could not see, the offset seems to be mentioned, and I assume it is applied, but perhaps not ?

0xE1 = 225
225*0.002 = 0.45 which matches the output seen.

There must be an offset because Peukert only goes from 1 - 1.506, and 1/0.002 = 500 which is > uint8_t ?

@keesverruijt keesverruijt changed the title Is Puerket decoding right ? Is Peukert decoding right ? Jun 10, 2023
@keesverruijt
Copy link
Collaborator

keesverruijt commented Jun 10, 2023

Hi, I haven't analysed this fully, but I have changed your 'Puekret' to 'Peukert' (the poor fellow deserves his name written right, at least I think?) (See https://en.wikipedia.org/wiki/Peukert%27s_law )

(Funnily enough, my editor also 'corrected' me in auto-correcting Peukert to something else...)

@keesverruijt
Copy link
Collaborator

Yup, it was a mistake in the decoder. Fix on master and in upcoming 4.13 release.

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