View Single Post
Old 07-19-2012, 09:42 AM   #21 (permalink)
Daox
Administrator
 
Daox's Avatar
 
Join Date: Dec 2007
Location: Germantown, WI
Posts: 11,166

CM400E - '81 Honda CM400E
90 day: 51.49 mpg (US)

Daox's Grey Prius - '04 Toyota Prius
Team Toyota
90 day: 49.53 mpg (US)

Daox's Insight - '00 Honda Insight
90 day: 64.33 mpg (US)

Swarthy - '14 Mitsubishi Mirage DE
Mitsubishi
90 day: 56.69 mpg (US)
Thanks: 2,464
Thanked 2,535 Times in 1,529 Posts
Thanks a lot for taking the time to look through this thingstodo! I appreciate it very much.

My code that is in the first post is quite dated. I have updated a fair amount of things from testing different portions of the code. However, I haven't put it all back together yet, thus I haven't reposted it.

I'm very glad you brought up the limitations of the float variable as it may be an issue. This is the latest code for the interrupt that I have been using. RawCurrentRead, CurrentRead, and AHused are all float type variables.

Code:
// interrupt to count amp hours used
ISR(TIMER1_COMPA_vect)
{
    // read sensor output
    RawCurrentRead = analogRead(CurrentPin);
    
    // calibrate sensor
    CurrentSensorCalib = analogRead(CurrentSensorCalibPin);
    
    // Convert currentread to amps
    CurrentRead = (RawCurrentRead - CurrentSensorCalib) * .78125;
    
    // Convert to AH used and add to total
    AHused = AHused + (CurrentRead * 0.0000002777);
}


I have yet to hook the arduino up to a more noise proof power source. I was going to do this but I am depending on the arduino's serial output to get feedback on the variables. I'm not sure how to connect the arduino to the computer without using the USB to power it. This is where a scope would come in quite handy.


Thanks for finding those chips! I'll have to take a look at them once I get the BMS in the car and running things properly.

__________________
Current project: A better alternator delete
  Reply With Quote