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

main.cpp

Committer:
wavenumber
Date:
2020-08-31
Revision:
2:73a028278c5c
Parent:
0:7798270c1f52
Child:
3:cb48919cd5e8

File content as of revision 2:73a028278c5c:

#include "mbed.h"
#include "CHEM_BOX_INTERFACE.h"

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();

    //Beep 6 times
    for(i=0;i<6;i++)
      {
        Buzz(.05);  //Since the Buzz function immediately returns we should wait a bit before calling it again in the loop
        wait(.1);   //I want a 50% duty cycle so I will wait twice as long as my previous Buzz() call
     }
     
     
      //Here is an example of how to draw on the screen!
      
      //This makes the backlight white.   Each color can be between 0 and 3 (integers... 0,1,2,3)
      SmartSwitch_SetBackLightColor(3, 3, 3);
      
      //The display routines are fully buffered.   When you call the draw routines,  the write to the backbuffer, not the screen.
      //The flow is to clear the backbuffer,   call all the drawing routines,  then dump the backbuffer to the screen.   
      
      //This clears the back buffer
      GFX_FullDisplayBufferClear(&BackBuffer);
      
      //Draw a box around the edge of the screen
      
      GFX_DrawLine(&BackBuffer, 0,0, PHYSICAL_DISPLAY_XRES - 1,0);
      GFX_DrawLine(&BackBuffer, PHYSICAL_DISPLAY_XRES - 1,0,PHYSICAL_DISPLAY_XRES - 1 ,PHYSICAL_DISPLAY_YRES - 1);
      GFX_DrawLine(&BackBuffer, PHYSICAL_DISPLAY_XRES - 1 ,PHYSICAL_DISPLAY_YRES - 1,0,PHYSICAL_DISPLAY_YRES - 1);
      GFX_DrawLine(&BackBuffer,0, PHYSICAL_DISPLAY_YRES - 1,0,0);
      
      //Draw a plain string using the 5x7 font.   
      GFX_DrawString(&BackBuffer,"Rioux Box",6,2, &Font5x7);
      
      GFX_DrawHline(&BackBuffer,0,PHYSICAL_DISPLAY_XRES - 1 ,12);
      
      //This shows how to do a printf.   Using this allows you to put internal variables, etc on the screen.   
      //Just lookup documentation on printf on the web to see examples of escape sequences in the control strings   
      //In this example API_VERSION is a string so we use %s to display it  
      GFX_printf(&BackBuffer,15,20, &Font3x5,"Ver: %s",API_VERSION);
      
      //Move the backbuffer to the actual display
      GFX_DumpRenderContextToPhysicalScreen(&BackBuffer);
      
     
    //Here is the main super loop
    
    //reset and start our control loop Timer
    ControlLoopTimer.reset();
    ControlLoopTimer.start();
    
    while(1)
     {
          //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);
                    }

                 }
            }*/
      
      
            /*
            
            //control loop example
            //We will do something ever 250mS.
            //Use a timer and an if statement we won't hold the microprocessor from do other things in the main super loop!
            if(ControlLoopTimer.read_ms >= 250)
            {
                ControlLoopTimer.reset();    
                
                //if 250mSec has elapsed then do our control loop
                
                CurrentTemperature = ReadThermocouple(0);
                
                if(CurrentTemperature < 15.5)
                {
                    EnableHeater(0);
                }
                else
                {
                   DisableHeater(0);
                }
                
                FlushDigitalIO(); //Remeber, the digital outs are queued up until this is called!
            }
            */
     }

}