|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: Project Questions about Programming and Electrical
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 |
|
#2
|
||||
|
||||
|
Re: Project Questions about Programming and Electrical
Quote:
Also, I'm going to add something. I think for the charger, I might have a manual override so I can force it to charge while off (like just a small switch in the back) |
|
#3
|
|||||
|
|||||
|
Re: Project Questions about Programming and Electrical
You could pretty easily use the CCP ports represented by PWMs 13-16 to output single frequency tones. You'd set it up to output a square wave at the particular frequency you want. You'd have to filter it fairly heavily if you wanted a pure tone, of course. Square waves have harmonics at odd multiples of the fundamental frequency, so if it were me, I'd pick what your high frequency is, make yourself something like a 4th or 6th order low pass filter with a corner frequency at that highest frequency. Then you can put out frequencies down to about 1/2 that highest frequency and still have a pretty pure tone. You'd need to make up a separate amp to drive your speaker, and you'd want it to filter out the DC offset inherent in that initial PWM-style square wave and you'd probably need to create a virtual ground split between your 0V and 12V and various other things as well, of course.
|
|
#4
|
||||
|
||||
|
Re: Project Questions about Programming and Electrical
Quote:
|
|
#5
|
||||
|
||||
|
Re: Project Questions about Programming and Electrical
Quote:
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*/
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. Last edited by RyanN : 12-10-2007 at 22:23. |
|
#6
|
||||
|
||||
|
Re: Project Questions about Programming and Electrical
Quote:
Code:
printf("volts %d\n","battery_voltage %d\n",volts_variable, battery_voltage_variable);
|
|
#7
|
||||
|
||||
|
Re: Project Questions about Programming and Electrical
Quote:
Code:
printf("volts %d\n","battery_voltage %d\n",volts_variable,battery_voltage_variable);
Code:
C:\FrcCode2005v2.2\user_routines_fast.c:168:Error [1105] symbol 'volts_variable' has not been defined C:\FrcCode2005v2.2\user_routines_fast.c:168:Error [1105] symbol 'battery_voltage_variable' has not been defined C:\FrcCode2005v2.2\user_routines_fast.c:168:Warning [2058] call of function without prototype Halting build on first failure as requested. Code:
printf("volts %d\n","battery_voltage %d\n",(int)volts,(int)battery_voltage);
|
|
#8
|
||||
|
||||
|
Re: Project Questions about Programming and Electrical
Are you doing the volts equation before printf?
|
|
#9
|
||||
|
||||
|
Re: Project Questions about Programming and Electrical
Code:
printf("volts %d\n","battery_voltage %d\n",(int)volts,(int)battery_voltage);
Code:
printf("volts %d\n battery_voltage %d\n",(int)volts,(int)battery_voltage);
|
|
#10
|
||||
|
||||
|
Re: Project Questions about Programming and Electrical
Well, I tried your code and same thing... I then defined battery_voltage in user_routines_fast and it's now updating, but the values are still in the 15 and 16000 range. I totally took out all the multiplication and stuff to get the normal volts and just created values using that equation so now I'm doing stuff like:
Code:
if (battery_voltage < 361)
{
relay02_fwd = 1 (<- this may be wrong, I'm writing this from memory)
}
Edit: Just thought of another problem. My charger should stop charging when the value is greater than like 370 or something, but even though it's 16000, the charger remains on. I can connect the charger to a switch with the software and it works, so I'm probably screwing something up with the programming. |
|
#11
|
||||
|
||||
|
Re: Project Questions about Programming and Electrical
Well, no one has replied in over a week, so I'm going to ask again...
Okay... I've tried to program the controller to read the battery voltage, but it's giving me raw values of over 16,000 (if you go to this post, they're experiencing the same problem). No body answered their question, and I posted there yesterday and also got no answer. Please please, any ideas are greatly appreciated, otherwise this thing will overcharge as it did last time. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| two electrical questions | mechanicalbrain | Electrical | 9 | 11-07-2005 09:41 |
| Problems and questions about programming | hedgehogger | Programming | 4 | 15-01-2005 18:18 |
| Questions about DNS, URL Forwarding, and Cloaking | sanddrag | Website Design/Showcase | 7 | 22-10-2004 21:32 |
| Questions about Textures and Models | thoughtful | 3D Animation and Competition | 28 | 11-02-2004 22:13 |
| Pneumatics electrical wiring and programming | archiver | 2001 | 1 | 23-06-2002 23:10 |