View Single Post
  #22   Spotlight this post!  
Unread 12-10-2007, 22:21
RyanN's Avatar
RyanN RyanN is offline
RyanN
AKA: Ryan Nazaretian
no team
Team Role: Mentor
 
Join Date: Jun 2006
Rookie Year: 2005
Location: Austin, TX
Posts: 1,127
RyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond repute
Re: Project Questions about Programming and Electrical

Quote:
Originally Posted by Phalanx View Post
Look in ifi_aliases.h, You will find the variables for the battery.
I hope this helps.

/*
*-----------------------------------------------------------------------------------------------------
*---------- Aliases for Battery Voltage bytes --------------------------------------------------------
*-----------------------------------------------------------------------------------------------------
* Formula to calculate voltage in volts:
* current_voltage = battery_voltage * 0.038 + 0.05;
*/

#define battery_voltage rxdata.rc_main_batt*15.64/256
#define backup_voltage rxdata.rc_backup_batt*15.64/256
I've gotten to the part of programming where I'm trying to get my charger working, but obviously there is something wrong with the code.
User_routines_fast.c
Code:
/*** DEFINE USER VARIABLES AND INITIALIZE THEM HERE ***/
int powerrelay;
int tempb;
int tempc;
int tempd;
int pwrofftmout;
int powerout;
int poweroutb;
int volts;
(Skip a lot of the stuff that doesn't matter in this post)
printf("volts %d\n","battery_voltage %d\n");
volts = battery_voltage*0.038+0.05; /*Should give the correct voltage*/
With my novice programming skills, all this seems good to me, however, when using the printf command (which I'm not sure I'm using it correctly) it says "volts 15865" meaning that it has no value for volts and when I manually convert: 15865*0.038+0.05 = 602.92V which is obviously not correct. Any help is greatly appreciated.

Also, the value 15865 does not change at all. It is constant when I disconnect the charger or when I put a load on the battery, which indicates something else is not working properly.
__________________
Taking a break from mentoring for a few years. (Is that allowed?!?)

Controls Mentor
@rnazaretian

Previous teams:
Team Fusion, FRC 364
Garnet Squadron, FRC 4901

Last edited by RyanN : 12-10-2007 at 22:23.