Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 09, 2016, 02:34:57 14:34


Login with username, password and session length


Pages: [1]
Print
Author Topic: C code help  (Read 1484 times)
0 Members and 1 Guest are viewing this topic.
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 976

Thank You
-Given: 197
-Receive: 344



« on: August 17, 2009, 08:20:47 20:20 »

I need a bit of help, Attached is a c file which is part of the battery Capcity meter, What I'm trying to understand has I do not know C that well, is I'm trying to find the part of the bit of code that works out the calibration of the battery voltage, So I can see if I can port it over to PDS, Can you C bofins have a look at it

Wizpic
Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
Ichan
Hero Member
*****
Offline Offline

Posts: 840

Thank You
-Given: 312
-Receive: 387



WWW
« Reply #1 on: August 17, 2009, 10:53:51 22:53 »

Quote
I'm trying to find the part of the bit of code that works out the calibration of the battery voltage

I'm not very sure what you are looking for, how it read the battery voltage? how it adjust the pwm? Perhaps more description will help and the schematic too.

Anyway I 'm a bit surprised that there is a lot of task on the interupt service, most adc measurement and calculation are inside "myISRHigh" interupt service, not pretty i think.

-ichan
Logged

There is Gray, not only Black or White.
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 976

Thank You
-Given: 197
-Receive: 344



« Reply #2 on: August 17, 2009, 11:32:06 23:32 »

What I was lookng for is how he is doing his one time calibration without no trim pots, I've attached the schematic and calibration procedure, Not sure what the resalution is like, I just like the idea and wanted to try and use his idea, by looking at the schematic he is using a high and a low inoput then some how using that to calibrate the voltage reading.
Attached is the schematic and calibration procedure, I think is is part of it but not quote sure

Code:
void setVoltageRail50(int i)
{
doEnterNumberMenu((rom char*) "+5V Rail (V)?", 4.0, 6.0, 2, (double*)&voltageRail50);
}

/*
void calibrateVoltageRail50(int i)
{
double g;
if(areYouSure())
{
while(totalUpdated==0);
g=3.30000/vusbRail;
voltageRail50*=g;
}
}
*/

/*
void setVoltageRail33(int i)
{
doEnterNumberMenu((rom char*) "+3.3V Rail (V)? ", 3.0, 3.6, 2, &voltageRail33);
}
*/


Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
Ichan
Hero Member
*****
Offline Offline

Posts: 840

Thank You
-Given: 312
-Receive: 387



WWW
« Reply #3 on: August 18, 2009, 02:58:48 02:58 »

Quick reading the schematic and the code, what i can catch:

- The purpose of separate input for Batt Lo and Batt Hi is to measure the the circuit (not battery) current and voltage.
- The ADC use Vdd (VRail) as reference voltage.
- The calibration is to define "adjustment factor" against the reading of DVM each for VRail, Bat Lo (Circuit Voltage), and Batt Hi (Battery Voltage).

I'll try to look into it more deeper later.

-ichan
Logged

There is Gray, not only Black or White.
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC