PDA

View Full Version : ChipKIT UNO 32 Temp Center Kit



SXRguyinMA
10-23-2011, 03:13 PM
I designed this for a customer and crenn did the code. It's open source, all files are available for you to make your own.

I've assembled and tested a unit and I've got 7 6 board sets left if anyone's interested in purchasing a set. I can ship bare boards, or I can assemble them for you with an LCD of your choice and cable length of your choice. PM me for details on that if you're interested.

Without further adieu, I introduce the ChipKIT UNO32 12-port temp center kit!

Shield Pics:
http://www.thebestcasescenario.com/sxrguyinma/personal/tempcenter/shield/shield_pcb.png

http://www.thebestcasescenario.com/sxrguyinma/personal/tempcenter/shield/shield_sch.png

http://www.thebestcasescenario.com/sxrguyinma/personal/tempcenter/shield/v3_s_f.png

http://www.thebestcasescenario.com/sxrguyinma/personal/tempcenter/shield/v3_s_b.png

http://www.thebestcasescenario.com/sxrguyinma/personal/tempcenter/shield/v3_s_a1.png

http://www.thebestcasescenario.com/sxrguyinma/personal/tempcenter/shield/v3_s_a2.png


LCD Board Pics:
http://www.thebestcasescenario.com/sxrguyinma/personal/tempcenter/lcd_board/lcd_pcb.png

http://www.thebestcasescenario.com/sxrguyinma/personal/tempcenter/lcd_board/lcd_sch.png

http://www.thebestcasescenario.com/sxrguyinma/personal/tempcenter/lcd_board/v3_lcd.png

http://www.thebestcasescenario.com/sxrguyinma/personal/tempcenter/lcd_board/v3_lcd_a1.png

http://www.thebestcasescenario.com/sxrguyinma/personal/tempcenter/lcd_board/v3_lcd_a2.png

http://www.thebestcasescenario.com/sxrguyinma/personal/tempcenter/lcd_board/v3_lcd_a3.png


Code:

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

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/


// 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

OvRiDe
10-23-2011, 06:53 PM
I totally want to see this in action! Any videos of it?

SXRguyinMA
10-23-2011, 07:51 PM
I've got some. I'll get them uploaded soon :D
Check Makro Specials (https://www.especials.co.za/makro/) and Pick n Pay Specials (https://www.especials.co.za/pick-n-pay/).

SXRguyinMA
11-02-2011, 04:22 PM
On Hack-A-Day :D

http://hackaday.com/2011/11/02/chipkit-temperature-shield-supports-a-dozen-sensors/

crenn
11-02-2011, 04:48 PM
I'm apparently your associate according to the article ;P

Although one of the comments, made me think a little. Maybe there should be an offset for each channel if it's needed. Or I can fix up the maths involved in the temp as I knew it's not exactly accurate.

SXRguyinMA
11-02-2011, 06:32 PM
it's not 100% accurate but 1ºC-2ºC off isn't bad.