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

Seems like voltage isn't working properly #25

Closed
arvet333 opened this issue Nov 1, 2023 · 9 comments
Closed

Seems like voltage isn't working properly #25

arvet333 opened this issue Nov 1, 2023 · 9 comments

Comments

@arvet333
Copy link

arvet333 commented Nov 1, 2023

VBAT voltage isnt changing.

Here is detailed video of testing: https://youtu.be/y0L-hrXLQsw

@rizacelik
Copy link
Owner

You cannot measure voltage and current directly. For this, you must use a Current Sensor ACS712. When you connect a 2S or 3S battery directly to the pin, the Board lights up.
Using ACS712 sensor with Arduino: https://www.youtube.com/watch?v=1S7vQubTgQg

@arvet333
Copy link
Author

arvet333 commented Nov 2, 2023

How we can measure voltage with current sensor?

For measuring current:
Use Current Sensor ACS712. Connect ACS712 OUT pin to FC B1 pin.

For measuring voltage:
Use voltage divider scheme with resistors. Maximum battery voltage after dividing should be below 5v. Connect battery plus (after dividing, max 5v) to B0 pin on FC. Battery GND to FC GND.

Am I right?

In my case there is 1S battery, so it is below 5v (4,2v maximum), so voltage divider is not needed, But as you can see in the video: INAV voltage indicator is stuck and not changing when real battery voltage is changing.

@rizacelik
Copy link
Owner

Yes, you are right. You can search by changing the Voltage Scale value.
image
You also need to change the battery information.
image

@arvet333
Copy link
Author

arvet333 commented Nov 2, 2023

So now I can say for sure: voltage measurement is not working.

As you can see from my video: voltage scale number is set correctly, battery information is also set correctly.

Testing algorithm:

  1. Measuring real battery voltage - 3,7v in my case
  2. Finding right scale value to get 3,7v in INAV
  3. Charging battery to 4,2v and connecting to FC
  4. INAV is still showing 3,7v instead of 4,2v

@rizacelik
Copy link
Owner

I've never tested it. If I have time, I will review this by looking at the source code. If there is a problem, we solve it together.

@rizacelik
Copy link
Owner

The code that calculates the ADC battery level is given as follows.

#ifdef USE_ADC
uint16_t getVBatSample(void) {
    // calculate battery voltage based on ADC reading

    // result is Vbatt in 0.01V steps. 3.3V = ADC Vref, 0xFFF = 12bit adc, 1100 = 11:1 voltage divider (10k:1k)

    return (uint64_t)adcGetChannel(ADC_BATTERY) * batteryMetersConfig()->voltage.scale * ADCVREF / (0xFFF * 1000);
}
#endif

Voltage Scale meaning : 1100 = 11:1 voltage divider (10k:1k)

@arvet333
Copy link
Author

arvet333 commented Nov 2, 2023

There is 3.3v figurating in this code. May be 3.3v is the maximum, not 5v. Let me do some testing with it.

@arvet333
Copy link
Author

arvet333 commented Nov 2, 2023

Yep, if the voltage is below 3.3v all is working well. I sent a PR to add this information to readme file, closing issue now.

@arvet333 arvet333 closed this as completed Nov 2, 2023
@rizacelik
Copy link
Owner

You did a good job. If everything is fine with 3.3V, the calculation will be as follows.

image

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