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

Voltage is reported in milivolts instead of Volts #1

Open
g0nz4I0 opened this issue Dec 2, 2024 · 1 comment
Open

Voltage is reported in milivolts instead of Volts #1

g0nz4I0 opened this issue Dec 2, 2024 · 1 comment

Comments

@g0nz4I0
Copy link
Member

g0nz4I0 commented Dec 2, 2024

The module reports voltage in 100mV increments, so 1 inc = 100 mV, not one volt.
I dont think throught the decoding this is updated.

            case CMS::ProtocolNumber::ModuleStateResponse:
                module_state = {
                    .general_state{static_cast<CMS::GeneralModuleState>(
                        (static_cast<uint16_t>(packet.data[1]) << 8) |
                        packet.data[0])},
                    .module_voltage{static_cast<CMS::ModuleVoltage>(
                        (static_cast<uint16_t>(packet.data[3]) << 8) |
                        packet.data[2])}
@g0nz4I0
Copy link
Member Author

g0nz4I0 commented Dec 2, 2024

I suggest the following:

static float get_total_voltage() {
        using BCU::Communication::ModuleCAN;

        return (ModuleCAN::strings[1].modules[1].module_voltage +
               ModuleCAN::strings[1].modules[2].module_voltage +
               ModuleCAN::strings[1].modules[3].module_voltage) * 0.1; // the * 0.1 to return volts and not milivolts
    }

@g0nz4I0 g0nz4I0 changed the title Voltage is reported wrongly Voltage is reported in milivolts instead of Volts Dec 2, 2024
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

1 participant