chipKIT® Development Platform

Inspired by Arduino™

Temp Sensor Shield

Created Sun, 04 Sep 2011 16:35:04 +0000 by SXRguyinMA


SXRguyinMA

Sun, 04 Sep 2011 16:35:04 +0000

I designed this for a customer. The boards have been made and are on their way to me for testing. 12 2-wire temp sensor inputs with output via a 2x5 header to a 16x2 LCD. You can use either a 5V or 3.3V LCD.

Pics here: http://s92.photobucket.com/albums/l11/sportrider12584/ChipKIT%20Temp%20Center/

I'm working on getting the eagle files together to share.


marcmccomb

Fri, 07 Oct 2011 20:31:47 +0000

Cool...please keep us posted! Don't forget to visit www.chipkit.cc/wiki and add info on the board and any libraries.


SXRguyinMA

Fri, 07 Oct 2011 21:00:05 +0000

I'll keep you posted! I had to redesigna nd re-order the boards as I noticed a couple flaws with the first design. I'll put up the eagle files and the working code (temps are within 1-2ºC of my temp gun readings) once the new boards come in and are tested!


SXRguyinMA

Sun, 23 Oct 2011 19:08:24 +0000

The new boards are in, assembled and tested! It's open source, and as such all the files are attached :D

Shield Pics:

LCD Board Pics:

Code:

// ChipKIT UNO 32 12-port Temperature Center Shield
// Code Written by Crenn (www.thebestcasescenario.com)
// Designed by Will Lyon (www.computersandcircuits.com)

// Libraries
#include <LiquidCrystal.h>

// Global Constants
const unsigned short START_MES_DIS_TIME=3;
const unsigned short ACTION_TIME=5;
const unsigned short UPDATE_TIME=1;
const unsigned short MILLIS_IN_SEC=1000;
const unsigned short SMDT_IN_MS=START_MES_DIS_TIME*MILLIS_IN_SEC;
const unsigned short AT_IN_MS=ACTION_TIME*MILLIS_IN_SEC;
const unsigned short UT_IN_MS=UPDATE_TIME*MILLIS_IN_SEC;
const byte TEMP_PINS=12;
const byte NO_TEMPS_ON_LCD=2;
const byte TEMP_SETS=TEMP_PINS/NO_TEMPS_ON_LCD;
const byte TEMP_PIN_MAP[NO_TEMPS_ON_LCD][TEMP_SETS]={
    {14,16,18,20,22,24} , {15,17,19,21,23,25}
};
const byte LCD_COLS=16;
const byte LCD_ROWS=2;
// The +1 is to allow for the null character at the end of the string
const char WELCOME_LA[LCD_COLS+1]="                ";                    // edit these to change the opening message display. Line 1 on top, line 2 on bottom
const char WELCOME_LB[LCD_COLS+1]="                ";
const char TEMP_L[]="TEMP ";
const byte TEMP_CUST_CHARS=7;
const byte TEMP_CUSTOM[TEMP_PINS][TEMP_CUST_CHARS+1]={
  
  {"TEMP  1"},{"TEMP  2"},{"TEMP  3"},{"TEMP  4"},                       // Change these to edit the temp zone display names. Max 8 characters each!
  {"TEMP  5"},{"TEMP  6"},{"TEMP  7"},{"TEMP  8"},                       // You will need to adjust the spacing and upload to get it where you want it
  {"TEMP  9"},{"TEMP 10"},{"TEMP 11"},{"TEMP 12"}
};
const char TEMP_S[]={0xDF,'C'};

// Global Variables
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
byte temp_pin_pointer=0;
unsigned short temp_values[NO_TEMPS_ON_LCD][TEMP_SETS];
byte temp_lcda=1;
byte temp_lcdb=2;
byte welc_disp=0;
unsigned long tsla; // time_since_last_action;
unsigned long tslu; // time_since_last_update;

double convertTemp(unsigned short ttbc) {
  if (ttbc > 237 && ttbc < 748) {
    return (ttbc-237)*0.0939947781;
  }
  return 0.0;  
}

// Temperature Sensor Functions
void newTemps() {
  temp_lcda=(TEMP_PIN_MAP[0][temp_pin_pointer]-13);
  temp_lcdb=(TEMP_PIN_MAP[1][temp_pin_pointer]-13);
}

void updateTemps() {
  for(byte i=0;i<TEMP_SETS;i++) {
    temp_values[0]*=analogRead(TEMP_PIN_MAP[0][i]);
    temp_values[1][i]=analogRead(TEMP_PIN_MAP[1][i]);
  }
}

void displayTemps() {
  unsigned char spaces = 2;
  double temp_conv = 0.0;
  lcd.setCursor(0, 0);
  if(TEMP_CUSTOM[(temp_lcda-1)][0] != 0) {
    for (int i=0;i<TEMP_CUST_CHARS;i++) {
      if(TEMP_CUSTOM[(temp_lcda-1)][i] != 0) {
        lcd.print(TEMP_CUSTOM[(temp_lcda-1)][i]);
      }
	  else {
	    spaces = 8-i;
		break;
	  }
	}
  }
  else {
    lcd.print(TEMP_L);
    if(temp_lcda < 10) {
      lcd.print(' ');
    }
    lcd.print(temp_lcda,DEC);
	spaces = 2;
  }
  for (int i=0;i<spaces;i++) {
    lcd.print(' ');
  }
  if(TEMP_CUSTOM[(temp_lcdb-1)][0] != 0) {
    for (int i=0;i<TEMP_CUST_CHARS;i++) {
      if(TEMP_CUSTOM[(temp_lcdb-1)][i] != 0) {
        lcd.print(TEMP_CUSTOM[(temp_lcdb-1)][i]);
      }
      else {
        spaces = 8-i;
    	break;
      }
    }
  }
  else {
    lcd.print(TEMP_L);
    if(temp_lcdb < 10) {
      lcd.print(' ');
    }
    lcd.print(temp_lcdb,DEC);
    spaces = 0;
  }
  if (spaces != 0) {
    for (int i=0;i<spaces;i++) {
      lcd.print(' ');
    }
  }
  spaces = 3;
  lcd.setCursor(0, 1);
  temp_conv=convertTemp(temp_values[0][temp_pin_pointer]);
  if (temp_conv<10) {
    lcd.print(' ');
  }
  lcd.print(temp_conv,1);
  lcd.print(TEMP_S);
  for (int i=0;i<spaces;i++) {
    lcd.print(' ');
  }
  temp_conv=convertTemp(temp_values[1][temp_pin_pointer]);
  if (temp_conv<10) {
    lcd.print(' ');
  }
  lcd.print(temp_conv,1);
  lcd.print(TEMP_S);
}

void displayWel() {
  lcd.setCursor(0, 0);
  lcd.print(WELCOME_LA);
  lcd.setCursor(0, 1);
  lcd.print(WELCOME_LB);
}

void setup() {
  lcd.begin(LCD_COLS, LCD_ROWS);
  displayWel();
  tsla = millis();
  while (millis() < (tsla + SMDT_IN_MS));
  tsla = millis();
  updateTemps();
  displayTemps();
}

void loop() {
  if (millis() > (tsla + AT_IN_MS)) {
    if (welc_disp == 1) {
	  temp_pin_pointer = 0;
	  welc_disp = 0;
	  updateTemps();
	}
	else {
	  ++temp_pin_pointer;
	}
    if (temp_pin_pointer >= TEMP_SETS) {
	  displayWel();
	  welc_disp = 1;
    }
    else {
	  newTemps();
      displayTemps();
    }
    tsla = millis();
  }
  if (temp_pin_pointer < TEMP_SETS) {
    if (millis() > (tslu + UT_IN_MS)) {
      updateTemps();
      displayTemps();
      tslu = millis();
    }
  }
}

Eagle Files:

[i]Shield Board:* .brd: http://www.thebestcasescenario.com/sxrguyinma/personal/tempcenter/shield/Temp_Center_Brd.brd .sch: http://www.thebestcasescenario.com/sxrguyinma/personal/tempcenter/shield/Temp_Center_Brd.sch

LCD Board: .brd: http://www.thebestcasescenario.com/sxrguyinma/personal/tempcenter/lcd_board/Temp_Center_LCD.brd .sch: http://www.thebestcasescenario.com/sxrguyinma/personal/tempcenter/lcd_board/Temp_Center_LCD.sch

Bill Of Materials (.pdf): http://www.thebestcasescenario.com/sxrguyinma/personal/tempcenter/Temp_Center_BOM.pdf


MGLSOFT

Thu, 22 Dec 2011 18:56:30 +0000

Very good development, congratulations! What kind of sensors can be used on this board? I did not find this answer anywhere, so be good for me that clarification.

Thanks for sharing!


SXRguyinMA

Sat, 24 Dec 2011 13:08:27 +0000

any 2-wire 10k thermistor can be used :)


MGLSOFT

Sat, 24 Dec 2011 14:37:54 +0000

Can this shield and library use in Chipkit MAX32?


SXRguyinMA

Sat, 24 Dec 2011 14:45:50 +0000

The library will work just fine and I'll see if the sheild will fit on my MAX32 when I get home tonight and let you know.


SXRguyinMA

Tue, 27 Dec 2011 12:39:23 +0000

Can this shield and library use in Chipkit MAX32?

This shield will not work with the MAX 32 due to the pin layout on the board. It will only work with the UNO 32.


SXRguyinMA

Sun, 09 Dec 2012 20:16:19 +0000

I've tested the library with the MAX32 and it works fine, the shield just needs to be changed for the different pin layout. I'll work on making a new shield board for it soon