This code allows you to graph the 6 analog inputs of Arduino in real time and to analyse all the information after the acquisition.
You can review all the graphics with a Range Bar, wich allows you to zoom in and zoom out in time, and you can know the specific value of any part of the graphic just positioning the mouse over it. Also shows the maximum of each of the inputs and there is a clock that shows the acquisition time of each value.
Arduino is programmed to take 17 samples per sec approximately, but it can take up to 130 sampels per second if you delete the delay() function.
With 17 Sampels per second the program can store up to 8 hours of measurement, but if you need more you can increase the maxSize parameter of the cVectors objects at the beginning of the code.
The winSize parameter defines the speed the graphic moves.
You can also change the Grid of the screen, just modify the gx and gy variables inside the Grilla class..
You can save all the data in a .csv file just pressing on "GUARDAR"
The buttons are in Spanish because I am Argentinian, and my grammar errors are because of the same
Its done on a mac so you might have to check the serial port before running it on a PC..
Hope you enjoy it!
Here is an screen shot of the application running.
int maxSize=mps*3600*8; //tamaño maximo del vector (3600seg = 1h) seteado en 8hs
int winSize=200; //cantidad de muestras que se grafican en la ventana
int posicionInicial; //posicion inicial del vector ai# que se grafica en pantalla cuando no se esta monitoreando, responde a LowValue de la barra Range
int posicionFinal; //posicion inicial del vector ai# que se grafica en pantalla cuando no se esta monitoreando, responde a HighValue de la barra Range
//Máximos de cada vector para la funcion fMaximo
float max0=0;
float max1=0;
float max2=0;
float max3=0;
float max4=0;
float max5=0;
String[] t1 = new String[maxSize]; //Vector que contiene el tiempo
int i=0; //Contador para el vector de tiempo
boolean monitorear=false; //boolean para activar o desactivar la entrada de datos al vector ai#
//vectores para cada señal
cVector ai0 = new cVector(maxSize, winSize);
cVector ai1 = new cVector(maxSize, winSize);
cVector ai2 = new cVector(maxSize, winSize);
cVector ai3 = new cVector(maxSize, winSize);
cVector ai4 = new cVector(maxSize, winSize);
cVector ai5 = new cVector(maxSize, winSize);
//areas de grafico para cada vector
cGrafico g0 = new cGrafico(bordeIzq, bordeTecho+0*(sizey-bordeVertical)/6, sizex-bordeLateral, (sizey-bordeVertical)/6);
cGrafico g1 = new cGrafico(bordeIzq, bordeTecho+1*(sizey-bordeVertical)/6, sizex-bordeLateral, (sizey-bordeVertical)/6);
cGrafico g2 = new cGrafico(bordeIzq, bordeTecho+2*(sizey-bordeVertical)/6, sizex-bordeLateral, (sizey-bordeVertical)/6);
cGrafico g3 = new cGrafico(bordeIzq, bordeTecho+3*(sizey-bordeVertical)/6, sizex-bordeLateral, (sizey-bordeVertical)/6);
cGrafico g4 = new cGrafico(bordeIzq, bordeTecho+4*(sizey-bordeVertical)/6, sizex-bordeLateral, (sizey-bordeVertical)/6);
cGrafico g5 = new cGrafico(bordeIzq, bordeTecho+5*(sizey-bordeVertical)/6, sizex-bordeLateral, (sizey-bordeVertical)/6);
//grilla del grafico
cGrilla grilla = new cGrilla();
//declaracion de instancias de clases
ControlP5 cp5;
Serial arduino;
Range range;
ControlTimer c;
Textlabel t;
void setup()
{
size(sizex, sizey, P2D);
background(150);
println(Serial.list()); //imprime lista de puertos seriales disponibles
arduino = new Serial(this, Serial.list()[0], 115200, 'N', 8, 1.0); //se crea el objeto Serial