Example project for the Rioux Chem control box

Dependencies:   mbed MODSERIAL

Dependents:   screentest

Rioux Chem Control Box

/media/uploads/emh203/ccb.jpg

This is the example project for the Rioux Chem Control Box. I have posted some youtube videos to guide you through the hardware and software:

Rioux Chem Control Box - Hardware

http://www.youtube.com/watch?v=MoZ92GRYa4s

Rioux Chem Control Box - Software - Part I

http://www.youtube.com/watch?v=_MwaTLL4dyA==

Rioux Chem Control Box - Software - Part II

http://www.youtube.com/watch?v=j_P89izfgoQ

Files at this revision

API Documentation at this revision

Comitter:
wavenumber
Date:
Mon Aug 31 13:00:37 2020 +0000
Parent:
1:d64ac853223c
Child:
3:cb48919cd5e8
Commit message:
Fixed issue with Thermocouple bit masking. Added Echo off command

Changed in this revision

DRIVERS/CHEM_BOX_COMMON.cpp Show annotated file Show diff for this revision Revisions of this file
DRIVERS/CHEM_BOX_INTERFACE.h 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
--- a/DRIVERS/CHEM_BOX_COMMON.cpp	Thu Aug 06 15:02:29 2015 +0000
+++ b/DRIVERS/CHEM_BOX_COMMON.cpp	Mon Aug 31 13:00:37 2020 +0000
@@ -6,6 +6,8 @@
 
 //Mbed Objects
 
+DigitalOut MBED_LED1(LED1);
+
 DigitalOut AIO_ADC1_CS(p30);     
 
 DigitalOut AIO_ADC2_CS(p29);  
@@ -46,6 +48,8 @@
 //Local Variables
 
 
+static uint8_t TerminalEcho = 1;
+
 static uint8_t HeaterBits = 0;
 
 static uint16_t SolenoidBits = 0;
@@ -226,22 +230,22 @@
     MCU_SR_LOAD = 0;
 }
 
-//Make sure to call  ReadThermocouple befor eyou call this so internal variables are updated
+//Make sure to call  ReadThermocouple before you call this so internal variables are updated
 uint16_t ReadThermocouple_OC() 
 {
     return Thermocouple_OC;
 }
-//Make sure to call  ReadThermocouple befor eyou call this so internal variables are updated
+//Make sure to call  ReadThermocouple before you call this so internal variables are updated
 uint16_t ReadThermocouple_SCG()
 {
     return Thermocouple_SCG;
 }
-//Make sure to call  ReadThermocouple befor eyou call this so internal variables are updated
+//Make sure to call  ReadThermocouple before you call this so internal variables are updated
 uint16_t ReadThermocouple_SCV()
 {
     return  Thermocouple_SCV;
 }
-//Make sure to call  ReadThermocouple befor eyou call this so internal variables are updated
+//Make sure to call  ReadThermocouple before you call this so internal variables are updated
 uint16_t ReadThermocouple_FAULT()
 {
     return  Thermocouple_FAULT;
@@ -500,6 +504,7 @@
 void TerminalCmd_MFCOFF(char *arg);
 void TerminalCmd_AOUT(char *arg);
 void TerminalCmd_Reset(char *arg);
+void TerminalCmd_ECHO_OFF(char *arg);
 
 //Populate this array with the callback functions and their terminal command string
 TerminalCallbackRecord MyTerminalCallbackRecords[] ={   {"reset",TerminalCmd_Reset,"Resets the CHEM box"},
@@ -542,7 +547,9 @@
                                                         
                                                         {"MFCON",TerminalCmd_MFCON,"Turns on the MFC power"},
                                                         
-                                                        {"MFCOFF",TerminalCmd_MFCOFF,"Turns off the MFC power"}
+                                                        {"MFCOFF",TerminalCmd_MFCOFF,"Turns off the MFC power"},
+                                                        
+                                                        {"ECHO_OFF",TerminalCmd_ECHO_OFF,"Disables echoing of characters"}
                                                     };
 
 
@@ -553,11 +560,18 @@
     mbed_reset();
 }
 
+
+
 void TerminalCmd_Stub(char *arg)
 {
     PC.printf("stub \r\n");
 }
 
+void TerminalCmd_ECHO_OFF(char *arg)
+{
+    TerminalEcho = 0;
+}
+
 void TerminalCmd_MFCI(char *arg)
 {
     int Channel = -1;
@@ -846,11 +860,13 @@
 void TerminalCmd_FanOn(char *arg)
 {
      SetFanSpeed(100);   //PWMing the FANs doesn't work with the ME40100V1 models!   WE will just on or off
+     MBED_LED1 = 1;
 }
 
 void TerminalCmd_FanOff(char *arg)
 {
      SetFanSpeed(0);   //PWMing the FANs doesn't work with the ME40100V1 models!   WE will just on or off
+      MBED_LED1 = 0;
 }
 
 void TerminalCmd_Fan(char *arg)
@@ -991,8 +1007,12 @@
             case '\r':
              
              TerminalLineBuf[TerminalPos++] = 0x0;
-             PC.putc(NextCharIn);
-           
+             
+             if(TerminalEcho)
+             {
+                 PC.putc(NextCharIn);
+             }
+             
              if(TerminalPos > 1)
              {
                  //find the command
@@ -1061,7 +1081,7 @@
                   
                 }
               }    
-             PC.printf("\r\n>");
+             PC.printf("\r\n");
              TerminalPos = 0;
             
             break;
@@ -1069,8 +1089,11 @@
             case '\b':
                 if(TerminalPos > 0)
                 {
-                    TerminalPos--;    
-                    PC.putc(NextCharIn);
+                    TerminalPos--;  
+                    if(TerminalEcho)
+                    {  
+                        PC.putc(NextCharIn);
+                    }
                 }
             break;
             
@@ -1086,7 +1109,10 @@
                     if(TerminalPos < MAX_TERMINAL_LINE_CHARS-1)
                     {
                          TerminalLineBuf[TerminalPos++] = NextCharIn;
-                         PC.putc(NextCharIn);
+                         if(TerminalEcho)
+                         {
+                            PC.putc(NextCharIn);
+                         }
                     }
                 }
             
--- a/DRIVERS/CHEM_BOX_INTERFACE.h	Thu Aug 06 15:02:29 2015 +0000
+++ b/DRIVERS/CHEM_BOX_INTERFACE.h	Mon Aug 31 13:00:37 2020 +0000
@@ -134,6 +134,11 @@
 
 uint16_t ReadThermocouple_FAULT();
 
+/*
+Read the internal reference temperature
+*/
+float ReadInternalTemperature(uint8_t ThermocoupleIndex);
+
 //Writes to one of the Misc Analog Output channels.  The Value shoul dbe in Volts (from 0 to 5v)
 void WriteMISC_AnalogOut(uint8_t Channel,float Value);
 
--- a/main.cpp	Thu Aug 06 15:02:29 2015 +0000
+++ b/main.cpp	Mon Aug 31 13:00:37 2020 +0000
@@ -4,11 +4,20 @@
 Timer ControlLoopTimer;
 float CurrentTemperature;
 
+#define VT100_RED     "\033[31;40m"
+#define VT100_GREEN   "\033[32;40m"
+#define VT100_YELLOW  "\033[33;40m"
+#define VT100_BLUE    "\033[34;40m"
+#define VT100_MAGENTA "\033[35;40m"
+#define VT100_CYAN    "\033[36;40m"
+#define VT100_WHITE   "\033[37;40m"
+#define VT100_RESET   "\033c"
+
 
 int main() 
 {
     int i;
-
+    char * Color = VT100_WHITE;
     //This function always needs called before you do anythign wit the CHEM BOX.
     InitChemBox();
 
@@ -62,6 +71,43 @@
      {
           //Call this often if you want the USB interface/Terminal
           ProcessTerminal();
+      /*RS232_0.printf(" RUN\r");
+          if(ControlLoopTimer.read_ms() >= 1000)
+            {
+                ControlLoopTimer.reset();   
+              
+              
+                PC.printf(VT100_RESET);
+              
+                for(int channel=0;channel<12;channel++)
+                {
+                    if(channel & 0x01)
+                        Color = VT100_CYAN;
+                    else
+                        Color =  VT100_GREEN  ;
+                    
+                    
+                    float ThermocoupleTemperature = ReadThermocouple(channel);
+                    float InternalReferenceTemperature = ReadInternalTemperature(channel);
+                    
+                    bool IsDisconnected = (ReadThermocouple_OC() & (1<<channel));
+                    
+                    if(IsDisconnected == true)
+                    {
+                           PC.printf(VT100_WHITE"Channel %i: ",channel);
+                           PC.printf(VT100_RED"disconnected\r\n");
+                    }
+                    else
+                    {
+                        PC.printf(VT100_WHITE"Channel %i: ",channel);
+                        PC.printf(VT100_WHITE"%s%.2f  ",Color,ThermocoupleTemperature);
+                        PC.printf(VT100_WHITE"INT: ",channel);
+                        PC.printf(VT100_WHITE"%s%.2f\r\n",Color,InternalReferenceTemperature);
+                    }
+
+                 }
+            }*/
+      
       
             /*