Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: Sous Vide Programming help (90% done) on: May 02, 2013, 07:55:04 pm
arrch,

I added some more brackets and the relay works! Thanks for the find

Code:
  if (buffer <= 0) {}
    ...
   { if ( targetTemp > celsius ) {
      digitalWrite(12, LOW);    // set the relay OFF
    }
    else {
      digitalWrite(12, HIGH);   // set the RELAY ON
    }}

Pauls,

     Im not good at code, what is a global variable? Is their an easy way to to change the code to display 1/2 degree increments?
2  Using Arduino / Programming Questions / Re: Sous Vide Programming help (90% done) on: May 02, 2013, 05:17:40 pm
PeterH,
       Is this the right way to use code tag?

Code:
#define THERMISTOR_PIN 1

#include <LiquidCrystal.h>

#define BUFFER_SIZE 2000
#define MIN_BUFFER_SKIP 20
#define MAX_BUFFER_SKIP 100
#define INC_BUFFER_SKIP 5

/**
 * Buffer used to keep track of timing
 */
short buffer = 0, bufferSkip, buttonSkip;
/**
 * Values used for processing
 */
int rawValue, celsius, lastCelsius, fahrenheit, targetTemp, lastKey;

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

// define some values used by the panel and buttons
int lcd_key     = 0;
int adc_key_in  = 0;
#define btnRIGHT  0
#define btnUP     1
#define btnDOWN   2
#define btnLEFT   3
#define btnSELECT 4
#define btnNONE   5

// read the buttons
int read_LCD_buttons()
{
  adc_key_in = analogRead(0);      // read the value from the sensor
  // my buttons when read are centered at these valies: 0, 144, 329, 504, 741
  // we add approx 50 to those values and check to see if we are close
  if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
  if (adc_key_in < 50)   return btnRIGHT; 
  if (adc_key_in < 195)  return btnUP;
  if (adc_key_in < 380)  return btnDOWN;
  if (adc_key_in < 555)  return btnLEFT;
  if (adc_key_in < 790)  return btnSELECT;   
  return btnNONE;  // when all others fail, return this...
}

// EPCOS 100K Thermistor (B57560G1104F)
// Made with createTemperatureLookup.py (http://svn.reprap.org/trunk/reprap/firmware/Arduino/utilities/createTemperatureLookup.py)
// ./createTemperatureLookup.py --r0=100000 --t0=25 --r1=0 --r2=4700 --beta=4092 --max-adc=1023
// r0: 100000
// t0: 25
// r1: 0
// r2: 4700
// beta: 4092
// max adc: 1023
#define NUMTEMPS 20
short temptable[NUMTEMPS][2] = {
  {
    1, 821  }
  ,
  {
    54, 252  }
  ,
  {
    107, 207  }
  ,
  {
    160, 182  }
  ,
  {
    213, 165  }
  ,
  {
    266, 152  }
  ,
  {
    319, 141  }
  ,
  {
    372, 131  }
  ,
  {
    425, 123  }
  ,
  {
    478, 115  }
  ,
  {
    531, 107  }
  ,
  {
    584, 100  }
  ,
  {
    637, 93  }
  ,
  {
    690, 86  }
  ,
  {
    743, 78  }
  ,
  {
    796, 70  }
  ,
  {
    849, 60  }
  ,
  {
    902, 49  }
  ,
  {
    955, 34  }
  ,
  {
    1008, 3  }
};

void setup()
{

  Serial.begin(9600);

  Serial.println("Mark's Sous Vide cooker");

  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);

  // Print a message to the LCD.
  lcd.print("Mark's Sous Vide Cooker");

  pinMode(12, OUTPUT);          // tells arduino RELAY is an output

  // Preset Last Celsius so it will fail the test
  lastCelsius = -1;

  targetTemp = 35;
  bufferSkip = 20;
  lastKey = btnNONE;
  buttonSkip = 0;

  delay(5000);
  lcd.clear();
}



/**
 * Control loop
 * We use the buffer to control the flow of time, so user interaction is preserved.
 * Buffer skip is used to control how time flows, so if there are no user interactions,
 * it will slow down in an attempt to save battery
 */
void loop()
{

  if (buffer <= 0) {

    rawValue = analogRead(THERMISTOR_PIN);
    celsius = read_temp();
    fahrenheit = (((celsius * 9) / 5) + 32);
    // Reset buffer so we skip doing stuff
    buffer = BUFFER_SIZE;

    // Only update LCD if something changed
    if (celsius != lastCelsius) {
      lastCelsius = celsius;

      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Current ");
      lcd.print(celsius);
      lcd.print("C");
      lcd.setCursor(0, 1);
      lcd.print("Target  ");
      lcd.print( targetTemp );
      lcd.print("C");

      Serial.print("Current temp: ");
      Serial.print(celsius);
      Serial.println("C / ");
    }

    if ( targetTemp > celsius ) {
      digitalWrite(12, LOW);    // set the relay OFF
    }
    else {
      digitalWrite(12, HIGH);   // set the RELAY ON
    }

  }

  // This part of code will always run
  {
    // Listen for inputs here

    int buttonPressed = read_LCD_buttons();
    bool pressed = false;


    if (buttonPressed == lastKey) {

      if (buttonPressed == btnNONE) {

      }
      else {
        buttonSkip -= 1;
        if (buttonSkip < 100) {
          buttonSkip = 100;
        }

        if (buttonPressed == btnUP) {
          targetTemp++;
        }
        else if (buttonPressed == btnDOWN) {
          targetTemp--;
        }

        // Bound min.max values
        if (targetTemp < 0) {
          targetTemp = 0;
        }
        else if (targetTemp > 100) {
          targetTemp = 100;
        }
      }
    }
    else {
      buttonSkip = 200;
      lastKey = buttonPressed;
    }

    pressed = lastKey != btnNONE;

    // If there is a button press, we need to update the target temp, and set buffer to 20, so we have instant interaction now
    if (pressed) {
      bufferSkip = buttonSkip;
      buffer = buttonSkip;
    }
    else if (bufferSkip < MAX_BUFFER_SKIP) {
      // Increase the buffer skip until we get to the max
      bufferSkip += INC_BUFFER_SKIP;
      if (bufferSkip > MAX_BUFFER_SKIP) {
        bufferSkip = MAX_BUFFER_SKIP;
      }
    }
    // If the buffer skip is larger then the buffer, we just use buffer to keep timing
    if (buffer < bufferSkip) {
      delay(buffer);
    }
    // Or we just use the skip to control time, like normal
    else {
      delay(bufferSkip);
    }
    // It does not matter if it goes below 0, since we have a check for  <= 0
    buffer -= bufferSkip;
  }

}

/**
 * Read the temp from the sensor
 */
int read_temp() {
  int rawtemp = analogRead(THERMISTOR_PIN),
  current_celsius = 0;

  byte i;
  // I think this should start at 0, this in index positions, right?
  for (i=1; i < NUMTEMPS; i++) {
    if (temptable[i][0] > rawtemp) {
      int realtemp  = temptable[i-1][1] + (rawtemp - temptable[i-1][0]) * (temptable[i][1] - temptable[i-1][1]) / (temptable[i][0] - temptable[i-1][0]);

      if (realtemp > 255) {
        realtemp = 255;
      }

      current_celsius = realtemp;

      break;
    }
  }

  // Overflow: We just clamp to 0 degrees celsius
  if (i == NUMTEMPS) {
    current_celsius = 0;
  }

  return current_celsius;
}
3  Using Arduino / Programming Questions / Re: Sous Vide Programming help (90% done) on: May 01, 2013, 04:30:26 pm
Arrch,
         I really have never written code in my life. I was able to Hack this information together to make it work. What are Code tags, Can you help?
4  Using Arduino / Programming Questions / Sous Vide Programming help (90% done) on: April 30, 2013, 08:45:24 pm
All,
   Over the past month I have been working on building my own sous vide crockpot. After prototyping and making a working model I decided to use better parts to make a small unit. Doing this I ran into some small problems. 90% done with the project, All help is greatly appreciated

Here are the parts I'm currently using:

1) Arduino UNO
2) Sainsmart LCD KEYPAD Shield V1.0
 ( http://www.sainsmart.com/sainsmart-1602-lcd-keypad-shield-for-arduino-duemilanove-uno-mega2560-mega1280.html)
3) 5V digital Relay
 http://www.seeedstudio.com/depot/electronic-brick-5v-relay-module-digital-p-479.html?cPath=190
4) Custom Thermistor based off Thermistor 100K
(https://ultimachine.com/content/thermistor-100k)

Here is what I want the unit to do:
Display Current temperature (To 0.5 degrees)
Display Target Tempeature  (to 0.5 degrees)
Use Up and down to change Target tempeature by 0.5 degree increments
Turn Relay off when Target temp > Current Temp

Here is what my problems are:
1)Relay will not turn off when target temp is reached. I'm using digital pin 12 for relay
2)I really want when I press the up and down buttons for the temp to go up and down, but instead I have to hold the button down and the temp jumps ups. Can this be fixed?
3) How to display the tenth decimal point and not the whole number? Ex 34.3F than 34F

If anybody can help that would be amazing.  Here is my current code:

Code:
#define THERMISTOR_PIN 1

