Battery voltage(Battery)
method
Battery_init()
Initialized battery voltage measurement library
Get_Battery_Volotage(void)
Note: The power supply voltage output range of the Yahboom Self-balancing Robot is roughly between 8.5~12.5v
Get the actual battery voltage before voltage
The actual measurement value is a little lower than the value calculated
| Return value | type |
|---|---|
| Original voltage value | float |
Battery_Get(uint8_t ch)
Get ADC measurement value
| parameter | type | Annotation |
|---|---|---|
| ch | uint8_t | ADC channel |
| Return value | type |
|---|---|
| Get the ADC value | uint16_t |
Battery_Get_Average(uint8_t ch, uint8_t times)
Obtain ADC multiple measurement average
| parameter | type | Annotation |
|---|---|---|
| ch | uint8_t | ADC channel |
| times | uint8_t | Measurement times |
| Return value | type |
|---|---|
| Get the ADC value | uint16_t |
Get_Measure_Volotage(void)
Get the original voltage value
| Return value | type |
|---|---|
| Original voltage value | float |
Example
#include <bsp_battery.h>
int main()
{
Battery_init();
while(1){
// Get the current power supply voltage
float v = Get_Battery_Volotage();
}
}