Skip to content

Instantly share code, notes, and snippets.

@100ideas
Last active September 28, 2015 01:08
Show Gist options
  • Save 100ideas/1360983 to your computer and use it in GitHub Desktop.
Save 100ideas/1360983 to your computer and use it in GitHub Desktop.
Project:,PersonalPCR,,,,,,,
Circuit Board Components,,,,,,,,
Part,Description,Value,Package,#,Manufact.,Man PN,Vendor,Vend PN
"R1,R2,R3,R4,R5",Resistor,2000 Ohm,1206,3,,,Digikey,P2.00KFCT-ND
"A0,A1,A2,A3,A4",Thermistor,2000 Ohm,Leaded,3,,,Digikey,495-2144-ND
"R6,R7,R8",Resistor,240 Ohm,1206,2,,,Digikey,311-240ERCT-ND
"R11,R14,R17",Heater Resistor,12 Ohm,TH,1,Yageo,,Digikey,12W-5-ND
C1,Capacitor,10 uF,5x2mm TH,1,Panasonic,ECA-1CM101,Digikey,P5138-ND
--,Header,--,6 pin,2,3M,961106-6404-AR,Digikey,3M9451-ND
--,Header,--,8 pin,2,3M,961108-6404-AR,Digikey,3M9452-ND
"U1,U2,U3",Transistor,---,SOT-223,2,,,Digikey,FZT600CT-ND
,,,,,,,,
Fan and Power Supply,,,,,,,,
Part,Description,Value,Package,#,Manufact.,Man PN,Vendor,Vend PN
Extension Wire,,,,4,,,,misc
Heat Shrink,,,,4,,,,misc
Power Supply,12V 2A Arduino Compatible,,,1,,,,misc
FAN,FAN,,,1,,,Digikey,259-1564-ND
Cap,Cap,1uF,Leaded,1,,,,misc
,,,,,,,,
Tube Holder,,,,,,,,
Part,Description,Value,Package,#,Manufact.,Man PN,Vendor,Vend PN
Aluminum Tube,"9/32"" OD Tube",,,2,,,,misc
Aluminum Base,"1/4"" OD Stock",,,2,,,,misc
JB Weld,Epoxy,,,1,,,,misc
Acylic Top,"1/4"" Thick",,,1,,,,misc
Standoffs,,,,4,,,McMaster,94639A664
Screws,1.5” 4-40,,,4,,,McMaster,90276A119
Nuts,4-40,,,4,,,McMaster,90480A005
,,,,,,,,
,,,,,,,,
SOURCE: https://docs.google.com/spreadsheets/d/1WstWQa9UfXs3I-HbPjk5W_zOB-8NQKLVmavEHIy6UKk/pubhtml,,,,,,,,
NOTE: also check source BOM doc https://docs.google.com/spreadsheet/pub?key=0AvoYCobWBMh5dEljTXpmc19MSXRkVzA4d0dFUkpDNmc,,,,,,,,
// PersonalPCR v0.2.0
// 11/16/2011
// templemanautomation.com
// coFactorbio.com
// PCR Temperatures in C
const float INITIALIZATION = 95;
const float DENATURATION = 95;
const float ANNEAL = 55;
const float EXTENSION = 72;
const float FINAL_ELONGATION = 72;
const float HOLD = 10;
const int NUMBER_OF_CYCLES = 30;
#include <math.h>
#define aref_voltage 5.0
#define TRUE 1
#define FALSE 0
// core functions
void settemperature(float settemp, int settime, int duty, int dolastdelay);
void rampup(float temp);
void rampdown(float temp);
void printData(float setTemp, int timer);
void readTemps();
const float TOLERANCE = 1;
const float DENATURATION_OFFSET = 4;
const float ANNEAL_OFFSET = 2;
const float EXTENSION_OFFSET = 3.5;
const int DENATURE_RAMP_OFFSET = 4 + DENATURATION_OFFSET;
const int ANNEAL_RAMP_OFFSET = 3 - ANNEAL_OFFSET;
const int EXTENSION_RAMP_OFFSET = 3 + EXTENSION_OFFSET;
int timer = 0;
unsigned long t = 0;
int cycle = 0;
int heater = 3;
int fan = 2;
int sensorValue1 = 0;
int sensorValue2 = 0;
int sensorValue3 = 0;
float temp1 = 0;
float temp2 = 0;
float temp3 = 0;
float r1 = 0;
float r2 = 0;
float r3 = 0;
const int analogInPin0 = A0;
const int analogInPin1 = A1;
const int analogInPin2 = A2;
void setup()
{
Serial.begin(9600);
pinMode(heater, OUTPUT);
digitalWrite(heater, LOW);
Serial.print("seconds");
Serial.print(" ");
Serial.print("cycle_num");
Serial.print(" ");
Serial.print("cycle_time");
Serial.print(" ");
Serial.print("target_temp");
Serial.print(" ");
Serial.print("probe_1_temp");
Serial.print(" ");
Serial.print("probe_2_temp");
Serial.print(" ");
Serial.print("control_temp");
Serial.println(" ");
}
void loop()
{
rampup(INITIALIZATION - DENATURE_RAMP_OFFSET);
settemperature(INITIALIZATION - DENATURATION_OFFSET, 30, 50, TRUE);
for (int i = 0; i < NUMBER_OF_CYCLES ;i++)
{
cycle++;
rampup(DENATURATION - DENATURE_RAMP_OFFSET);
settemperature(DENATURATION - DENATURATION_OFFSET, 30, 50, TRUE);
rampdown(ANNEAL + ANNEAL_RAMP_OFFSET);
settemperature(ANNEAL - ANNEAL_OFFSET, 60, 30, TRUE);
rampup(EXTENSION - EXTENSION_RAMP_OFFSET);
settemperature(EXTENSION - EXTENSION_OFFSET, 60, 40, TRUE);
}
cycle++;
settemperature(FINAL_ELONGATION - EXTENSION_OFFSET, 300, 50, TRUE);
while (1)
{
rampdown(HOLD);
settemperature(HOLD, 20, 50, TRUE);
}
}
void settemperature(float settemp, int settime, int duty, int dolastdelay)
{
int i = 0;
int timer = 0;
int time2 = 0;
time2 = settime * 10;
int fanDuty = (100 - duty)/10;
while (timer < time2)
{
readTemps();
//display to serial monitor
i++;
t++;
if (i == 10)
{
i=0;
printData(settemp, timer);
}
if ( temp3 >= settemp)
{
digitalWrite(fan, HIGH);
}
if(temp3 < settemp + TOLERANCE){
digitalWrite(heater, HIGH);
delay(duty);
digitalWrite(heater, LOW);
}
else {
delay(duty);
}
if ((temp3 < (settemp + TOLERANCE)) && (temp3 > (settemp - TOLERANCE)))
{
timer = timer + 1;
}
if (dolastdelay)
{
delay(98 - duty - 20);
digitalWrite(fan, LOW);
delay(20);
}
}
}
void readTemps()
{
//read all three sensors
sensorValue1 = analogRead(analogInPin0);
delay(1);
sensorValue2 = analogRead(analogInPin1);
delay(1);
sensorValue3 = analogRead(analogInPin2);
//convert all thermistors from "counts" voltage to C
r1 = 2000.0*(1024.0/sensorValue1) - 2000.0;
temp1 = 3560.0/log(r1/0.0130444106) - 273.15;
r2 = 2000.0*(1024.0/sensorValue2) - 2000.0;
temp2 = 3560.0/log(r2/0.0130444106) - 273.15;
r3 = 2000.0*(1024.0/sensorValue3) - 2000.0;
temp3 = 3560.0/log(r3/0.0130444106) - 273.15;
}
void printData(float setTemp, int timer)
{
Serial.print(t / 10);
Serial.print(" ");
Serial.print(cycle);
Serial.print(" ");
Serial.print(timer / 10);
Serial.print(" ");
Serial.print(setTemp);
Serial.print(" ");
Serial.print(temp1);
Serial.print(" ");
Serial.print(temp2);
Serial.print(" ");
Serial.print(temp3);
Serial.println(" ");
}
void rampup(float temp)
{
digitalWrite(heater, HIGH);
int i = 0;
readTemps();
while(temp3 < temp) {
readTemps();
//display to serial monitor
i++;
t++;
if (i == 10)
{
i=0;
printData(temp, timer);
}
delay(100);
}
digitalWrite(heater, LOW);
}
void rampdown(float temp)
{
digitalWrite(fan, HIGH);
int i = 0;
readTemps();
while(temp3 > temp) {
readTemps();
//display to serial monitor
i++;
t++;
if (i == 10)
{
i=0;
printData(temp, timer);
}
delay(100);
}
digitalWrite(fan, LOW);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment