• 0 Votes - 0 Average
• 1
• 2
• 3
• 4
• 5
 eX-Robot. New Ideas and Solutions for Self Balancing Robot
06-12-2015, 12:30 PM
Post: #3
 KomX Member Posts: 98 Joined: Jun 2015 Reputation: 1
RE: eX-Robot. New Ideas and Solutions for Self Balancing Robot
Hi!
Under our future ideas need free memory and time for their execution.
Now we will unleash 16 bytes of memory and a 100 microsecond time.
So, we will upgrade the original procedure for measuring the battery voltage. The modernization will improve measurement accuracy and free up 16 bytes of memory and a 100 microsecond time.
The original code (not the library version of the code):
Code:
#define BATT_VOLT_FACTOR 8

boolean first_time = true;

{
if (first_time)
else
battery = (battery*9 + (analogRead(5)/BATT_VOLT_FACTOR))/10;
return battery;
}

Replace a new code:
Code:
uint16_t   tbattery = 0;

int readBattery() // c
{
battery = (battery*9 + (tbattery/BATT_VOLT_FACTOR))/10; //
ADMUX = (1<<REFS0) | (1<<REFS1);                       // Vref = 2.56В, for A5 (ADC0) all MUX5..0=0
return battery;
}

{
}

NOTE: In the original code BATT_VOLT_FACTOR = 8 selected for maximum battery voltage (Vin) equal to 12.5 volts and a voltage reference source Vref = 5 volt. Using a resistive divider R3(33K) end R5(22K).
The new code uses a built-in stabilized power supply with Vref = 2.56V. This limits the voltage at pin A5 and require different resistors R3, R5 and constant BATT_VOLT_FACTOR.

Question developers:
How to solve the problem of monitoring the battery on the board Pro Micro? In it there is no pin A5!
 « Next Oldest | Next Newest »

 Messages In This Thread eX-Robot. New Ideas and Solutions for Self Balancing Robot - KomX - 06-11-2015, 10:53 AM RE: eX-Robot. New Ideas and Solutions for Self Balancing Robot - KomX - 06-11-2015, 07:34 PM RE: eX-Robot. New Ideas and Solutions for Self Balancing Robot - sasa999 - 06-12-2015, 05:17 PM RE: eX-Robot. New Ideas and Solutions for Self Balancing Robot - KomX - 06-12-2015 12:30 PM RE: eX-Robot. New Ideas and Solutions for Self Balancing Robot - KomX - 06-12-2015, 05:32 PM RE: eX-Robot. New Ideas and Solutions for Self Balancing Robot - KomX - 06-16-2015, 09:51 AM RE: eX-Robot. New Ideas and Solutions for Self Balancing Robot - Wampo - 10-14-2015, 10:54 AM RE: eX-Robot. New Ideas and Solutions for Self Balancing Robot - KomX - 10-14-2015, 12:21 PM RE: eX-Robot. New Ideas and Solutions for Self Balancing Robot - vlelectronic - 10-14-2015, 07:19 PM RE: eX-Robot. New Ideas and Solutions for Self Balancing Robot - KomX - 10-14-2015, 08:14 PM

Forum Jump:

User(s) browsing this thread: 1 Guest(s)