//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// ARDUINO BATTERY CAPACITY TESTER
// You need an hardware modification and a current of 2 A, using second amplifier, read:
// https://www.voilec.com/pages/battery_test.php
// *******************************************************
/*
This tool shows PWM value on Oled display, 0..255. You can change it with Up/Down buttons,
and observe on oscilloscope and voltmeters influence of the various parameters.
For these experiments, replace the 18650 by a power supply 4 V with limit at 3 A.
When this test running, current is active, place a voltmeter on power resistor and check for temperature increase.
*/
float Vref_Voltage = 1.219 ; // LM385BLP-1.2 Band Gap Reference voltage -> Need to be exactly adjusted
float Resistance = 1.004; // Value of R3 Power Resistor -> Need to be exactly adjusted
#define supplyOn true // Bridge on 12 V-> 2 V on A2, set to false if not
#include<JC_Button.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
#define LED_BUILTIN 13 // Led on Nano bord
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
//Desired Current steps
//int Current [] = {0,50,100,200,300,400,500,600,700,800,900,1000, 1500, 2000};
//int PWM [] = {0, 2, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70};
const int Vvolt_Pin = A2; // Pin to read 12V supply
const byte PWM_Pin = 10;
const byte buzzer = 9;
bool calc = false, Done = false, press = false, Report_Info = true;
// From library : pinMode(m_pin, m_puEnable ? INPUT_PULLUP : INPUT);
Button UP_Button(2, 25, true, true); // No need for external resistor, internal enabled false -> last true
Button Down_Button(3, 25, true, true);
uint8_t PWM_bk, PWM=60 ;
// **********************************************
void setup ()
{
Serial.begin(115200);
pinMode(PWM_Pin, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
analogWrite(PWM_Pin, 0); // No current on start
UP_Button.begin();
Down_Button.begin();
while (!Serial);
nStars (12);
Serial.print ("\nBATTERY CAPACITY TESTER\nVersion 3.01\nCompilation : ") ;
// Example of __DATE__ string: "Jul 27 2012"
// 01234567890 11 car
Serial.print (__DATE__) ; // Compilater Gcc constants
Serial.print (" ") ;
// Example of __TIME__ string: "21:06:19"
// 01234567 8 car
Serial.println (__TIME__) ;
Serial.println ("") ;
//nStars (2);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
delay (10);
panel_Intro(); // Compilation informations
soundSwitchAction ();
delay (2000);
//supplySecurity (); // Test if the 12 V supply is present
}
// **********************************************
void loop()
{
Serial.print("PWM: ");
Serial.println(PWM);
UP_Button.read();
Down_Button.read();
//if (UP_Button.wasReleased() )
if (UP_Button.read() )
{
++PWM;
//soundRecord () ;
press = true;
}
//if (Down_Button.wasReleased() )
if (Down_Button.read() )
{
--PWM;
//soundRecord ();
press = true;
}
//if (PWM>100)
// PWM=100;
analogWrite(PWM_Pin, PWM); // No current on start
if (PWM !=PWM_bk)
{
display.clearDisplay();
display.setTextSize(1);
display.setCursor(30,5);
display.print("PWM = ");
display.setTextSize(4);
display.setCursor(40,30);
display.print(PWM);
display.display();
}
}
// **********************************************
void panel_Intro()
{
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(1);
display.setCursor(0,2);
display.print("Small Battery tester");
display.setCursor(28,17);
display.print("Version 3.2");
display.setCursor(26,30);
display.print(__DATE__);
display.setCursor(38,41);
display.print(__TIME__);
display.setCursor(18,54);
display.print("www.voilec.com");
display.display();
}