#include <LiquidCrystal.h>

#define BUFFER_SIZE 2000
#define MIN_BUFFER_SKIP 20
#define MAX_BUFFER_SKIP 100
#define INC_BUFFER_SKIP 5

/**
 * Buffer used to keep track of timing
 */
short buffer = 0, bufferSkip, buttonSkip;
/**
 * Values used for processing
 */
int rawValue, celsius, lastCelsius, fahrenheit, targetTemp, lastKey;

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

// define some values used by the panel and buttons
int lcd_key     = 0;
int adc_key_in  = 0;
#define btnRIGHT  0
#define btnUP     1
#define btnDOWN   2
#define btnLEFT   3
#define btnSELECT 4
#define btnNONE   5

// read the buttons
int read_LCD_buttons()
{
  adc_key_in = analogRead(0);      // read the value from the sensor
  // my buttons when read are centered at these valies: 0, 144, 329, 504, 741
  // we add approx 50 to those values and check to see if we are close
  if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
  if (adc_key_in < 50)   return btnRIGHT;  
  if (adc_key_in < 195)  return btnUP;
  if (adc_key_in < 380)  return btnDOWN;
  if (adc_key_in < 555)  return btnLEFT;
  if (adc_key_in < 790)  return btnSELECT;  
  return btnNONE;  // when all others fail, return this...
}

// EPCOS 100K Thermistor (B57560G1104F)
// Made with createTemperatureLookup.py (http://svn.reprap.org/trunk/reprap/firmware/Arduino/utilities/createTemperatureLookup.py)
// ./createTemperatureLookup.py --r0=100000 --t0=25 --r1=0 --r2=4700 --beta=4092 --max-adc=1023
// r0: 100000
// t0: 25
// r1: 0
// r2: 4700
// beta: 4092
// max adc: 1023
#define NUMTEMPS 20
short temptable[NUMTEMPS][2] = {
  {
    1, 821  }
  ,
  {
    54, 252  }
  ,
  {
    107, 207  }
  ,
  {
    160, 182  }
  ,
  {
    213, 165  }
  ,
  {
    266, 152  }
  ,
  {
    319, 141  }
  ,
  {
    372, 131  }
  ,
  {
    425, 123  }
  ,
  {
    478, 115  }
  ,
  {
    531, 107  }
  ,
  {
    584, 100  }
  ,
  {
    637, 93  }
  ,
  {
    690, 86  }
  ,
  {
    743, 78  }
  ,
  {
    796, 70  }
  ,
  {
    849, 60  }
  ,
  {
    902, 49  }
  ,
  {
    955, 34  }
  ,
  {
    1008, 3  }
};

void setup()
{

  Serial.begin(9600);

  Serial.println("Mark's Sous Vide cooker");

  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);

  // Print a message to the LCD.
  lcd.print("Mark's Sous Vide Cooker");

  pinMode(12, OUTPUT);          // tells arduino RELAY is an output

  // Preset Last Celsius so it will fail the test
  lastCelsius = -1;

  targetTemp = 35;
  bufferSkip = 20;
  lastKey = btnNONE;
  buttonSkip = 0;

  delay(5000);
  lcd.clear();
}



/**
 * Control loop
 * We use the buffer to control the flow of time, so user interaction is preserved.
 * Buffer skip is used to control how time flows, so if there are no user interactions,
 * it will slow down in an attempt to save battery
 */
void loop()
{

  if (buffer <= 0) {

    rawValue = analogRead(THERMISTOR_PIN);
    celsius = read_temp();
    fahrenheit = (((celsius * 9) / 5) + 32);
    // Reset buffer so we skip doing stuff
    buffer = BUFFER_SIZE;

    // Only update LCD if something changed
    if (celsius != lastCelsius) {
      lastCelsius = celsius;

      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Current ");
      lcd.print(celsius);
      lcd.print("C");
      lcd.setCursor(0, 1);
      lcd.print("Target  ");
      lcd.print( targetTemp );
      lcd.print("C");

      Serial.print("Current temp: ");
      Serial.print(celsius);
      Serial.println("C / ");
    }

    if ( targetTemp > celsius ) {
      digitalWrite(12, LOW);    // set the relay OFF
    }
    else {
      digitalWrite(12, HIGH);   // set the RELAY ON
    }

  }

  // This part of code will always run
  {
    // Listen for inputs here

    int buttonPressed = read_LCD_buttons();
    bool pressed = false;


    if (buttonPressed == lastKey) {

      if (buttonPressed == btnNONE) {

      }
      else {
        buttonSkip -= 1;
        if (buttonSkip < 100) {
          buttonSkip = 100;
        }

        if (buttonPressed == btnUP) {
          targetTemp++;
        }
        else if (buttonPressed == btnDOWN) {
          targetTemp--;
        }

        // Bound min.max values
        if (targetTemp < 0) {
          targetTemp = 0;
        }
        else if (targetTemp > 100) {
          targetTemp = 100;
        }
      }
    }
    else {
      buttonSkip = 200;
      lastKey = buttonPressed;
    }

    pressed = lastKey != btnNONE;

    // If there is a button press, we need to update the target temp, and set buffer to 20, so we have instant interaction now
    if (pressed) {
      bufferSkip = buttonSkip;
      buffer = buttonSkip;
    }
    else if (bufferSkip < MAX_BUFFER_SKIP) {
      // Increase the buffer skip until we get to the max
      bufferSkip += INC_BUFFER_SKIP;
      if (bufferSkip > MAX_BUFFER_SKIP) {
        bufferSkip = MAX_BUFFER_SKIP;
      }
    }
    // If the buffer skip is larger then the buffer, we just use buffer to keep timing
    if (buffer < bufferSkip) {
      delay(buffer);
    }
    // Or we just use the skip to control time, like normal
    else {
      delay(bufferSkip);
    }
    // It does not matter if it goes below 0, since we have a check for  <= 0
    buffer -= bufferSkip;
  }

}

