new project guidance - battery monitor display

Good day all.

I am starting a new arduino based project.

I am wanting to fit a display to my e-bike battery pack so I can see the voltage of each cell, and total pack voltage.

The e-bike battery pack has 10x 3.7v 20Ah LiPo Cells.

Hardware wise I don't think I will have to much of a problem.

But writing the code for the arduino is where I am going to need help.

I have started work on the code over the last few days

Here is my current code.

/*

<3.00v		= FLASHING RED + BUZZER
3.00v - 3.19v	= RED
3.20v - 3.39v	= CRIMSON
3.40v - 3.59v	= ORANGE
3.60v - 3.79v	= YELLOW
3.80v - 3.99v	= GOLD
4.00v - 4.20v	= GREEN
>4.20v		= FLASHING RED + BUZZER


Created: 29/06/2013.
Modified: 30/06/2013.

By "Mad Professor"

*/

#include <ColorLCDShield.h>

const int ReadCellVolt = A0;                         // Analog input pin for sencing battery cell voltage
const int S0 = 2;                                    // Digital output pin for MUX IC (S0 pin)
const int S1 = 3;                                    // Digital output pin for MUX IC (S1 pin)
const int S2 = 4;                                    // Digital output pin for MUX IC (S2 Pin)
const int BUZZER = 5;                                // PWM output pin for Warning Buzzer
const int BackLight = 6;                             // Digital output pin for LCD Backlight
const int WakeButton = 7;                            // Digital input pin for waking up LCD Display

int BG_COLOR = BLACK;                                // Set LCD Background Color
int TXT_COLOR = WHITE;                               // Set LCD Text Color
int CV_COLOR = RED;                                  // Set LCD Cell Voltage Color
int PV_COLOR = RED;                                  // Set LCD Pack Voltage Color
int SOC_COLOR = RED;                                 // Set LCD State Of Charge Color


LCDShield lcd;void setup()
{                                                    
 lcd.init(PHILIPS, 1);                               // sets LCD type
 lcd.contrast(63);                                   // sets LCD contrast (value between 0~63)
 lcd.clear(BG_COLOR);                                // Sets Background Color
 lcd.setStr("C01:", 0,0, TXT_COLOR, BG_COLOR);       // 
 lcd.setStr("C02:", 0,65, TXT_COLOR, BG_COLOR);      // 
 lcd.setStr("C03:", 15,0, TXT_COLOR, BG_COLOR);      // 
 lcd.setStr("C04:", 15,65, TXT_COLOR, BG_COLOR);     // 
 lcd.setStr("C05:", 30,0, TXT_COLOR, BG_COLOR);      // 
 lcd.setStr("C06:", 30,65, TXT_COLOR, BG_COLOR);     // 
 lcd.setStr("C07:", 45,0, TXT_COLOR, BG_COLOR);      // 
 lcd.setStr("C08:", 45,65, TXT_COLOR, BG_COLOR);     // 
 lcd.setStr("C09:", 60,0, TXT_COLOR, BG_COLOR);      // 
 lcd.setStr("C10:", 60,65, TXT_COLOR, BG_COLOR);     // 
 lcd.setStr("Pack Voltage", 85,15, BLUE, BG_COLOR);  // 
}


