Timeplot and Timekeeping Question
Posted: Fri Oct 14, 2022 12:29 pm
Hi, My sketch using the TIMEPLOT feature is now giving me a "Variable not defined error" when i try and compile the sketch but the same sketch compiled before and worked. Can someone help me figure out what is going on with the TIMEPLOT error and why it all of a sudden stopped working?
This is my Arduino code..
This is the compile error....
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\eightanaloginputs" "-IC:\\Users\\Greg\\Documents\\LTSketchbook\\libraries\\MLP-master" "-IC:\\Users\\Greg\\Documents\\LTSketchbook\\libraries\\Time-master" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-IC:\\Users\\Greg\\Documents\\LTSketchbook\\libraries\\SparkFun_MS5803-14BA_Pressure_Sensor\\src" "C:\\Users\\Greg\\AppData\\Local\\Temp\\arduino_build_543485\\sketch\\P-TESTER-V2rev2.03.ino.cpp" -o "C:\\Users\\Greg\\AppData\\Local\\Temp\\arduino_build_543485\\sketch\\P-TESTER-V2rev2.03.ino.cpp.o"
In file included from C:\Users\Greg\Documents\LTSketchbook\libraries\MLP-master/MegunoLink.h:6:0,
from C:\Users\Greg\Desktop\P-TESTER-V2\P_TESTER-V2.2\FIRMWARE 2.03\P-TESTER-V2rev2.03\P-TESTER-V2rev2.03.ino:1:
C:\Users\Greg\Documents\LTSketchbook\libraries\MLP-master/utility/TimePlot.h:90:50: error: 'tm' has not been declared
void SetCursorPosition(const char* SeriesName, tm &Time);
^~
C:\Users\Greg\Documents\LTSketchbook\libraries\MLP-master/utility/TimePlot.h:91:65: error: 'tm' has not been declared
void SetCursorPosition(const __FlashStringHelper* SeriesName, tm& Time);
^~
Using library MLP-master at version 1.30 in folder: C:\Users\Greg\Documents\LTSketchbook\libraries\MLP-master
Using library Time-master at version 1.5 in folder: C:\Users\Greg\Documents\LTSketchbook\libraries\Time-master
Using library Wire at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire
Using library SparkFun_MS5803-14BA_Pressure_Sensor at version 1.1.2 in folder: C:\Users\Greg\Documents\LTSketchbook\libraries\SparkFun_MS5803-14BA_Pressure_Sensor
exit status 1
Error compiling for board Arduino Pro or Pro Mini.
This is my Arduino code..
Code: Select all
#include <MegunoLink.h>
#include <CommandHandler.h>
#include <ArduinoTimer.h>
#include <MegunoLink.h>
#include <CommandHandler.h>
#include <ArduinoTimer.h>
// Pressure Sensor - Out of Bounds Technology
// ***************************************
#include "CommandHandler.h"
#include <TimeLib.h>
#include "MegunoLink.h"
#include <Wire.h>
#include <SparkFun_MS5803_I2C.h> // Click here to get the library: http://librarymanager/All#SparkFun_MS5803-14BA
XYPlot Myplot;
MS5803 sensor(ADDRESS_HIGH);
InterfacePanel MyPanel;
CommandHandler<> SerialCommandHandler;
// ***** USER CONROLLED VARIABLES ******
double Pressure_Bias = 1.03; // CHANGE THIS TO CALIBRATE THE PRESSURE SENSOR
double tplBIAS = .35; // Adjust this variable for leek detection sensitvity,(difference peek / max loss)
//***** SYSTEM VARIABLES *****
double PEEK_PRESSURE = 0;
double Pressure_Loss;
double Start_Pressure;
double stability_timer;
double temp_F, temp_c, Base_Pressure;
double pressure_abs = 0;
double pressure_psi = 0;
double Pressure_Average[3];
double timer = 0;
double avg_bar = 0;
double SET_TIMER = 30;
double Set_Time;
double tpLOSS = 0;
double stableDIFF = 0;
double TOTALDIFF = 0;
int start = 0;
int y = 0;
int x = 0;
int Y1 = 1;
int Y2 = 7;
void setup() {
// Start your preferred I2C object
Wire.begin();
//Initialize Serial Monitor
Serial.begin(9600);
//Retrieve calibration constants for conversion math.
sensor.reset();
sensor.begin();
READ_SETUP_PRESSURE();
SETUP_XYPLOT();
SETUP_DISPLAY();
}
void loop() {
SerialCommandHandler.Process();
READ_PRESSURE();
tpLOSS = (PEEK_PRESSURE - avg_bar);
// +++++++++++++UPDATED DISPLAY READINGS ++++++++++
Myplot.SendData("BAR", timer, avg_bar); // Display the graph
MyPanel.SetText(F("DynamicLabel11"), timer);
MyPanel.SetText(F("DynamicLabel2"), avg_bar); // Display BAR pressure
MyPanel.SetText(F("DynamicLabel4"), pressure_psi); // Display PSI pressure
MyPanel.SetText(F("DynamicLabel5"), temp_c);
MyPanel.SetText(F("DynamicLabel6"), temp_F);
MyPanel.SetText(F("DynamicLabel12"), tpLOSS );
if (x == 1){
TOTALDIFF = (tpLOSS - stableDIFF);
MyPanel.SetText(F("DynamicLabel15"), TOTALDIFF);
if (TOTALDIFF <= .03){
MyPanel.SetBackColor(F("DynamicLabel15"), F("Green"));
}
if (TOTALDIFF > .03){
MyPanel.SetBackColor(F("DynamicLabel15"), F("Orange"));
}
if (TOTALDIFF > .04){
MyPanel.SetBackColor(F("DynamicLabel15"), F("Red"));
}
}
// +++++++ Is there pressure ? ++++++++
if (avg_bar > 1)
{
if (start == 0){
setTime(0,0,0,0,0,0);
start = 1;
}
timer = (minute() + (second()*.01)); // start timer
// Is pressure rising? ++++++++++++++
if ((Pressure_Average[0] + .0005) < Pressure_Average[2])
{
MyPanel.SetBackColor(F("DynamicLabel7"), F("Orange"));
MyPanel.SetBackColor(F("DynamicLabel2"), F("Orange"));
MyPanel.SetBackColor(F("DynamicLabel4"), F("Orange"));
MyPanel.SetText(F("DynamicLabel7"), "PRESSURIZING");
}
// Is pressure stable? ++++++++++++++
if (Pressure_Average[0] == Pressure_Average[2])
{
MyPanel.SetBackColor(F("DynamicLabel7"), F("Green"));
MyPanel.SetText(F("DynamicLabel7"), "---PRESSURE STABLE---");
MyPanel.SetBackColor(F("DynamicLabel2"), F("Green")); //
MyPanel.SetBackColor(F("DynamicLabel4"), F("Green"));
stability_timer++;
if (x == 0){
if (stability_timer > .50)
{
Set_Time = timer;
Base_Pressure = ((sensor.getPressure(ADC_4096)*.001)- Pressure_Bias); // take pressure reading if stable for comparrison.
MyPanel.SetText(F("DynamicLabel9"), Base_Pressure);
stableDIFF = (PEEK_PRESSURE - Base_Pressure);
MyPanel.SetText(F("DynamicLabel10"),stableDIFF);
MyPanel.SetBackColor(F("DynamicLabel13"), F("Green"));
MyPanel.SetText(F("DynamicLabel13"),"TESTING..." );
x = 1;
}
}
}
// Is pressure going down? ++++++++++++++
if ((Pressure_Average[0]- .0005) > Pressure_Average[2])
{
if (y == 0)
{
PEEK_PRESSURE = ((sensor.getPressure(ADC_4096)*.001)- Pressure_Bias);
MyPanel.SetText(F("DynamicLabel14"),PEEK_PRESSURE);
y = 1;
}
if (timer < 1)
{
MyPanel.SetBackColor(F("DynamicLabel2"), F("yellow"));
MyPanel.SetBackColor(F("DynamicLabel4"), F("Yellow"));
MyPanel.SetBackColor(F("DynamicLabel7"), F("Yellow"));
MyPanel.SetText(F("DynamicLabel7"), "PRESSURE STABILIZING");
}
else
{
MyPanel.SetBackColor(F("DynamicLabel2"), F("Red"));
MyPanel.SetBackColor(F("DynamicLabel4"), F("Red"));
MyPanel.SetBackColor(F("DynamicLabel7"), F("Red"));
MyPanel.SetText(F("DynamicLabel7"), "PRESSURE DROPPING");
}
}
if (x == 2)
{
MyPanel.SetText(F("DynamicLabel12"), (Base_Pressure - avg_bar));
}
// ++++++++++++++++++ IS THERE A LEAK? ++++++++++++++++
if (stableDIFF > 0)
{
if (TOTALDIFF > .04)
{
MyPanel.SetBackColor(F("DynamicLabel8"), F("RED"));
MyPanel.SetText(F("DynamicLabel8"), "LEAK DETECTED");
MyPanel.SetBackColor(F("DynamicLabel13"), F("Red"));
MyPanel.SetText(F("DynamicLabel13"),"TESTING FAILED" );
}
}
}
}
// +++++++++++++++++++++++ FUNCTIONS +++++++++++++++++++++
void SETUP_DISPLAY()
{
MyPanel.SetBackColor(F("DynamicLabel5"), F("Control"));
// MyPanel.SetText(F("DynamicLabel7"), "");
MyPanel.SetBackColor(F("DynamicLabel7"), F("White"));
MyPanel.SetText(F("DynamicLabel7"), "");
MyPanel.SetBackColor(F("DynamicLabel8"), F("White"));
MyPanel.SetText(F("DynamicLabel8"), "");
MyPanel.SetBackColor(F("DynamicLabel2"), F("White"));
MyPanel.SetText(F("DynamicLabel12"), 0.00);
MyPanel.SetBackColor(F("DynamicLabel4"), F("White"));
MyPanel.SetText(F("DynamicLabel9"), 0.00);
MyPanel.SetText(F("DynamicLabel10"),0.00);
MyPanel.SetBackColor(F("DynamicLabel11"), F("Control"));
MyPanel.SetText(F("DynamicLabel11"), "");
MyPanel.SetBackColor(F("DynamicLabel13"), F("Cyan"));
MyPanel.SetText(F("DynamicLabel13"),"WAITING" );
MyPanel.SetText(F("DynamicLabel14"),PEEK_PRESSURE);
MyPanel.SetText(F("DynamicLabel12"), 0.00);
MyPanel.SetBackColor(F("DynamicLabel15"), F("Control"));
MyPanel.SetText(F("DynamicLabel15"), 0.00);
}
void SETUP_XYPLOT()
{
Myplot.Clear("BAR");
Myplot.SetTitle("P-TESTER - V2");
Myplot.SetXLabel("MINUTES");
Myplot.SetYLabel("BAR");
Myplot.SetSeriesProperties("BAR", Plot::Red, Plot::Solid, 2,Plot::NoMarker);
Myplot.SetYRange(Y1,Y2);
Myplot.SetY2Label("BAR");
Myplot.SetXRange(0,SET_TIMER);
}
double READ_PRESSURE()
{
// ++++++++++++PUT READINGS INTO AN ARRAY+++++++++++
for (byte i = 0; i < 3; i++)
{
Pressure_Average[i] = ((sensor.getPressure(ADC_4096)*.001) - Pressure_Bias);
if (Pressure_Average[i] <= 0 )
{
Pressure_Average[i] = 0;
}
delay(300);
}
// +++++++ Average the Pressure Readings ++++++++++++
avg_bar = ((Pressure_Average[0] + Pressure_Average[1] + Pressure_Average[2])/3);
// +++++++ Convert to PSI ++++++++++++
pressure_psi = (avg_bar * 14.5038);
// +++++++ GET TEMP READINGS ++++++++++++
temp_c = sensor.getTemperature(CELSIUS, ADC_512);
temp_F = sensor.getTemperature(FAHRENHEIT, ADC_512);
}
double READ_SETUP_PRESSURE()
{
Start_Pressure = ((sensor.getPressure(ADC_4096)*.001) - Pressure_Bias);
}
This is the compile error....
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\eightanaloginputs" "-IC:\\Users\\Greg\\Documents\\LTSketchbook\\libraries\\MLP-master" "-IC:\\Users\\Greg\\Documents\\LTSketchbook\\libraries\\Time-master" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-IC:\\Users\\Greg\\Documents\\LTSketchbook\\libraries\\SparkFun_MS5803-14BA_Pressure_Sensor\\src" "C:\\Users\\Greg\\AppData\\Local\\Temp\\arduino_build_543485\\sketch\\P-TESTER-V2rev2.03.ino.cpp" -o "C:\\Users\\Greg\\AppData\\Local\\Temp\\arduino_build_543485\\sketch\\P-TESTER-V2rev2.03.ino.cpp.o"
In file included from C:\Users\Greg\Documents\LTSketchbook\libraries\MLP-master/MegunoLink.h:6:0,
from C:\Users\Greg\Desktop\P-TESTER-V2\P_TESTER-V2.2\FIRMWARE 2.03\P-TESTER-V2rev2.03\P-TESTER-V2rev2.03.ino:1:
C:\Users\Greg\Documents\LTSketchbook\libraries\MLP-master/utility/TimePlot.h:90:50: error: 'tm' has not been declared
void SetCursorPosition(const char* SeriesName, tm &Time);
^~
C:\Users\Greg\Documents\LTSketchbook\libraries\MLP-master/utility/TimePlot.h:91:65: error: 'tm' has not been declared
void SetCursorPosition(const __FlashStringHelper* SeriesName, tm& Time);
^~
Using library MLP-master at version 1.30 in folder: C:\Users\Greg\Documents\LTSketchbook\libraries\MLP-master
Using library Time-master at version 1.5 in folder: C:\Users\Greg\Documents\LTSketchbook\libraries\Time-master
Using library Wire at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire
Using library SparkFun_MS5803-14BA_Pressure_Sensor at version 1.1.2 in folder: C:\Users\Greg\Documents\LTSketchbook\libraries\SparkFun_MS5803-14BA_Pressure_Sensor
exit status 1
Error compiling for board Arduino Pro or Pro Mini.