Modules
Battery voltage

Functions which handle the battery voltage. More...

Modules

 Advanced informations
 

Request Funktions

void battery_request (eRequestType request)
 Requests new data from the battery. More...
 
uint8_t battery_received (void)
 Indicates if new data for the data block sMD_SensBattery was received. More...
 
uint8_t battery_changed (void)
 Indicates if new data changed the data block sMD_SensBattery. More...
 

Access Funktions

uint16_t battery_get (void)
 Returns the last stored voltage of the battery. More...
 

Detailed Description

Functions which handle the battery voltage.

Note
The battery voltage is always monitored by the driving module of the TUC-Bot. The discharge-protection has four level:
0 full >6,9V LED off
1 soon empty 6,4V...6,9V LED is toggled
2 empty <6,4V LED on; motors off
3 deep-discharge <6V Robot is protected by a hardware circuit.
Please turn off the robot and charge battery as soon as possible!
If robot is in level 2 (led on; motors stopped), it is not going back to level 1 or 0. But you may turn the robot off and on again.

example

/*******************************************************************************
* examples/battery.c *
* ================== *
* *
* Version: 1.0.6 *
* Date : 01.11.17 *
* Author : Peter Weissig *
* *
* If you are changing this file, you may also consider to update *
* demos/diagnosticTool/diagnosticTool.c *
*******************************************************************************/
//*********************************<Included files>*****************************
#include <tucbot/tucbot.h>
//*********************************<Methods>************************************
void testBattery(void);
int main(void);
//*********************************[testBattery]********************************
void testBattery(void) {
lcdclr();
lcdstr_p(PSTR("Battery" ));
lcdxy(0,1);
lcdstr_p(PSTR("Voltage:##### mV"));
while (1) {
if (battery_changed()) {
lcdxy(8,1);
mdelay(250);
}
}
}
//*********************************[main]***************************************
int main (void) {
init_tucbot(0xFF);
testBattery();
return (0);
}

Function Documentation

◆ battery_changed()

uint8_t battery_changed ( void  )

Indicates if new data changed the data block sMD_SensBattery.

The return value is boolean.

Returns
8-bit unsigned integer which is a boolean value
See also
battery_received(), battery_request() and battery_get()
Examples
battery.c.

◆ battery_get()

uint16_t battery_get ( void  )

Returns the last stored voltage of the battery.

This function relies on the internal data block sMD_SensBattery - for new data use battery_request().

Returns
16-bit unsigned integer (0..1023)
The battery voltage is measured in 10 millivolts units. E.g. a value of 675 relates to 6.75 V.
See also
battery_request(), battery_received() and battery_changed()
Examples
battery.c.

◆ battery_received()

uint8_t battery_received ( void  )

Indicates if new data for the data block sMD_SensBattery was received.

The return value is boolean.

Returns
8-bit unsigned integer which is a boolean value
See also
battery_changed(), battery_request() and battery_get()

◆ battery_request()

void battery_request ( eRequestType  request)

Requests new data from the battery.

For details on the request schema see The general request.

Involved data blocks are:
sMD_SensBattery

Parameters
requestSee also eRequestType
See also
battery_get(), battery_received() and battery_changed()
Examples
battery.c.
battery_get
uint16_t battery_get(void)
Returns the last stored voltage of the battery.
int16tostr
void int16tostr(void *out, int16_t number, uint8_t digits)
Converts an integer to a string and passes it to an output function.
kRequestContinuous
@ kRequestContinuous
constant (3): request continuous updates
Definition: update.h:37
battery_changed
uint8_t battery_changed(void)
Indicates if new data changed the data block sMD_SensBattery.
battery_request
void battery_request(eRequestType request)
Requests new data from the battery.
lcdclr
void lcdclr(void)
Clears the display.
lcdxy
void lcdxy(uint8_t x, uint8_t y)
Moves the cursor to a postion on the display.
lcdstr_p
void lcdstr_p(const char *send_data)
Writes a string located in the flash to the display.
lcdout
void lcdout(uint8_t data)
Writes one byte to the display.
init_tucbot
void init_tucbot(uint8_t enable_interrupts)
Initiates the TUC-Bot.
mdelay
void mdelay(uint16_t mseconds)
Waits for the given time in milliseconds.