/**
 * Read the temp from the sensor
 */
int read_temp() {
  int rawtemp = analogRead(THERMISTOR_PIN),
  current_celsius = 0;

  byte i;
  // I think this should start at 0, this in index positions, right?
  for (i=1; i < NUMTEMPS; i++) {
    if (temptable[i][0] > rawtemp) {
      int realtemp  = temptable[i-1][1] + (rawtemp - temptable[i-1][0]) * (temptable[i][1] - temptable[i-1][1]) / (temptable[i][0] - temptable[i-1][0]);

      if (realtemp > 255) {
        realtemp = 255;
      }

      current_celsius = realtemp;

      break;
    }
  }

  // Overflow: We just clamp to 0 degrees celsius
  if (i == NUMTEMPS) {
    current_celsius = 0;
  }

  return current_celsius;
}

 
5  Forum 2005-2010 (read only) / Exhibition / Re: Arduino GPS on: February 24, 2010, 10:46:58 pm
What programs are you going to make for your GPS?

Keep up the good Work!  smiley

Mark
6  Forum 2005-2010 (read only) / Exhibition / NunPLUG = Wii NunChuck + ARDUINO (PLUG-N-PLAY) on: February 24, 2010, 10:58:46 pm
       After burning out 2 Wii Nunchuck   :'(  I wised up and built a direct plug for the Wii Nunchuck. Seeeduino builds a Brick shield that accepts 3 & 4 servo plugs and 3 Busses. I will publish a tutorial about this mod later. What is so great about this plug its a direct plug-in and it uses all of the Nunchuck libraries WITHOUT any modification to the code!! Truly a plug and play! Also it cost only 6 dollars total if you already have an seeeduino Brick Shield!


[size=12]Parts you will need: [/size]

Seeeduino Brick Shield:

http:// http://www.seeedstudio.com/depot/electronic-brick-chassis-v11-p-460.html?cPath=48_49
( 13.99 USD)


Seeduino 4 pin servo plug:

http:// http://www.seeedstudio.com/depot/electronic-brick-fully-buckled-4-wire-cable-p-486.html?cPath=48_57
(1.00 USD)

Wii NunChuck (Search Ebay)
5.00 USD Shipped!!


Photos Of the NunPLUG (Arduino Brick NunChuck)
(BETTER PHOTOS COMING SOON- DARN YOU IPHONE 2G)



NunPlug- The First DIRECT PLUG-N-PLAY Nunchuck for the arduino!

http://s960.photobucket.com/albums/ae85/2robotguy/?action=view&current=Nunplug1-1.jpg




IF ANYBODY KNOWS THE DIGI-KEY PART NUMBER FOR THE 4 SERVO CONNECTOR PLEASE REPLY, IT WOULD BE MUCH APPRECIATED!!


http://s960.photobucket.com/albums/ae85/2robotguy/?action=view&current=Nunplug2.jpg





[size=12]A Little Set up to show how fast it is to ADD parts with the Brick Shield.  ;D[/size]

http://s960.photobucket.com/albums/ae85/2robotguy/?action=view&current=Nunplug3.jpg


Think I am going to use a Wireless Nunchuck NEXT (WiCHUCK?) Found them on Ebay for 12 USD. Think about the wireless robots you can build with that for 13 dollars! Alot Cheaper than a remote or an XBEE!  :o

Questions or suggestions?  :-?

    Mark  8-)

Pages: [1]