Eric Patterson / Mbed 2 deprecated Final_Coffee_Roaster

Dependencies:   4DGL-uLCD-SE MAX31855 mbed-rtos mbed

Fork of Coffee_Roaster_Threads by Eric Patterson

Files at this revision

API Documentation at this revision

Comitter:
ericspatterson
Date:
Wed Nov 12 18:56:57 2014 +0000
Child:
1:26267401354a
Commit message:
First Publish..Need to work on Touch Panel controls and get motor controlled with SSR

Changed in this revision

4DGL-uLCD-SE.lib Show annotated file Show diff for this revision Revisions of this file
MAX31855.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/4DGL-uLCD-SE.lib	Wed Nov 12 18:56:57 2014 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/ericspatterson/code/4DGL-uLCD-SE/#e39a44de229a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MAX31855.lib	Wed Nov 12 18:56:57 2014 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/ericspatterson/code/MAX31855/#5eeee89cb281
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Nov 12 18:56:57 2014 +0000
@@ -0,0 +1,125 @@
+#include "mbed.h"
+#include "uLCD_4DGL.h"
+#include "rtos.h"
+#include "stdio.h"
+#include "max31855.h"
+
+uLCD_4DGL uLCD(p9,p10,p11); // serial tx, serial rx, reset pin;
+SPI thermoSPI(p5,p6,p7); // setup SPI interface
+max31855 max1(thermoSPI, p20); //setup max31855 interface
+Mutex lcd_mutex; // mutex to make the lcd lib thread safe
+Semaphore four_slots(1); //Activate semaphore
+DigitalOut toggle(p30);
+DigitalIn up(p19);
+DigitalIn down(p18);
+
+int settemp = 75;
+
+float ftemperature = 0; // float variable for temperature
+float ctemperature = 0; // float variable for temperature
+
+// Thread t1
+//  print the elapsed time on line 1 of the uLCD (i.e., HH:MM:SS)
+void elapsedtime(void const *args) { //line 2
+    int s = 00;
+    int m = 00;
+    int h = 00;
+    
+    while(true){
+        s++;
+        if(s>59){
+           s=00;
+          m++;
+         }
+         if(m>59){
+           m=00;
+           h++;
+         }
+       four_slots.wait();
+       //lcd_mutex.lock();
+        uLCD.color(0xFFFF00);
+        uLCD.locate(0,0); //col,row
+        wait(0.1);
+        uLCD.printf("ET: %2d:%2d:%2d", h,m,s);
+        //lcd_mutex.unlock();
+        four_slots.release();
+        Thread::wait(1000); // update once per secon
+    }
+}
+
+
+// Thread t2
+//  print the temperature from the thermocouple - MAX31855 device
+void thermoread(void const *args) { //line 2
+    
+
+    while(true){
+        if (max1.ready()==1){
+            ctemperature = max1.read_temp(); //Get the reading
+            ftemperature = (ctemperature)*(9.0/5.0)+32.0;
+            four_slots.wait();    
+            uLCD.color(0xFFFF00);
+            uLCD.locate(0,2); //col,row
+            wait(0.1);
+            uLCD.printf("Current Temp. F");
+            uLCD.locate(0,3); //col,row
+            uLCD.printf("%4.2f", ftemperature);
+            
+            //uLCD.locate(0,5); //col,row
+           // uLCD.printf("Set Temp. F");
+           // uLCD.locate(0,6); //col,row
+          //  uLCD.printf("%d",settemp);
+           
+            four_slots.release(); 
+        }
+    }
+}
+
+
+void thermoset (void const *args) { //line 2
+    while(true){
+        if (up==1){
+            settemp += 1;
+            four_slots.wait();    
+            uLCD.color(0xFFFF00);        
+            uLCD.locate(0,5); //col,row
+            uLCD.printf("Set Temp. F");
+            uLCD.locate(0,6); //col,row
+            uLCD.printf("%d",settemp);
+            four_slots.release(); 
+            wait(.5);
+        }
+        if (down==1){
+            settemp -= 1;
+            four_slots.wait();    
+            uLCD.color(0xFFFF00);        
+            uLCD.locate(0,5); //col,row
+            uLCD.printf("Set Temp. F");
+            uLCD.locate(0,6); //col,row
+            uLCD.printf("%d",settemp);
+            four_slots.release();
+            wait(.5); 
+        }
+    }
+}
+
+
+
+int main() {
+    max1.initialise(); //initialize thermocouple IC    
+    uLCD.baudrate(3000000); //set LCD baudrate
+    Thread t1(elapsedtime); //run elapsed time counter
+    Thread t2(thermoread); //read and display temperature from thermocouple
+    Thread t3(thermoset);
+    
+    
+    while(1){ //While so program doesn't end
+            if(ftemperature < settemp-1){
+                toggle=1; //turn on ssr
+            }
+            if(ftemperature > settemp+1){
+                toggle=0;
+            }
+            wait(1);
+        }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Wed Nov 12 18:56:57 2014 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/ericspatterson/code/mbed-rtos/#aaa1b2c7c64c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Nov 12 18:56:57 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1
\ No newline at end of file