Show Posts
Pages: [1] 2 3 ... 8
1  Using Arduino / Displays / New arduino TFT vs adafruit 1.8" TFT vs eBay clone of adafruit TFT on: May 25, 2013, 08:56:31 am
All of these seem to be based on the ST7735R.
They have very similar wiring.  See this ref: http://webshed.org/wiki/18tftbreakout
The screens are all about the same size (might actually be the same)
Header arrangement on the arduino version seems to be much better for hooking onto arduino easier.
The adafruit one and the arduino one are actually probably lead free.  The eBay one not so much.
The arduino version and the adafruit version have a PWM dimable backlight...I don't think the others do this.
All three have a micro ad slot.

Will the new arduino TFT library work with the adafruit and the eBay device? 
What advantage does the arduino libs have over the adafruit ones? Is it just that they are more processing like?

(I ask all of this because I once had a project that used the liquid ware touchscreens.  Communicating with them was always an issue for me.  These screens are worlds cheaper and seem very straightforward to communicate with.)
2  Using Arduino / Displays / Re: issue with touschshield slide comms (showing reading then 0 then reading...etc) on: February 16, 2011, 09:47:56 pm
Ok, so i made the code much more simple and now the arduino just gets the values from the sensors via analog read sends those integers straight to the touchshield.

To debug I'm just displaying the those raw 0-1024 values and i'm getting the following behaviors:

-The values change rapidly between multiple values in a large(ish) range.
-That range seems to propogate through all the sensor with exactly the same values.
-They all show a peak of 912.

So, is addressing sensor values like this not working:
Code:
if (Sensor.available()){
    int value;
    value = Sensor.read();
    if (strcmp(Sensor.getName(), "x")) { 
        //accelx = getAccelerometerData(value)/100; //get the sensor value
        accelx = value;
        if ((accelx > x_peak_pos) && (accelx > 0)){
          x_peak_pos = accelx;
        }
        if ((accelx < x_peak_neg) && (accelx < 0)){
          x_peak_neg = accelx;
        }
        print_values_x();
        //draw_bars_x();
      }
      if (strcmp(Sensor.getName(), "y")) { 
        //accely = getAccelerometerData(value)/100; //get the sensor value
        accely = value;
        if ((accely > y_peak_pos) && (accely > 0)){
          y_peak_pos = accely;
        }
        if ((accely < y_peak_neg) && (accely < 0)){
          y_peak_neg = accely;
        }       
        print_values_y();
        //draw_bars_y();
      }
      if (strcmp(Sensor.getName(), "t1")) { 
        //temp1 = lookup_temp(value); //get the sensor value
        temp1 = value;
        if (temp1 > peak_temp1){
          peak_temp1 = temp1;
        }
        print_values_t1();
        //draw_bars_t1();
      }
      if (strcmp(Sensor.getName(), "t2")) { 
        //temp2 = lookup_temp(value); //get the sensor value
        temp2=value;
        if (temp2 > peak_temp2){
          peak_temp2 = temp2;
        }
        print_values_t2();
        //draw_bars_t2();
      }
      if (strcmp(Sensor.getName(), "bt")){
        //boost = lookup_boost(value);
        boost=value;
        if (boost > peak_boost){
          peak_boost = boost;
        }
        print_values_boost();
        //draw_bars_boost();
      } 
  }
3  Using Arduino / Displays / Re: issue with touschshield slide comms (showing reading then 0 then reading...etc) on: February 15, 2011, 10:58:50 pm
Wait... Small epiphany here.

Can I send a float through Sensor.print and expect it to reassembled the float on the other end or should I break it up into small chunks and reassemble them on the other end (ala the famous scooter computer)?
4  Using Arduino / Displays / Re: issue with touschshield slide comms (showing reading then 0 then reading...etc) on: February 15, 2011, 10:22:47 pm
Code:
#include <HardwareSensor.h>
//writen for the touchshield slide
//draws current/peak and a bar graph for:
//  x
//  y
//  bst
//  IC F
//  Turbo F

//debug notes:
//showing max then 0 then max then 0?? with no sensors plugged in and with sensors pluggedin
//shows value then 0 then value...
////comms issue - getting sent 0 and then getting sent real value (arduino code fix)
////comms issue - packing 0 into the var that is getting sent out (arduino code)
////comms error - between checking which sensor it is and then grabbing that value there is an error
////   but the buffer should aready have that value
//with sensors plugged in:
//boost 35 or 32 (not sure why...suspect missing something or other)
///boost also looks like it is matching the t2 output for some odd reason...even with no sensor present
//x and y both at 0
//t1 and t2 are working in their full range (warm hand test)

float boost = 0;
float temp1 = 0;
float temp2 = 0;
float accelx = 0, accely = 0;
float o_x = 160;
float o_y = 160;
float x_peak_neg = 0;
float x_peak_pos = 0;
float y_peak_neg = 0;
float y_peak_pos = 0;
float peak_boost = 0;
float peak_temp1 = 0;
float peak_temp2 = 0;
float o_boost = 0;
float o_temp1 = 0;
float o_temp2 = 0;

int maxBoost = 25;
int maxT1 = 300;
int maxT2 = 300;

int warnBoost = 21;
int warnT1 = 200;
int warnT2 = 200;

int severeBoost = 23;
int severeT1 = 300;
int severeT2 = 300;

void setup(){
  Sensor.begin(19200);
  background(0); //black background
 
  //draw the rectangles and labels
  //-spacing should be 40 pixels tall for each rectangle
  //-all rects start at 50 and go 2xx pixels widen
  //-all rects are 44 high
  fill(0,0,0);
  stroke(255,0,0);
  rect(50,4,220,42);
  rect(50,52,220,42);
  rect(50,100,220,42);
  rect(50,148,220,42);
  rect(50,196,220,42);
 
  //bar labels
  text("boost",8,22,8);
  text("x",20, 52+20,18);
  text("y",20,100+20,18);
  text("t1",14,148+20,18);
  text("t2",14,196+20,18);
 
}

//get the readings from the arduino
void loop(){
  gettouch(); //update the mouse coordinates
  //add section to reset peaks on touch per area

  //change the below section so that it updates in a nicer/more efficient manner
  if (Sensor.available()){
    int value;
    value = Sensor.read();
    if (strcmp(Sensor.getName(), "x")) { 
        accelx = value/100; //get the sensor value
        if ((accelx > x_peak_pos) && (accelx > 0)){
          x_peak_pos = accelx;
        }
        if ((accelx < x_peak_neg) && (accelx < 0)){
          x_peak_neg = accelx;
        }
        print_values_x();
        //draw_bars_x();
      }
      if (strcmp(Sensor.getName(), "y")) { 
        accely = value/100; //get the sensor value
        if ((accely > y_peak_pos) && (accely > 0)){
          y_peak_pos = accely;
        }
        if ((accely < y_peak_neg) && (accely < 0)){
          y_peak_neg = accely;
        }       
        print_values_y();
        //draw_bars_y();
      }
      if (strcmp(Sensor.getName(), "t1")) { 
        temp1 = value; //get the sensor value
        if (temp1 > peak_temp1){
          peak_temp1 = temp1;
        }
        print_values_t1();
        //draw_bars_t1();
      }
      if (strcmp(Sensor.getName(), "t2")) { 
        temp2 = value; //get the sensor value
        if (temp2 > peak_temp2){
          peak_temp2 = temp2;
        }
        print_values_t2();
        //draw_bars_t2();
      }
      if (strcmp(Sensor.getName(), "bt")){
        boost = value;
        if (boost > peak_boost){
          peak_boost = boost;
        }
        print_values_boost();
        //draw_bars_boost();
      } 
  }
    //for debuging the display without the comms stuff/without sensors
    /*boost = boost + random(2);
    accelx = accelx + .01;
    accely = accely + .01;
    temp1 = temp1 + random(2);
    temp2 = temp2 + random(2); */
   
    //avoid flicker as much as possible by only redrawing when there is a change
    //skip the accel readings because they will jump all over the place anyways?
    o_boost = boost;
    o_temp1 = temp1;
    o_temp2 = temp2;
    o_x = abs(accelx);
    o_y = abs(accely);
}


//TODO split this into many functions
void print_values_boost(){
  fill(0,0,0);
  stroke(0,255,255); //light blue
  //current
  text(boost,274,4+6);
  //peak
  text(peak_boost,274,30);
 }

 void print_values_x(){
  fill(0,0,0);
  stroke(0,255,255); //light blue
  text(accelx,274,52+6);
  text(x_peak_pos,274,52+20);
  text(x_peak_neg,274,52+30);
 }

 void print_values_y(){
  fill(0,0,0);
  stroke(0,255,255); //light blue
  text(accely,274,100+6);
  text(y_peak_pos,274,100+20);
  text(y_peak_neg,274,100+30);
 }

 void print_values_t1(){
  fill(0,0,0);
  stroke(0,255,255); //light blue
  text(temp1,274,148+6);
  text(peak_temp2,274,196+26);
 }

 void print_values_t2(){
  fill(0,0,0);
  stroke(0,255,255); //light blue
  text(temp2,274,196+6);
  text(peak_temp1,274,148+26); 
}

void draw_bars_boost(){
  float twidth=0;
  //boost
  if(boost != o_boost){
    fill(0,255,0); //green
    stroke(0,255,0);
    if (boost > warnBoost){
      fill(255,255,0);
      stroke(255,255,0);
    }
    if (boost > severeBoost){
      fill(255,0,0);
      stroke(255,0,0);
    }
    twidth=218/maxBoost*boost;
    rect(51,5,twidth,40);
    if (o_boost >= boost){
      stroke(0,0,0);
      fill(0,0,0);
      rect(twidth+1+51,5,218-twidth,40);
    }
  }
 }


  //x and y will be displayed as positive only (absolute value) in the bar graph
  //they will be light blue and have no warning/severe values

void draw_bars_x(){
  //x
  float twidth=0;
  fill(0,255,255); //light blue
  stroke(0,255,255);
  twidth = 218/200*abs(accelx*100);
  rect(51,53,twidth,40);
  if(o_x >= abs(accelx)){
    stroke(0,0,0);
    fill(0,0,0);
    rect(twidth+1+51,53,218-twidth-1,40);
  }
}
 
 void draw_bars_y(){
  //y
  float twidth=0;
  fill(0,255,255); //light blue
  stroke(0,255,255);
  twidth=218/200*abs(accely*100);
  rect(51,101,twidth,40);
  if (o_y >= abs(accely)){
    stroke(0,0,0);
    fill(0,0,0);
    rect(twidth+1+51,101,218-twidth-1,40);
  }
 }
 
void draw_bars_t1(){
  //t1
  float twidth=0;
  if (temp1 != o_temp1){
    fill(0,255,0); //green
    stroke(0,255,0);
    if (temp1 > warnT1){
      fill(255,255,0);
      stroke(255,255,0);
    }
    if (temp1 > severeT1){
      fill(255,0,0);
      stroke(255,0,0);
    }
    twidth = temp1;
    rect(51,149,twidth,40);
    if (o_temp1 >= temp1){
      stroke(0,0,0);
      fill(0,0,0);
      rect(twidth+1+51,149,218-twidth,40);
    }
  }
 }

  void draw_bars_t2(){
  //t2
  float twidth=0;
  if (temp2 != o_temp2){
    fill(0,255,0); //green
    stroke(0,255,0);
        if (temp2 > warnT2){
      fill(255,255,0);
      stroke(255,255,0);
    }
    if (temp2 > severeT2){
      fill(255,0,0);
      stroke(255,0,0);
    }
    twidth = temp2;
    rect(51,197,twidth,40);
    if (o_temp2 >= temp2){
      stroke(0,0,0);
      fill(0,0,0);
      rect(twidth+1+51,197,218-twidth,40);
    }
  }
}

5  Using Arduino / Displays / issue with touschshield slide comms (showing reading then 0 then reading...etc) on: February 15, 2011, 10:22:31 pm
I've been back and forth with this project and have "given up" a number of times...

Now I'm back and have a specific issue that is holding things up.  Communications between the arduino and the touchshield is unreliable with my code.  Currently the sensors that work flash between the current reading and 0.  I'm not sure why.

Here is the background info on the project: http://code.google.com/p/robotmeter/
This version of the code is a suite of bar graphs and print outs of the sensor readings.

Code:
//code for arduino to use with touchshield and other programs
//pulls data from sensors and reports it across serial based on a handshake

#include <HardwareSensor.h>
#include <Wire.h>

int xval = 4;
int yval = 5;
int zerogy = 512;
int zerogx = 512;

int t1pin = 2;
int t2pin = 3;
int boostPin = 1;

float boost;
float t1;
float t2;
float x;
float y;


void setup(){
  //setup connection to tsshield
  Sensor.begin(19200);
  zeroAccelerometer();
}

