-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDC_Load.ino
More file actions
118 lines (102 loc) · 3.76 KB
/
Copy pathDC_Load.ino
File metadata and controls
118 lines (102 loc) · 3.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/* INCLUDES ********************************************************************/
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <JC_Button.h>
/* DECLARATIONS *******************************************************************/
//LCD I2C pins declaration
LiquidCrystal_I2C lcd(0x27, 16, 2);
// TEMPERATURE sensor data wire on the Arduino
#define ONE_WIRE_BUS 4
/********************************************************************/
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
/********************************************************************/
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
/********************************************************************/
const byte CurrentPin = A4; // current read pin
const byte VoltagePin = A5; // voltage read pin
//const byte voltageCheck = A5;
//const byte PotInputPin = A2; // pot input
const byte RelayOnOff = 12;
const byte ControlPin = 13; // control voltage pin
const byte FGenPin = 5;
const byte StatusLED = 6; // On/Off LED
ToggleButton // JC_button: define toggle buttons
LoadOnOff(7),
SetButton(8);
Button
CursorToggle(9),
ValueDown(10),
ValueUp(11);
unsigned long previousMillisP = 0;
unsigned long currentMillisP;
unsigned long previousMillisA = 0;
unsigned long currentMillisA;
unsigned long previousMillisV = 0;
unsigned long currentMillisV;
unsigned long previousMillisT = 0;
unsigned long currentMillisT;
unsigned long previousMillis = 0;
unsigned long currentMillis;
int interval = 500;
//int potValue;
float current;
float voltage;
int power;
// Temperature settings
int tempResolution = 12;
unsigned long lastTempRequest = 0;
int delayInMillis = 0;
float temperature = 0.0;
int idle = 0;
// Shut-off Limits
float temperatureLimit = 45.0; // in Celsius
float currentLimit = 2.0; // in Amperes
float voltageLimit = 12.0; // in Volts
float powerLimit = 80.0; // in Watts
// Limits refs
float& currentLimitRef = currentLimit;
float& voltageLimitRef = voltageLimit;
float& tempLimitRef = temperatureLimit;
float& powerLimitRef = powerLimit;
// Limits screen positions
int currentLimitPos[] = {0,1,3,1}; // cursor start, row, printed value length, decimal places
int voltageLimitPos[] = {5,1,2,0};
int powerLimitPos[] = {9,1,2,0};
int tempLimitPos[] = {13,1,2,0};
// Transients
bool TransientsStatus = false;
float transientFrequency = 1; // in Hz
float transientMin = 0.5; // in Amperes
float transientMax = 1.0; // in Amperes
// Transients refs
float& transientFrequencyRef = transientFrequency;
float& transientMinRef = transientMin;
float& transientMaxRef = transientMax;
// Transients screen positions
int transientFrequencyPos[] = {0,1,5,0}; // cursor start, row, printed value length, decimal places
int transientMinPos[] = {11,1,3,2};
int transientMaxPos[] = {11,0,3,2};
int controlVMin = 0;
int controlVMax = 0;
int controlMillis = 0;
bool controlStatus = false;
int CP = 0; // cursor position
float SetCurrentValue;
float CurrentVal1 = 1; // set current 1.00 A value
float CurrentVal2 = 0; // set current 0.10 A value
float CurrentVal3 = 0; // set current 0.01 A value
int Load = 0;
int controlVoltage = 0;
String Mode = "Read";
int cycle = 0;
int cycleMax = 0;
float value; float valStep; float valMin; float valMax;
bool FGenStatus = false;
int test;
float diff;
float adjustment;