void loop()
{

// Cell 1
 digitalWrite(S2, LOW);                              // 
 digitalWrite(S1, LOW);                              // 
 digitalWrite(S0, LOW);                              // 
 delay(10);                                           // 
 int sensorValue = analogRead(ReadCellVolt);         // 
 float voltage1 = sensorValue * (5.0 / 1023.0);      // 
 lcd.setStr("0.00", 0,30, CV_COLOR, BG_COLOR);       // 

// Cell 2
 digitalWrite(S2, LOW);                              // 
 digitalWrite(S1, LOW);                              // 
 digitalWrite(S0, HIGH);                             // 
 delay(10);                                           // 
 sensorValue = analogRead(ReadCellVolt);             // 
 float voltage2 = sensorValue * (5.0 / 1023.0);      // 
 lcd.setStr("0.00", 0,95, CV_COLOR, BG_COLOR);       // 

// Cell 3
 digitalWrite(S2, LOW);                              // 
 digitalWrite(S1, HIGH);                             // 
 digitalWrite(S0, LOW);                              // 
 delay(10);                                           // 
 sensorValue = analogRead(ReadCellVolt);             // 
 float voltage3 = sensorValue * (5.0 / 1023.0);      // 
 lcd.setStr("0.00", 15,30, CV_COLOR, BG_COLOR);      // 

// Cell 4
 digitalWrite(S2, LOW);                              // 
 digitalWrite(S1, HIGH);                             // 
 digitalWrite(S0, HIGH);                             // 
 delay(10);                                           // 
 sensorValue = analogRead(ReadCellVolt);             // 
 float voltage4 = sensorValue * (5.0 / 1023.0);      // 
 lcd.setStr("0.00", 15,95, CV_COLOR, BG_COLOR);      // 

// Cell 5
 digitalWrite(S2, HIGH);                             // 
 digitalWrite(S1, LOW);                              // 
 digitalWrite(S0, LOW);                              // 
 delay(10);                                           // 
 sensorValue = analogRead(ReadCellVolt);             // 
 float voltage5 = sensorValue * (5.0 / 1023.0);      // 
 lcd.setStr("0.00", 30,30, CV_COLOR, BG_COLOR);      // 

// Cell 6
 digitalWrite(S2, HIGH);                             // 
 digitalWrite(S1, LOW);                              // 
 digitalWrite(S0, HIGH);                             // 
 delay(10);                                           // 
 sensorValue = analogRead(ReadCellVolt);             // 
 float voltage6 = sensorValue * (5.0 / 1023.0);      // 
 lcd.setStr("0.00", 30,95, CV_COLOR, BG_COLOR);      // 

// Cell 7
 digitalWrite(S2, HIGH);                             // 
 digitalWrite(S1, HIGH);                             // 
 digitalWrite(S0, LOW);                              // 
 delay(10);                                           // 
 sensorValue = analogRead(ReadCellVolt);             // 
 float voltage7 = sensorValue * (5.0 / 1023.0);      // 
 lcd.setStr("0.00", 45,30, CV_COLOR, BG_COLOR);      // 

// Cell 8
// digitalWrite(S2, HIGH, S1, HIGH, S0, HIGH);       // 
 digitalWrite(S2, HIGH);                             // 
 digitalWrite(S1, HIGH);                             // 
 digitalWrite(S0, HIGH);                             // 
 delay(10);                                           // 
 sensorValue = analogRead(ReadCellVolt);             // 
 float voltage8 = sensorValue * (5.0 / 1023.0);      // 
 lcd.setStr("0.00", 45,95, CV_COLOR, BG_COLOR);      // 

// Cell 9
// digitalWrite(S2, ????);                           // 
// digitalWrite(S1, ????);                           // 
// digitalWrite(S0, ????);                           // 
 delay(10);                                           // 
 sensorValue = analogRead(ReadCellVolt);             // 
 float voltage9 = sensorValue * (5.0 / 1023.0);      // 
 lcd.setStr("0.00", 60,30, CV_COLOR, BG_COLOR);      // 
 
// Cell 10
// digitalWrite(S2, LOW);                            // 
// digitalWrite(S1, LOW);                            // 
// digitalWrite(S0, LOW);                            // 
 delay(10);                                           // 
 sensorValue = analogRead(ReadCellVolt);             // 
 float voltage10 = sensorValue * (5.0 / 1023.0);     // 
 lcd.setStr("0.00", 60,95, CV_COLOR, BG_COLOR);      // 

// Pack voltage
 lcd.setStr("00.00v", 100,10, PV_COLOR, BG_COLOR);   // 
 
// State Of Charge
 lcd.setStr("000%", 100,85, SOC_COLOR, BG_COLOR);    // 
}

I am sure the code can be cleaned up a lot.

The above code was so that I could test the layout on screen, and start getting some working code.

Here is what the above code looks like on screen atm.

I am now starting to work on getting real input voltages to display on the screen.

Later on I would like to text colour to change depending on the cell voltage.

How is my code looking at this point, or is there a better way to go about doing it?

Thanks for your time.

Best Regards.

LCDShield lcd;void setup()

Novel layout - I had to read that one twice.

You've got a lot of constant strings which would probably be better placed in program memory.

Thanks for your reply,

As said above I am still very much a arduino newbe.

I have just found my 1st problem with coding, where I am unable to get the voltage to display on the lcd.

For testing the display I had

lcd.setStr("0.00", 0,30, CV_COLOR, BG_COLOR); //

But when I try to display the adc voltage by doing the following.

int sensorValue = analogRead(ReadCellVolt); //
float voltage1 = sensorValue * (5.0 / 1023.0); //
lcd.setStr(voltage1, 0,30, CV_COLOR, BG_COLOR); //

I get the following error when I try and upload.

no matching function for call to 'LCDShield::setStr(float&, int, int, int&, int&)'

I am sure I am doing something simple wrong here, can you please advice.

Thanks again.

I get an error when I try and upload.

I guess what it is, but you might want to let the others in on the secret.

The sparkfun nokia colour lcd library I am using only seems to have the following commands.

lcd.contrast
lcd.clear
lcd.init
lcd.printLogo
lcd.setArc
lcd.setCircle
lcd.setLine
lcd.setPixel
lcd.setRect
lcd.setStr

Or at least the only commands I could find.

I'm interested in this project. Specifically, I'd like to build a similar device for monitoring a pack of 45 cells in an EV (car).

Have you made any headway since the above posts?