void zeroAccelerometer(){
  //zero the accelerometer on startup
  int tempreading = analogRead(yval);
  if ((tempreading < 800) && (tempreading > 200)){
    zerogy = tempreading;
  }
  else {
    zerogy = 512;
  }
  tempreading = analogRead(xval);
  if (true) {
    zerogx = tempreading;
  }
  else {
    zerogx = 512;
  }
}

void loop (){
  //listen for queries from tsshield

  //boost = lookup_boost(analogRead(boostPin));
  boost = lookup_boost(analogRead(boostPin));
  t1 = lookup_temp(analogRead(t1pin));
  t2 = lookup_temp(analogRead(t2pin));
  x = getAccelerometerData(xval);
  y = getAccelerometerData(yval);
  Sensor.print("x", x);
  Sensor.print("y", y);
  Sensor.print("t1", t1);
  Sensor.print("t2", t2);
  Sensor.print("bt", boost);
}


//correctly changed for float values
float lookup_boost(int boost){
  //boost = ( (boost-106000) / 259000 );
  // boost = ( (( boost * 398) / 1000) + 2); //2 is the y intercept
  //398 changed to 378 for slope...because slope was too steep
  float fboost = ( (( (float)boost * 378.0) / 1000.0) - 4.0)/10.0; //divide by 10.0 when adding decimals on the display code
  return fboost;
}

//correctly converted to float values
float lookup_temp(int tval){
  float ftval = (float)tval;
  if (tval < 89){
    return (999.9);
  }
  if (tval > 960){
    return (0.0);
  }
  if ((tval <= 960)&&(tval > 932)){
    return (((ftval-1015.77))/(-1.72));
  }
  if ((tval <= 932)&&(tval > 896)){
    return (((ftval-1042.01))/(-2.26));
  }
  if ((tval <= 896)&&(tval > 851)){
    return (((ftval-1077.38))/(-2.80));
  }
  if ((tval <= 851)&&(tval > 791)){
    return (((ftval-1122.64))/(-3.35));
  }
  if ((tval <= 791)&&(tval > 707)){
    return (((ftval-1175.88))/(-3.88));
  }
  if ((tval <= 707)&&(tval > 624)){
    return (((ftval-1214.41))/(-4.21));
  }
  if ((tval <= 624)&&(tval > 532)){
    return (((ftval-1223.67))/(-4.28));
  }
  if ((tval <= 532)&&(tval > 437)){
    return (((ftval-1186.51))/(-4.05));
  }
  if ((tval <= 437)&&(tval > 364)){
    return (((ftval-1113.49))/(-3.66));
  }
  if ((tval <= 364)&&(tval > 306)){
    return (((ftval-1022.32))/(-3.21));
  }
  if ((tval <= 306)&&(tval > 248)){
    return (((ftval-90.78))/(-2.70));
  }
  if ((tval <= 248)&&(tval > 200)){
    return (((ftval-785.75))/(-2.20));
  }
  if ((tval <= 200)&&(tval > 158)){
    return (((ftval-665.07))/(-1.75));
  }
  if ((tval <= 158)&&(tval > 123)){
    return (((ftval-553.00))/(-1.37));
  }
  if ((tval <= 123)&&(tval > 90)){
    return (((ftval-417.52))/(-.94));
  }
}

//correctly converted to use float values
float getAccelerometerData (int axis){
  int zerog = 512;
  if (axis == 4){
    zerog = zerogx;
  }  
  if (axis == 5){
    zerog = zerogy;
  }

  int rc = analogRead(axis);
  int top =( (zerog - rc) ) ;
  float frtrn = ((float)top/(float)158);  //158Vint jumps are 1g for the ADXL213AE (original accel)
  //154Vint jumps are 1g for the ADXL322 (updated one)
  return frtrn;
}


6  Forum 2005-2010 (read only) / Syntax & Programs / Re: Thermistor readings... use lookup table? on: July 19, 2007, 09:42:32 pm
openoffice calc doesn't have an equation solving function like excel does.  This is why I'm taking the stuff and importing it into the OS X grapher.  Its working but it's relatively slow.
7  Forum 2005-2010 (read only) / Syntax & Programs / Re: Thermistor readings... use lookup table? on: July 19, 2007, 09:22:33 pm
No clue why the poll was added.

I am recalculating everything right now.  I think a 470 Ohm resistor might be the best choice for temp range i selected.

I started calculating the lines i'll interpolate from.  Not having excel is a pain...this graphing program on os x is really basic and unwieldy.
8  Forum 2005-2010 (read only) / Syntax & Programs / Re: Thermistor readings... use lookup table? on: July 18, 2007, 08:07:11 am
So by adding:

#include <avr/pgmspace.h>
and "PROGMEM"

This person was able to use the flash as memory for a constant.  Cool.
I may have to do the same sort of thing for a oil temp sender/sensor as well so this works out nicely.

The only concern I have with this is how much space the pgmspace.h takes up.  I guess if it is an issue I could always modify pgmspace.h to be smaller.

Currently the sketch uses about 10k of 14k available.
9  Forum 2005-2010 (read only) / Syntax & Programs / Re: Thermistor readings... use lookup table? on: July 18, 2007, 07:08:51 am
I was all set to implement the interpolation style solution you suggested.  However, I figured out the y=mx+b line formula for the first segment and it comes out to something with m or b of 2.033e10 something or other that has to be expressed in scientific notation.  This is a non-starter as we all know that it is difficult to do decimal numbers...especially ones that require scientific notation to state, on the arduino.  

Maybe I'll try to fit some exponential curves or something.  Maybe the os x graphic program isn't all that good.  I also tried open office calc but that doesn't solve for equations.  
10  Forum 2005-2010 (read only) / Syntax & Programs / Re: Thermistor readings... use lookup table? on: July 17, 2007, 08:04:59 pm
Apparently there is an upper bound for array size.  Apparently, I've reached it ;D

I couldn't figure out why my sketch wasn't running.  Then I commented out the lookup table and voila it works.  I guess I'll use your interpolation idea.
11  Forum 2005-2010 (read only) / Syntax & Programs / Re: Thermistor readings... use lookup table? on: July 17, 2007, 06:47:13 pm
Oh, I wasn't doing interpolation.  I was doing thresholds.  So if the voltage read by analogRead is between a and b then the temp is c.  So you are taking, say, 30-40 degrees and mapping those to some linear equation then mapping 40-50 (or whatever it is) to another linear equation?
12  Forum 2005-2010 (read only) / Syntax & Programs / Re: Thermistor readings... use lookup table? on: July 17, 2007, 11:14:38 am
I went with almost exactly what you did.  Lookup table.  Its only 318 integers in an array.  

BTW I'm going to probably have to use your car power supply protection circuit from that other thread.

If anyone is interested in my project it's all document (all ramblings, etc....might want to read it back to front) here: http://www.iwsti.com/forums/showthread.php?t=84794
13  Forum 2005-2010 (read only) / Syntax & Programs / Re: Thermistor readings... use lookup table? on: July 15, 2007, 09:24:18 pm
No "mothership" in this project.  Everything is sent directly from the arduino to a 16x2 serial display.  It's a standalone unit.

All the temp values are to be read by human beings so they should show up a degC or degF values.  logarithmic arithmetic is way too difficult to do on the chip itself so I will be using lookup tables.
14  Forum 2005-2010 (read only) / Syntax & Programs / Thermistor readings... use lookup table? on: July 11, 2007, 11:53:10 am
I'm going to be using a couple of thermistors to do wide range (32F - 350F) temperature readings.  The thermistor is going to be in a voltage gate so i can get analog voltage readings from it.  The problem with a  thermistor is that its resistance in relation to temperature does not change in a linear fashion.  Rather, it is a curve that is defined by a complicated formula (Steinhart Hart equation).  Unfortunately this equation makes use "ln()", which is something that is very difficult/slow to implement on the arduino.

So I have two options...
1) Make a lookup table with these values.  
2) Fit exponential curves to portions of the curve.  Select the curve based on the inputs.

Currently I'm leaning towards #1.  I would have a 2x318 array that would contain these values.  That would take up approx 2 * 2 * 318 = 1272 bytes.  That's not very good.  Plus I haven't really figured out how i'm going to search for them.  A loop with if-then's doesn't sounds very fast.
15  Forum 2005-2010 (read only) / Syntax & Programs / Re: millis does not stop. on: July 11, 2007, 11:54:59 am
Yeah, you are probably getting rounding errors and just not seeing them.  Converting from one type to the other can be tricky in any language.  Be sure to use unsigned longs throughout when comparing with millis() as that is what it returns.
Pages: [1] 2 3 ... 8