|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Battery Voltage variable on EDU controller
I am trying to use the battery_voltage variable in user_routines.c but I get this error when trying to compile..
Error [1205] unknown member 'rc_analog01' in '__tag_167' Am I missing something? EDIT After looking at 'ifi_default.h' i found this block of code.. Code:
unsigned char oi_analog01, oi_analog02, oi_analog03, oi_analog04; /*rxdata.oi_analog01*/ unsigned char oi_analog05, oi_analog06, oi_analog07, oi_analog08; unsigned char oi_analog09, oi_analog10, oi_analog11, oi_analog12; unsigned char oi_analog13, oi_analog14, oi_analog15, oi_analog16; unsigned char rc_main_batt, rc_backup_batt; If found that if you took rxdata.rc_main_batt and applied the formula "current voltage = battery_voltage * 0.038 + 0.05; " found at the bottom of 'ifi_aliases.h' you get a value of 650.. im running the the controller off a wall adapter putting out 6 volts to i think this is pretty acurate. Here is the code if anyone is interested.. Code:
float current_voltage = 0;
float average_voltage = 0;
int voltage_count = 0;
int i = 0;
int i2 = 0;
void Process_Data_From_Master_uP(void)
{
Getdata(&rxdata); /* Get fresh data from the master microprocessor. */
current_voltage = rxdata.rc_main_batt; // Store current voltage
average_voltage += current_voltage; // Add the current voltage to the average stack
voltage_count++; // Increase the average stack count
if (voltage_count == 39) // If the stack is 40
{
average_voltage = (average_voltage / 40) * 0.038 + 0.05; // Get the average and apply formula
i = (int)average_voltage; // Truncate decimals
i2 = (int) ((average_voltage - i) * 1000); // Subtract to get decimals only and then multiply by 1000
printf("Average: %d.%03d \n",i,i2); // Print the two together to make it look like a decimal
average_voltage = 0; // Reset the stack
voltage_count = 0; // Rest the counter
}
Putdata(&txdata); /* DO NOT CHANGE! */
}
EDIT I just tried using current_voltage = rxdata.oi_analog01; and i get averages of 4.7 so im not sure what to think now.. can anyone clarify as to what one it is and why i get an error when i try to use the 'battery_voltage' aliase... also i just realized that the battery_voltage aliase points to 'rxdata.rc_analog01' which i cant seem to even find anywhere.. Last edited by bear24rw : 02-07-2006 at 19:38. |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| The 8.2 (or 8.3) Battery Voltage Bug | eugenebrooks | Programming | 167 | 21-02-2008 20:05 |
| Reading battery voltage in software | RbtGal1351 | Programming | 17 | 21-10-2007 13:07 |
| battery voltage compensation | Rickertsen2 | Programming | 5 | 17-10-2005 22:12 |
| Battery voltage | Josh Siegel | Programming | 5 | 22-12-2003 10:15 |
| Battery Voltage | Neal Probert | Programming | 3 | 09-01-2003 10:18 |