We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Trying to create a temperature profiler with UI
Pages: 1 2 
Trying to create a temperature profiler with UI (Read 3561 times)
Trying to create a temperature profiler with UI
Aug 7th, 2009, 9:50am
 
Hello, new here and to processing in general.  I'm trying to figure out if proccessing is able to help me with this project.  
I'm using an Arduino with 2 temp probes.
I would like to create a window displaying a large graph, plotting the temps according to time.  Temp from 0*f to 500*F, time from 0 to 20 mins.  I would also like 4 other boxes in the window.

1. Elapsed time
2. Temp A - from analog(0) - to be shown on graph
3. Temp B - from analog(1) - to be shown on graph
4. start/stop "button" that starts and stops the graph and timer.

Does this sound like a job processing can do?  Sorry, I'm a complete rookie with this stuff but would love to learn.
Any advice on where to start?
Thanks for your help.
Re: Trying to create a temperature profiler with UI
Reply #1 - Aug 13th, 2009, 6:07pm
 
I'm surprised no one has yet replied. I'm also very, very new to processing: I'm working through my first application, which is very similar to your application. I've wired up two MAX6675s to an Arduino and I'm reading temperatures from them every second. I graph those temps and display them numerically on the window. I haven't implemented your number 4, but I want to soon.

Like I said, I'm a total n00b at processing and not much of a coder, so my code is a disaster (totally inefficient. Maybe someday I'll clean it up? Probably not). But I'll post it soon, if you like.

-brett
Re: Trying to create a temperature profiler with UI
Reply #2 - Aug 13th, 2009, 7:13pm
 
Hi,
no experience with arduino here, but once you get your values coming in and being read, my advice for the plotting is:

1.  count time with millis(), which returns the milliseconds the program's been running, and an int representing the time interval between points, say "timeStep" for example...you also need an int representing the last time grabbed, say "previousGrabTime."
so:
int timeStep = 1000; // ~1 sec, for example
int previousGrabTime=0;

2. Set up two arrays of floats to store your temperature data, say tempValsA and tempValsB.  They have a finite length and you have to be careful not to exceed whatever you set...initialize them like this:
float[] tempValsA = new float[numberOfGraphPoints];
float[] tempValsB = new float[numberOfGraphPoints];
^ all of this goes outside your setup and draw loops, so they are global variables.  You'll also need a "currentPoint" int, starting at 0.  (int currentPoint = 0)

set up your screen size and so forth, e.g.:
void setup(){
  size(640,480);
  background(255);
}

3. in draw, say:
if (currentPoint< numberOfGraphPoints){ // don't exceed your arrays
  if (millis() - previousGrabTime>=timeStep){ // if it's time to grab
  // grab the values for A and B
  // store them in the two float[] arrays
  tempValsA[currentPoint]=[theGrabbedDataA];
  tempValsB[currentPoint]=[theGrabbedDataB];
  // previousGrabTime = millis(); // reset the wait time
 currentPoint++; // add 1 to the current point
  }
}
else plot(); // currentPoint exceeds array length, time to plot:

3. plotting:
once you have two float[] arrays full of data, you need a script to run through them and put points or lines on the screen:
for (int a=0; a<tempValsA.length; a++){
 point(a, tempValsA[a]);
}
^ this says "the x coordinate of the point is its position in time, and the y coordinate is its temperature value.
For lines, just make a variable to store the last two points, and make each line connect the previous (x,y) with the current (x,y).

To get fancy and scale it to the window, change that to:
point(a*tempValsA.length/width, tempValsA[a]*maxTemp/height);
^ where maxTemp allows for the highest you reasonably expect...
and then the same for the B line, maybe with a different fill color, or stroke color for lines.

I think this will get you started...feel free to post progress or pm me.
Oh and -- you might get more answers in the questions forum (rather than exhibition).

Ben
Re: Trying to create a temperature profiler with UI
Reply #3 - Aug 14th, 2009, 9:30am
 
My first draft of code. I've since added file recording, and text display of the two temperatures among other things. But that code isn't quite ready yet, this at least runs without bugs. I should make a subroutine for processing each temp rather than doing it twice, I know:

Code:
// Graphing sketch

// This program takes two ASCII-encoded temperatures
// from the serial port at 9600 baud and graphs them. It expects values in the
// range 0 to 100, separated by a comma and space followed by a newline

// Based on code by Tom Igoe
// Updated July 2009 by Brett Heliker

import processing.serial.*;

Serial myPort;        // The serial port
int xPosTop = 10;         // horizontal position of the graph
int xPosBot = 10;         // horizontal position of the graph
float rcolor = 0.0;  
float gcolor = 230.0;    
float bcolor = 0.0;
float maxTemp = 62.0;
float minTemp = 58.0;
PFont font;


void setup () {
 // set the window size (w,h)
 size(1000, 600);
 
 font = loadFont("HelveticaNeue-23.vlw");
 textFont(font);
 // Open the port you're using.
 myPort = new Serial(this, Serial.list()[0], 9600);
 
 // don't generate a serialEvent() unless you get a newline character:
 myPort.bufferUntil('\n');
 
 // set inital background:
 background(0);
}
void draw () {
 // everything happens in the serialEvent()
}

void serialEvent (Serial myPort) {
 // get the ASCII string:
 String inTemp0 = myPort.readStringUntil(32);
 String inTemp1 = myPort.readStringUntil('\n');

 if (inTemp0 != null) {
   // trim off any whitespace:
   inTemp0 = trim(inTemp0);
   // convert to an int and set colors

   float inByte0 = float(inTemp0);
   

   if (inByte0 < minTemp) {
     bcolor = 230;
     gcolor = 0.0;
     rcolor = 0.0;
   } else if (inByte0 > maxTemp) {
     rcolor = 230;
     gcolor = 0.0;
     bcolor = 0.0;
   } else {  
     gcolor = 230.0;    
     rcolor = 0.0;
     bcolor = 0.0;
   }
     
   // map to half screen height:
   inByte0 = map(inByte0, 0, 100, 0, height/2);

   // draw the line, halfway up the screen. The color code should make it Green when the
   // Temperature is around 60 (as desired for a boil), blue when too cold
   // and red when too hot.
   
   stroke(rcolor,gcolor,bcolor);
   line(xPosTop, height/2, xPosTop, height/2 - inByte0);

   fill(0);
   rect(12, 8, 63, 26);

   fill(rcolor, gcolor, bcolor);
   text(inTemp0, 15, 30);

   
   // at the edge of the screen, go back to the beginning:
   if (xPosTop >= width) {
     xPosTop = 0;
     background(0);
   }
   else {
     // increment the horizontal position:
     xPosTop++;
   }
 }
 
 
 if (inTemp1 != null) {
   // trim off any whitespace:
   inTemp1 = trim(inTemp1);
   // convert to an int and set colors
   float inByte1 = float(inTemp1);
   
   if (inByte1 < minTemp) {
     bcolor = 230;
     gcolor = 0.0;
     rcolor = 0.0;
   } else if (inByte1 > maxTemp) {
     rcolor = 230;
     gcolor = 0.0;
     bcolor = 0.0;
   } else {  
     gcolor = 230.0;    
     rcolor = 0.0;
     bcolor = 0.0;
   }
     
   
   // map to half screen height:
   inByte1 = map(inByte1, 0, 100, 0, height/2);

   // draw the line at the bottom of the screen. The color code should make it Green when the
   // Temperature is around 60 (as desired for a boil), blue when too cold
   // and red when too hot.
   
   stroke(rcolor,gcolor,bcolor);
   line(xPosBot, height, xPosBot, height - inByte1);

   fill(0);
   rect(12, height/2+8, 63, 26);

   fill(rcolor, gcolor, bcolor);
   text(inTemp1, 15, height/2+30);

   
   // at the edge of the screen, go back to the beginning:
   if (xPosBot >= width) {
     xPosBot = 0;
     background(0);
   }
   else {
     // increment the horizontal position:
     xPosBot++;
   }
 }
}
Re: Trying to create a temperature profiler with UI
Reply #4 - Aug 16th, 2009, 2:39pm
 
sorry I haven't checked this thread in a while.

here is my Arduino code to read the two temps.
Code:
//declare variables
float tempC;
float tempB;
float tempD;
float tempE;
int beanPin = 0;
int envPin = 1;

void setup()
{
Serial.begin(9600); //opens serial port, sets data rate to 9600 bps
}

void loop()
{
tempD = analogRead(beanPin); //read the value from bean sensor
tempE = analogRead(envPin); //read value from environment sensor
tempC = (5.0 * tempD * 100.0)/1024.0; //convert bean analog data to temperature
tempB = (5.0 * tempE * 100.0)/1024.0; //convert env analog data to temp
Serial.print((byte)tempC); //send the data to the computer
Serial.print((byte)tempB);
delay(1000); //wait one second before sending new data
}



Re: Trying to create a temperature profiler with UI
Reply #5 - Aug 16th, 2009, 2:42pm
 
And here is my sketch I'm working on.
I haven't done any work on the graph yet, but any advice is much appreciated.
I'm sure there are easier ways and clean ways to do many of these functions.  But I've just started to use processing.

Code:
//import Serial communication library
import processing.serial.*;

//init variables
int startSECOND, startMINUTE, startTOTAL;
int stopSECOND, stopMINUTE, stopTOTAL;
int dis_m, dis_s;
boolean startcount = false;
Serial commPort;
float tempC;
float tempF;
float tempB;
float tempEnvF;
PFont font12;
PFont font24;
PFont font18;
PFont font7;
PFont font10;

void setup()
{
 //setup fonts for use throughout the application
 font12 = loadFont("Verdana-12.vlw");
 font24 = loadFont("Verdana-24.vlw");
 font18 = loadFont("Verdana-18.vlw");
 font7 = loadFont("Verdana-7.vlw");
 font10 = loadFont("Verdana-10.vlw");
 //set the size of the window
 size(680, 600);
 
 //init serial communication port
 commPort = new Serial(this, Serial.list()[1], 9600);
}

void draw()
{

 //get the temp from the serial port
 while (commPort.available() > 0)
 {
   tempC = commPort.read();
   tempB = commPort.read();
 
   //refresh the background to clear old data
   background(#7683b4);
 
   
   //draw graph
   stroke(0);             //graph is 375 pixels high - 1 px for each degree
   fill(255,255,255);     // of F from 225 F to 500F
   rect(30,145,500,375);  //graph is 500pixels wide - 25 pixels for each
                          //minute, from 0 to 20 minutes
   
   
         
 
    //write reference values for temp
   
   fill(0,0,0);
   textFont(font7);
   textAlign(RIGHT);
   text("500 F", 28, 145);
   line(28,145,29,145);      
   
   text("475 F",28,170);
   line(28,170,29,170);
   
   text("450 F",28,195);
   line(28,195,29,195);
   
   text("425 F",28,220);
   line(28,220,29,220);
   
   text("400 F",28, 245);
   line(28,245,29,245);
   
   text("375 F",28, 270);
   line(28,270,29,270);
     
   
   text("350 F",28, 295);
   line(28,295,29,295);
   
 
   text("325 F",28, 320);
   line(28,320,29,320);
   
   
   text("300 F",28, 345);
   line(28,345,29,345);
   
   
   text("275 F",28, 370);
   line(28,370,29,370);
   
   
   text("250 F",28, 395);
   line(28,395,29,395);
   
 
   text("225 F",28, 420);
   line(28,420,29,420);
   
   text("200 F",28, 445);
   line(28,445,29,445);
   
   
   text("175 F",28, 470);
   line(28,470,29,470);
   
   
   text("150 F",28, 495);
   line(28,495,29,495);
   
   
   text("125 F",28, 520);
   line(28,520,29,520);
   
   //write time values
    textFont(font10);
    textAlign(RIGHT);
   text("0:00",45,540);
   line(30,520,30,524);
 
   line(55,520,55,522);
   text("2:00",95,540);
   line(80,520,80,524);
   
   line(105,520,105,522);
   text("4:00",145,540);
   line(130,520,130,524);
   
   line(155,520,155,522);
   text("6:00",195,540);
   line(180,520,180,524);
   
   line(205,520,205,522);
   text("8:00",245,540);
   line(230,520,230,524);
   
   line(255,520,255,522);
   text("10:00",295,540);
   line(280,520,280,524);
   
   line(305,520,305,522);
   text("12:00",345,540);
   line(330,520,330,524);
   
   line(355,520,355,522);
   text("14:00",395,540);
   line(380,520,380,524);
   
   line(405,520,405,522);
   text("16:00",445,540);
   line(430,520,430,524);
   
   line(455,520,455,522);
   text("18:00",495,540);
   line(480,520,480,524);
   
   line(505,520,505,522);
   text("20:00",545,540);
   line(530,520,530,524);
 
   
 
 
   
 

   
   //draw boxes for bean,env and stopwatch
   stroke(0);
   fill(255,255,255);
   rect(325,55,80,40);
   rect(425,55,80,40);

   
   //write box titles
   fill(0,0,0);
   textFont(font12);
   textAlign(CENTER);
   text("Bean Temp",362,50);
   text("Env Temp",462,50);
   textFont(font18);
   text("Elapsed Time",590,40);
 
 
   //write the temp in C and F
   fill(0,0,0);
   textFont(font24);
   textAlign(LEFT);
   tempF = ((tempC*9)/5) + 32;
   text(str(int(tempF)) + " F", 348, 85);
   tempEnvF = ((tempB*9)/5) + 32;
   text(str(int(tempEnvF)) + " F", 448,85);
 }

drawbuttons();
if(mousePressed && rectSTART())
{
startSECOND=second();
startMINUTE = minute();
startTOTAL = startMINUTE*60 + startSECOND;
startcount = true;
}

if(mousePressed && rectSTOP())
{
startcount = false;
}

if(mousePressed && rectRESET())
{
 
dis_m = 0;
dis_s = 0;

}

calculate();
display();
}

void drawbuttons()
{
fill(6,203,27);  rect(562,115,50,20); // green start
fill(250,0,17);  rect(562,140,50,20); // red stop
fill(250,122,30);  rect(562,165,50,20); //orange reset

fill(0);
   textFont(font10);  
   textAlign(CENTER);
   text("Start", 588,130);
   text("Stop", 588, 155);
   text("Reset", 588, 180);
}

boolean rectSTART()
{
if(mouseX >= 562 && mouseX <= 612 && mouseY >= 115 && mouseY <= 135) return true;
else return false;
}

boolean rectSTOP()
{
if(mouseX >= 562 &&  mouseX <= 612 && mouseY >= 140 && mouseY <= 160) return true;
else return false;
}

boolean rectRESET()
{
if(mouseX >= 562 && mouseX <= 612 && mouseY >= 165 && mouseY <= 185) return true;
else return false;
}

void calculate()
{
if(startcount)
{
stopMINUTE = minute();
stopSECOND = second();

stopTOTAL = stopMINUTE*60 + stopSECOND;

int diff = stopTOTAL-startTOTAL;
dis_m = diff/60;
dis_s = diff - dis_m*60;
}
}
void display()
{
stroke(0);
   fill(255,255,255);
 rect(538,50,100,60); // stopwatch  
fill(0);
textFont(font24);
textAlign(LEFT);
text(nf(dis_m,2)+":"+nf(dis_s,2),555,88);
}
Re: Trying to create a temperature profiler with UI
Reply #6 - Aug 17th, 2009, 10:26am
 
ben_hem wrote on Aug 13th, 2009, 7:13pm:
Hi,
no experience with arduino here, but once you get your values coming in and being read, my advice for the plotting is:

1.  count time with millis(), which returns the milliseconds the program's been running, and an int representing the time interval between points, say "timeStep" for example...you also need an int representing the last time grabbed, say "previousGrabTime."
so:
int timeStep = 1000; // ~1 sec, for example
int previousGrabTime=0;

2. Set up two arrays of floats to store your temperature data, say tempValsA and tempValsB.  They have a finite length and you have to be careful not to exceed whatever you set...initialize them like this:
float[] tempValsA = new float[numberOfGraphPoints];
float[] tempValsB = new float[numberOfGraphPoints];
^ all of this goes outside your setup and draw loops, so they are global variables.  You'll also need a "currentPoint" int, starting at 0.  (int currentPoint = 0)

set up your screen size and so forth, e.g.:
void setup(){
  size(640,480);
  background(255);
}

3. in draw, say:
if (currentPoint< numberOfGraphPoints){ // don't exceed your arrays
  if (millis() - previousGrabTime>=timeStep){ // if it's time to grab
  // grab the values for A and B
  // store them in the two float[] arrays
  tempValsA[currentPoint]=[theGrabbedDataA];
  tempValsB[currentPoint]=[theGrabbedDataB];
  // previousGrabTime = millis(); // reset the wait time
 currentPoint++; // add 1 to the current point
  }
}
else plot(); // currentPoint exceeds array length, time to plot:

3. plotting:
once you have two float[] arrays full of data, you need a script to run through them and put points or lines on the screen:
for (int a=0; a<tempValsA.length; a++){
 point(a, tempValsA[a]);
}
^ this says "the x coordinate of the point is its position in time, and the y coordinate is its temperature value.
For lines, just make a variable to store the last two points, and make each line connect the previous (x,y) with the current (x,y).

To get fancy and scale it to the window, change that to:
point(a*tempValsA.length/width, tempValsA[a]*maxTemp/height);
^ where maxTemp allows for the highest you reasonably expect...
and then the same for the B line, maybe with a different fill color, or stroke color for lines.

I think this will get you started...feel free to post progress or pm me.
Oh and -- you might get more answers in the questions forum (rather than exhibition).

Ben


Ben, Thanks a lot.  I think this is  a great starting point for me.
A couple questions.
- when you ask for number of graph points.  I have 500 points for time and 375 points for temp.  For the graph in my sketch.
I think I'll try building the graph on a separate sketch before i try to incorporate it into my main one.
so a window (500,375)
-how do I make it that the 500 points represents 20 minutes or 1200 seconds
-how do I make the 375 points represent the temperature
eventually I would like it to read from 125 F to 500 F, but to test it i would like to work with lower temps.

-I also need to learn how to code the line to connect from point to point.  
Basically I have zero knowledge of this and I'm learning as I go.  So if you can send me in the right direction, via a link, that would be appreciated. Or if you're willing to post some ideas.
thanks,
D

Re: Trying to create a temperature profiler with UI
Reply #7 - Aug 17th, 2009, 10:40am
 
for example, in my current sketch my rect() for my graph is (30,145,500,375)

for temperature on the y: each graph point = 1 deg.
high Y = 145
low Y = 520

for time on the x: each minute = 25 graph, points up to 20minutes.  seconds would be 1200/500
lowX (0 minutes) = 30
highX (20 minutes) = 530
Re: Trying to create a temperature profiler with UI
Reply #8 - Aug 17th, 2009, 12:11pm
 
You need to set up your tempVals[] = new temp[500].  The length of the array is what's spanning time, and the values from 1-375 are stored in that array, e.g:
temp[0] = 200.0;
temp[1] = 345.4; // etc...  up to temp[499] = n°

Your window can be any size, as long as you scale the points to your area -- the map() function is your friend there, or use cross-products.

It looks like your tempA, tempB, tempC etc. are not arrays[], but single floats.  So every time you store a value, it overwrites the previous value.

line() takes 4 points, so you need your loop to remember the previous (x,y) or (time,temp) values, and connect them with the current grab.

And if you're using seconds as intervals, you can also call second() or minute().

Hope this helps -- Ben
Re: Trying to create a temperature profiler with UI
Reply #9 - Aug 17th, 2009, 2:01pm
 
yes the temps currently are designed to display only the current temp.

my time frame is 500 graph points.
my temp is 375.

If I want my temp to read from 125 F to 500 F, would it look like this.

tempVal[] = new temp[500]

temp[125] = 520;
temp[126] = 519;
temp[127] = 518; // etc.. up to temp[499] = 144;

basically temp[degree F] = y point on graph?

would I do the same with the time?
i.e. something like this? minutes[0] = 30; up to .. minutes[20] = 530;


I want it to plot every second, but my seconds are less than 1px, since each minute is 25px.  Which is 1200 seconds.  Please tell me I dont have to do the same as temp with [0] seconds to [1200] seconds.

Sorry, I'm still trying to comprehend this.  Just need a little more info for it to sink in.


just did a little research..
would this be accurate in setting up my map.
20 minutes but plotting each second, 1200?
the size of my graph is (500,375)

size(500,375);
float value = 1200; // 1200 seconds
float m = map(value, 30, 530, 30, 530); // 0 seconds at Xval30, 1200
                                                          //seconds at Xval530
Re: Trying to create a temperature profiler with UI
Reply #10 - Aug 17th, 2009, 9:10pm
 
map(value, low1, high1, low2, high2) takes "value" (which doesn't have to be called "value," by the way, that's just a variable placeholder) and maps it from the range (low1 ... high1) to (low2 ... high2).  So first, get a temperature value (could be from 1 to a million if you want) and then, run this on it to get a height that works with your display area:
X = [the position in the array, 0 ... 499]
Y = map(9,435, 1,000,000, 0,300);  // for a value of 9,435 degrees
this will give you an X from 0-499, and a Y from 0-300.  It basically takes the place of saying:
Y = n° * height / maxDegrees;  // a cross-product approach.

You should check out arrays and so forth in the reference, and google some of these terms.  But basically, think of arrays as a book with one item on each page.  The number in brackets is the page number, and is totally independent of what is represented on the page.  So,
TaleOfTwoCities[1] == "It was the best of times..."  etc.
(of course, TaleOfTwoCities is a String[], not a float[]).

So you don't need a second array to represent time.  Time is represented by a number's position in the array ("page number").  If you have 20 minutes divided into 500 positions, or whatever number you want, then at t=0, position==0, and at t=20 mins, position==499.  You just need to grab data at the correct time interval in order for the array to build itself properly (see original reply).
Re: Trying to create a temperature profiler with UI
Reply #11 - Aug 18th, 2009, 10:08am
 
Ok, so I think what is confusing me is the fact that I'm dividing the temperature into 500 increments, which is my time.  That makes sense since I want the temp plotted across only 500 graph points.  Let me know if this is what you're talking about.  If I want my temp to read from 125 F to 500 F.
tempVals[] = new temp [500];
temp[0] = 125;
temp[2] = 125.75;
temp[3] = 126.5; // etc, etc... to temp[499] = 500;

After some brief research on arrays it seems that I'm setting values for each time point, when I don't actually know the values, since it will be read from a thermocouple.  I'm sorry this is taking a while for me to comprehend.  But I feel I'm really close to having it make sense.  thanks for your patience.  
With the 500 graph points, would that mean inside 20 minutes that I'm asking it to plot every 2.4 seconds?  Would I need to change it to new temp [1200] if I want it to plot every second?


for the map, is this the right idea?

map(125,500,520,145);  // temp reading from 125 F at y= 520
                                         // to 500F at y = 145
Re: Trying to create a temperature profiler with UI
Reply #12 - Aug 18th, 2009, 11:27am
 
Right, if you want a value every second, you need 1200 points in your graph, for (20 minutes x 60 seconds).  It sounds like you've got it.  As for reading the values, you only read them when you know them, and plug them into the array, using a loop with variables, instead of calling each point by its index in the array.

The numbers held in the array are the temperatures you're recording from the thermocouple.  That value range doesn't need to be defined at this point.

So, you need a function in your draw() loop to catch the temperature values every 2.4 seconds, or 2400 milliseconds.  Every time the current millis() exceeds the last capture time by at least 2400, it's time to grab the current temperature values from your device and record them in the arrays, then flip the page.  Then reset the "stopwatch" so you can wait another 2.4 seconds.

To continue with the book metaphor (create a book with 500 blank pages, and every 2.4 seconds write the temperature and turn the page) :

if ((millis()-timeOfLastEntry) >= 2400){
 currentTemperature = [doYourGrabStuff];
 BookOfValues[pageNumber] = currentTemperature;
 pageNumber ++; // turn the page.
 timeOfLastEntry = millis(); // reset your stopwatch.
}

For map(), you need 5 values.  The map() entry in the reference describes what each value does, if you scroll down.  The first value is your temperature, the second and third values are your low and high points for the starting range, and the fourth and fifth values are the low and high points in the range you want to translate it to.

By the way, at some point you'll probably want 'up' on your screen to be a higher number, so that the graph is right-side-up.  So when you do the plotting, you'll probably want the Y value of your points to be (height - Y).
Re: Trying to create a temperature profiler with UI
Reply #13 - Aug 18th, 2009, 11:58am
 
great, I definitely want it to plot every second, so I need 1200 lines.
from temp[0] = ??; to temp[1199]=??
will i have to do 2 separate temp values for tempB and tempC ?
(tempB and tempC are whats being read every second from my Arduino)
for example..
with
currentTempB = [tempB];
currentTempC= [tempC];
1 set of 1200 for temp[0]= currentTempB
and another set of 1200 for temp[0] = currentTempC

and to use your code..

if ((millis()-timeOfLastEntry) >= 1000){
currentTempB = [tempB];
temp[0] = currentTempB;
0++; // turn the page.
timeOfLastEntry = millis(); // reset your stopwatch.
}

map(currentTempB,125,500,500,145);

I had no idea I could 'up' my screen.  The problem is, I will have to change my current sketch, 6th post down.  Can it still be done without the 'up'.
Re: Trying to create a temperature profiler with UI
Reply #14 - Aug 18th, 2009, 12:12pm
 
Ok, now that you get arrays, I'd suggest re-reading my first reply.
Think of each set of temperature values as a separate 'book', hence:
float [] tempValsA = new float[1200];
float [] tempValsB = new float[1200];
float [] tempValsC = new float[1200];

An aside: once you're comforatble with this method you might want to look into 2D arrays, which would condense the above into this:
float tempVals[][] = new float [3][1200];

You've done some stuff to that code example that won't work:  currentTemperature = [doYourGrabStuff] doesn't get replaced with a predefined constant -- it gets replaced with the current temperature.
e.g. tempValsA[pageNumber] = analogRead(beanPin);
temp[pageNumber] doesn't get changed to a static value like [0].  pageNumber is intended to be a global int variable, as in my first reply.
On the same note, saying "0++" will always result in 1, because 0 + 1 = 1.  So you need to keep it "pageNumber++" (or whatever you decide to call the "current entry position" variable.

If you reverse the low and high output range in your map() function as you have done, you won't need to flip the Y axis.  Just remember that the point (0,0) in Processing is the upper-left.
Pages: 1 2