Go to Post No matter what you do and how well you try to protect them, some people are just out there to be candidates for the Darwin Awards! - Jay H 237 [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-07-2006, 15:45
bear24rw's Avatar
bear24rw bear24rw is offline
Team 11 Programming Captain
AKA: Max T
FRC #0011 (MORT)
Team Role: Programmer
 
Join Date: Sep 2005
Rookie Year: 2005
Location: Flanders, NJ
Posts: 385
bear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to behold
Send a message via AIM to bear24rw
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;
So i decided to try rc_main_batt and 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! */
}
Thanks to Mark McLeod for example on how to printf floats...

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.
  #2   Spotlight this post!  
Unread 02-07-2006, 20:14
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Battery Voltage variable on EDU controller

Are you using the EDU header files? For those two fields (rc_*_batt), I have "res01" and "res02".

In ifi_aliases.h (EDU version), it has this macro:
Code:
/*
 *-------------------------------------------------------------------------------
 *---------- Alias for Battery Voltage  -----------------------------------------
 *-------------------------------------------------------------------------------
 * current voltage = battery_voltage * 0.038 + 0.05; 
 */
#define battery_voltage rxdata.rc_analog01
Also, I'm pretty sure the formula is known to be inaccurate.
  #3   Spotlight this post!  
Unread 02-07-2006, 23:05
bear24rw's Avatar
bear24rw bear24rw is offline
Team 11 Programming Captain
AKA: Max T
FRC #0011 (MORT)
Team Role: Programmer
 
Join Date: Sep 2005
Rookie Year: 2005
Location: Flanders, NJ
Posts: 385
bear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to behold
Send a message via AIM to bear24rw
Re: Battery Voltage variable on EDU controller

Yeah im sure im using the right header files... i got it off the ifi website three days ago from this URL http://www.ifirobotics.com/mini-rc-read-me.shtml
Has there been an update or something?
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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


All times are GMT -5. The time now is 23:04.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi