Working on firmware. A picture of the arduino pin out was added for reference.
This commit is contained in:
@@ -1,2 +1,5 @@
|
|||||||
# PowerTester
|
# PowerTester
|
||||||
Testing volts and amp from a PCB and log into SDCard.
|
Testing volts and amp from a PCB and log into SDCard.
|
||||||
|
|
||||||
|
|
||||||
|
File pro_mini.png provides a guide for the pin out.
|
||||||
|
15
TODO
15
TODO
@@ -10,3 +10,18 @@ Use current sense resistor PWR263S-20-R500F. PLACED
|
|||||||
Place SD card holder. PLACED
|
Place SD card holder. PLACED
|
||||||
Use solid state mosfet relay ASSR-1611-501E. 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
|
||||||
|
---
|
||||||
|
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
|
|
||||||
Powertester
|
Powertester
|
||||||
|
|
||||||
Measures 2 voltages and current from an equipment(Load), and logs
|
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
|
Tue Jun 12 14:56:12 GMT 2018
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
|
|
||||||
|
#include <avr/sleep.h>
|
||||||
#include <LiquidCrystal.h>
|
#include <LiquidCrystal.h>
|
||||||
|
|
||||||
|
|
||||||
// Configuration of pins ------------------------------------------------------------------------------
|
// Configuration of pins, insert here arduino pin numbers only(not fisical)----------------------------
|
||||||
#define v_batt 7 // Analog pin for the battery voltage, insert here arduino pin
|
#define v_batt 7 // Analog pin for the battery voltage
|
||||||
#define volt_1 0 // Analog pin for voltage 1, insert here arduino pin
|
#define volt_1 0 // Analog pin for voltage 1
|
||||||
#define volt_2 1 // Analog pin for voltage 2, insert here arduino pin
|
#define volt_2 1 // Analog pin for voltage 2
|
||||||
#define load_line 17 // Line that turns load On or Off
|
#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 LEFT 16 // Button 1 will be function Left
|
||||||
#define RIGHT 18 // Button 2 will be function Right, insert here arduino pin
|
#define RIGHT 18 // Button 2 will be function Right
|
||||||
#define ACT 19 // Button 3 will be function Action, insert here arduino pin
|
#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)
|
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 --------------------------------
|
// Macros to read the buttons --------------------------------
|
||||||
#define rLEFT digitalRead(LEFT) // Read button Left
|
#define rLEFT digitalRead(LEFT) // Read button Left
|
||||||
#define rRIGHT digitalRead(RIGHT) // Read button Right
|
#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 sd_status = 0;
|
||||||
bool load_status = 0;
|
bool load_status = 0;
|
||||||
|
|
||||||
const int numOfScreens = 6;
|
|
||||||
int currentScreen = 0;
|
int currentScreen = 0;
|
||||||
String screens[numOfScreens][2] = {{"Voltage 1","Volts"}, {"Voltage 2","Volts"},
|
String screens[numOfScreens][2] = {{"Voltage 1","Volts"}, {"Voltage 2","Volts"},
|
||||||
{"Load current","Amps"},{"Batt Voltage","volts"}, {"SD Logging", ""}, {"Load", ""}};
|
{"Load current","Amps"},{"Batt Voltage","volts"}, {"SD Logging", ""}, {"Load", ""}};
|
||||||
@@ -59,12 +65,12 @@ float volt_pin (int pin); // Read and display voltage
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup()
|
||||||
|
{
|
||||||
pinMode(LEFT, INPUT); // Button 1 is an input
|
pinMode(LEFT, INPUT); // Button left is an input
|
||||||
pinMode(RIGHT, INPUT); // Button 2 is an input
|
pinMode(RIGHT, INPUT); // Button right is an input
|
||||||
pinMode(ACT, INPUT); // Button 3 is an input
|
pinMode(ACT, INPUT); // Button act is an input
|
||||||
pinMode(load_line, OUTPUT); // Output that controls the load
|
pinMode(load_line, OUTPUT); // load_line is an output
|
||||||
|
|
||||||
lcd.begin(16, 2);
|
lcd.begin(16, 2);
|
||||||
|
|
||||||
@@ -84,7 +90,6 @@ void setup() {
|
|||||||
TIMSK1 |= (1 << OCIE1A); // enable timer compare interrupt
|
TIMSK1 |= (1 << OCIE1A); // enable timer compare interrupt
|
||||||
interrupts(); // enable all interrupts
|
interrupts(); // enable all interrupts
|
||||||
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -97,66 +102,83 @@ ISR(TIMER1_COMPA_vect)
|
|||||||
//-------------------------------------------
|
//-------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
void loop() {
|
void loop()
|
||||||
|
{
|
||||||
parameters[3] = volt_pin(v_batt);
|
parameters[battery_volt] = volt_pin(v_batt);
|
||||||
parameters[0] = volt_pin(volt_1);
|
parameters[voltage_1] = volt_pin(volt_1);
|
||||||
parameters[1] = volt_pin(volt_2);
|
parameters[voltage_2] = volt_pin(volt_2);
|
||||||
|
|
||||||
printScreen();
|
printScreen();
|
||||||
delay(4000);
|
delay(4000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void menuState() {
|
void menuState()
|
||||||
|
{
|
||||||
|
|
||||||
if (!rRIGHT) {
|
if (!rRIGHT)
|
||||||
if (currentScreen == 5) {
|
{
|
||||||
|
if (currentScreen == (numOfScreens - 1))
|
||||||
|
{
|
||||||
currentScreen = 0;
|
currentScreen = 0;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
currentScreen++;
|
currentScreen++;
|
||||||
}
|
}
|
||||||
while (!rRIGHT); // Check if button is still pressed do nothing
|
while (!rRIGHT); // Check if button is still pressed do nothing
|
||||||
printScreen();
|
printScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rLEFT) {
|
if (!rLEFT)
|
||||||
if (currentScreen == 0) {
|
{
|
||||||
currentScreen = 5;
|
if (currentScreen == 0)
|
||||||
|
{
|
||||||
|
currentScreen = (numOfScreens - 1);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
currentScreen--;
|
currentScreen--;
|
||||||
}
|
}
|
||||||
while (!rLEFT); // Check if button is still pressed do nothing
|
while (!rLEFT); // Check if button is still pressed do nothing
|
||||||
printScreen();
|
printScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rACT) {
|
if (!rACT)
|
||||||
if (currentScreen == 4) {
|
{
|
||||||
|
if (currentScreen == 4)
|
||||||
|
{
|
||||||
sd_status = !sd_status;
|
sd_status = !sd_status;
|
||||||
}
|
}
|
||||||
if (currentScreen == 5) {
|
if (currentScreen == 5)
|
||||||
|
{
|
||||||
load_status = !load_status;
|
load_status = !load_status;
|
||||||
}
|
}
|
||||||
while (!rACT); // Check if button is still pressed do nothing
|
while (!rACT); // Check if button is still pressed do nothing
|
||||||
printScreen();
|
printScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void printScreen() {
|
void printScreen()
|
||||||
|
{
|
||||||
lcd.clear();
|
lcd.clear();
|
||||||
lcd.print(screens[currentScreen][0]);
|
lcd.print(screens[currentScreen][0]);
|
||||||
lcd.setCursor(0,1);
|
lcd.setCursor(0,1);
|
||||||
|
|
||||||
if (currentScreen == 4) {
|
if (currentScreen == 4)
|
||||||
|
{
|
||||||
lcd.print(parameters_sd[sd_status]);
|
lcd.print(parameters_sd[sd_status]);
|
||||||
}
|
}
|
||||||
else if (currentScreen == 5) {
|
else if (currentScreen == 5)
|
||||||
|
{
|
||||||
lcd.print(parameters_load[load_status]);
|
lcd.print(parameters_load[load_status]);
|
||||||
}
|
}
|
||||||
else {
|
else if (currentScreen == 6)
|
||||||
|
{
|
||||||
|
lcd.print(screens[currentScreen][1]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
lcd.print(parameters[currentScreen]);
|
lcd.print(parameters[currentScreen]);
|
||||||
lcd.print(" ");
|
lcd.print(" ");
|
||||||
lcd.print(screens[currentScreen][1]);
|
lcd.print(screens[currentScreen][1]);
|
||||||
@@ -164,8 +186,8 @@ void printScreen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float volt_pin(int pin) {
|
float volt_pin(int pin)
|
||||||
|
{
|
||||||
float voltage;
|
float voltage;
|
||||||
voltage = analogRead(pin); // Obtain RAW voltage data
|
voltage = analogRead(pin); // Obtain RAW voltage data
|
||||||
voltage = (voltage / 1024) * 3.3; // Convert to actual voltage
|
voltage = (voltage / 1024) * 3.3; // Convert to actual voltage
|
||||||
|
BIN
pro_mini.png
Normal file
BIN
pro_mini.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 469 KiB |
Reference in New Issue
Block a user