diff --git a/README.md b/README.md index e4c653c..936209f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # PowerTester Testing volts and amp from a PCB and log into SDCard. + + +File pro_mini.png provides a guide for the pin out. diff --git a/TODO b/TODO index c6e026f..f2e0345 100644 --- a/TODO +++ b/TODO @@ -10,3 +10,18 @@ Use current sense resistor PWR263S-20-R500F. PLACED Place SD card holder. PLACED Use solid state mosfet relay ASSR-1611-501E. PLACED +Firmware +-------- +Screen DONE +Menu DONE +Buttons DONE +Voltage measurement DONE +Load line on/off DONE +Current measurement +SD card +Bluetooth + + +BOX +--- + diff --git a/firmware/v01/v01.ino b/firmware/v01/v01.ino index 5cb85ff..7e4fb29 100644 --- a/firmware/v01/v01.ino +++ b/firmware/v01/v01.ino @@ -1,5 +1,4 @@ /********************************************************************* - Powertester Measures 2 voltages and current from an equipment(Load), and logs @@ -9,22 +8,30 @@ By Jony Silva Tue Jun 12 14:56:12 GMT 2018 *********************************************************************/ - +#include #include -// Configuration of pins ------------------------------------------------------------------------------ -#define v_batt 7 // Analog pin for the battery voltage, insert here arduino pin -#define volt_1 0 // Analog pin for voltage 1, insert here arduino pin -#define volt_2 1 // Analog pin for voltage 2, insert here arduino pin +// Configuration of pins, insert here arduino pin numbers only(not fisical)---------------------------- +#define v_batt 7 // Analog pin for the battery voltage +#define volt_1 0 // Analog pin for voltage 1 +#define volt_2 1 // Analog pin for voltage 2 #define load_line 17 // Line that turns load On or Off -#define LEFT 16 // Button 1 will be function Left, insert here arduino pin -#define RIGHT 18 // Button 2 will be function Right, insert here arduino pin -#define ACT 19 // Button 3 will be function Action, insert here arduino pin +#define LEFT 16 // Button 1 will be function Left +#define RIGHT 18 // Button 2 will be function Right +#define ACT 19 // Button 3 will be function Action LiquidCrystal lcd(7, 6, 2, 3, 4, 5); // LCD screen pins, LiquidCrystal(rs, enable, d4, d5, d6, d7) //----------------------------------------------------------------------------------------------------- +// Other configurations ------------------------------------------------------------------------------------ +#define battery_volt 3 // Parameter position where battery voltage value is hold +#define voltage_1 0 // Parameter position where voltage one value is hold +#define voltage_2 1 // Parameter position where voltage two value is hold +#define numOfScreens 6 // Number of screen menus, select here and rearrange String screens +//---------------------------------------------------------------------------------------------------------- + + // Macros to read the buttons -------------------------------- #define rLEFT digitalRead(LEFT) // Read button Left #define rRIGHT digitalRead(RIGHT) // Read button Right @@ -36,7 +43,6 @@ LiquidCrystal lcd(7, 6, 2, 3, 4, 5); // LCD screen pins, LiquidCrystal(rs, enabl bool sd_status = 0; bool load_status = 0; -const int numOfScreens = 6; int currentScreen = 0; String screens[numOfScreens][2] = {{"Voltage 1","Volts"}, {"Voltage 2","Volts"}, {"Load current","Amps"},{"Batt Voltage","volts"}, {"SD Logging", ""}, {"Load", ""}}; @@ -59,12 +65,12 @@ float volt_pin (int pin); // Read and display voltage -void setup() { - - pinMode(LEFT, INPUT); // Button 1 is an input - pinMode(RIGHT, INPUT); // Button 2 is an input - pinMode(ACT, INPUT); // Button 3 is an input - pinMode(load_line, OUTPUT); // Output that controls the load +void setup() +{ + pinMode(LEFT, INPUT); // Button left is an input + pinMode(RIGHT, INPUT); // Button right is an input + pinMode(ACT, INPUT); // Button act is an input + pinMode(load_line, OUTPUT); // load_line is an output lcd.begin(16, 2); @@ -84,7 +90,6 @@ void setup() { TIMSK1 |= (1 << OCIE1A); // enable timer compare interrupt interrupts(); // enable all interrupts // ---------------------------------------------------------- - } @@ -97,66 +102,83 @@ ISR(TIMER1_COMPA_vect) //------------------------------------------- -void loop() { - - parameters[3] = volt_pin(v_batt); - parameters[0] = volt_pin(volt_1); - parameters[1] = volt_pin(volt_2); +void loop() +{ + parameters[battery_volt] = volt_pin(v_batt); + parameters[voltage_1] = volt_pin(volt_1); + parameters[voltage_2] = volt_pin(volt_2); printScreen(); delay(4000); } -void menuState() { +void menuState() +{ - if (!rRIGHT) { - if (currentScreen == 5) { + if (!rRIGHT) + { + if (currentScreen == (numOfScreens - 1)) + { currentScreen = 0; } - else { + else + { currentScreen++; } while (!rRIGHT); // Check if button is still pressed do nothing printScreen(); } - if (!rLEFT) { - if (currentScreen == 0) { - currentScreen = 5; + if (!rLEFT) + { + if (currentScreen == 0) + { + currentScreen = (numOfScreens - 1); } - else { + else + { currentScreen--; } while (!rLEFT); // Check if button is still pressed do nothing printScreen(); } - if (!rACT) { - if (currentScreen == 4) { + if (!rACT) + { + if (currentScreen == 4) + { sd_status = !sd_status; } - if (currentScreen == 5) { + if (currentScreen == 5) + { load_status = !load_status; } while (!rACT); // Check if button is still pressed do nothing printScreen(); } - } -void printScreen() { +void printScreen() +{ lcd.clear(); lcd.print(screens[currentScreen][0]); lcd.setCursor(0,1); - if (currentScreen == 4) { + if (currentScreen == 4) + { lcd.print(parameters_sd[sd_status]); } - else if (currentScreen == 5) { + else if (currentScreen == 5) + { lcd.print(parameters_load[load_status]); } - else { + else if (currentScreen == 6) + { + lcd.print(screens[currentScreen][1]); + } + else + { lcd.print(parameters[currentScreen]); lcd.print(" "); lcd.print(screens[currentScreen][1]); @@ -164,8 +186,8 @@ void printScreen() { } -float volt_pin(int pin) { - +float volt_pin(int pin) +{ float voltage; voltage = analogRead(pin); // Obtain RAW voltage data voltage = (voltage / 1024) * 3.3; // Convert to actual voltage diff --git a/pro_mini.png b/pro_mini.png new file mode 100644 index 0000000..9741c1c Binary files /dev/null and b/pro_mini.png differ