Future online laboratories through chipKIT

A few professionals have published a research paper “A novel concept for configuring online laboratories” with the use of PIC kit in the Experiment International Conference.  (See below abstract)

They are interested in doing this with chipKIT in the future. Abstract—Embedded online laboratories are becoming frequent nowadays, because they can include both the functionality of a data acquisition device and the functionality of a webserver and this, in turn, results in lower implementation costs. However, while it is easy to configure a laboratory server which is located on a computer, the local configuration and control of an embedded laboratory is more challenging, because of the lack of interactive peripherals (such as the keyboard is to a computer). This paper introduces a novel concept which allows administrators to easily achieve the local configuration of the embedded (on-chip) laboratory parameters (including network settings) by using a mobile device.

Reference: B.Deaky, T. F. Andrade, L. Parv, “A novel concept for configuring online laboratories”, in Proceedings of the 2nd Experiment@ International Conference — Online Experimentation (exp.at’13), Coimbra, Portugal, September 18-20, 2013, pp. 79 – 82.

VN:F [1.9.22_1171]
Rating: 10.0/10 (2 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Reference materials for chipKIT

Dr. Andrew Veronis, Advanced Micro Circuits and Donald Jackson, Labcenter Electronics North America has created a reference materials called “A User’s Guide to chipKIT and Pmods”. It includes eight chapters including “What is microcontroller, Programming and so on. Each chapter covers theories, examples and hands on projects. It is free downloaded at https://docs.google.com/file/d/0B-oA-HSAnFDnVzAzeVVzOUFoRGs/edit?usp=sharing
VN:F [1.9.22_1171]
Rating: 10.0/10 (2 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Serial Communication – I2C Temperature sensor output to OLED

Overview:

In this project you will learn to use a basic functionality of chipKIT board, which is to use serial communication I2C bus to measure the room temperature and output the corresponding digital reading for it. I2C bus is a master slave bus, which communicates data from the processor on chipKIT board to other peripherals. More description on I2C communication can be found on the Wikipedia website.

Hardware Used:

The hardware used in this tutorial will be a chipKIT Uno32 along with a chipKIT Basic I/O Shield both manufactured by Digilent Inc.

Reference:

The reference guide for each board, schematics and other resources are available on their individual homepages:

Procedure:

  1. Go to the chipKIT Basic I/O Shield homepage mentioned in the reference section. Download the zip file that contains libraries and documentation for using the Basic I/O Shield™ with the chipKIT MPIDE. Open the downloaded zip folder and copy the three IOShield folders in it. These three folders have the libraries and example programs for EEPROM, OLED and Temperature Sensor peripherals on IO shield.
  2. Now open the drive where you installed the mpide software, inside your mpide folder navigate through hardware > pic32 > libraries and paste the three IOShield folders in it.
  3. Close your mpide software, for the libraries to get included and the changes to take effect.
  4. On restarting the mpide software and navigating through File > Examples; you can find IOShieldEEPROM, IOShieldOled and IOShieldTemp folders with their demo examples being included.
  5. As an initial test, you can run the existing example code for temperature sensor peripheral of the IO Shield. To do this navigate through and open File > Examples > IOShieldOled > IOShield_Oled_Demo. 
  6. Once the new sketch is opened, click the Verify button and this will compile successfully unless the library file is not included properly.
  7. Make sure you connect the Uno32 board via the mini-B connector on board to an available port on your computer.
  8. Place the IO shield on top of the Uno32 board with a bit of a firm press.
  9. Once connected, in your MPIDE window, select Tools>Board>chipKIT UNO32 to identify the UNO32 Board as the target
  10. Next, select Tools>Serial Port>COMxx. This will depend on which port was assigned to the chipKIT UNO32 Board when first connected.
  11. To load your sketch onto the chipKIT UNO32 board’s Microcontroller, press the Upload button. This will compile your sketch (check for errors) and then send to the Microcontroller. Unless you type your own code in the sketch, you wouldn’t need to verify them before uploading.
  12. Once the code is done uploading, open the serial monitor from the toolbar and after a few seconds of delay the temperature will be displayed in Celsius and Fahrenheit as shown below, tempsensor1
  13. As a next step, the Organic LED present in the IO shield can be used to display the temperature.
  14. Make sure that the jumper settings for JP4 on chipKIT Uno32 board is configured as SPI Slave Select input mode. You can find the jumper settings in chipKIT Uno32 board reference manual from the Digilent website. Also, ensure that the jumpers JP6/JP8 are configured to be used as I2C communication lines.
  15. To make the temperature be displayed on OLED, create a new sketch, save it by giving a name and insert the code below in the sketch space.
    #include <IOShieldTemp.h>
    #include <IOShieldOled.h>
    #include <Wire.h>
    
    int tensc = 0;
    int onesc = 0;
    int dot_tensc = 0;
    int dot_onesc = 0;
    int tensf = 0;
    int onesf = 0;
    int dot_tensf = 0;
    int dot_onesf = 0;
    int tempC=0;
    int tempF=0;
    
    void setup()
    {
      IOShieldOled.begin();
      IOShieldOled.displayOn();
      IOShieldTemp.config(IOSHIELDTEMP_ONESHOT | IOSHIELDTEMP_RES12);
    }
    void loop() 
    {
      float tempf, tempc;
      //Get Temperature in Celsius.
      tempc = IOShieldTemp.getTemp();
    
      // Convert the result to Fahrenheit.
      tempf = IOShieldTemp.convCtoF(tempc);
    
      //parse data for temperature in celcius
      tempC=tempc*100;
      dot_onesc = tempC%10;
      tempC = tempC/10;
      dot_tensc = tempC%10;
      tempC = tempC/10;
      onesc = tempC%10;
      tempC = tempC/10;
      tensc = tempC%10;
    
      //convert data to ASCII for temperature in celcius
       tensc = tensc+48;
       onesc = onesc+48;
       dot_tensc = dot_tensc+48;
       dot_onesc = dot_onesc+48;
    
      //parse data for temperature in Fahrenheit
      tempF=tempf*100;
      dot_onesf = tempF%10;
      tempF = tempF/10;
      dot_tensf = tempF%10;
      tempF = tempF/10;
      onesf = tempF%10;
      tempF = tempF/10;
      tensf = tempF%10;
    
      //convert data to ASCII for temperature in Fahrenheit
       tensf = tensf+48;
       onesf = onesf+48;
       dot_tensf = dot_tensf+48;
       dot_onesf = dot_onesf+48;
    
      //Clear the virtual buffer
      IOShieldOled.clearBuffer();
    
      //Draw a rectangle over wrting then slide the rectagle
      //down slowly displaying all writing
        IOShieldOled.clearBuffer();
        IOShieldOled.setCursor(0, 0);
        IOShieldOled.putString("Tempertaure is");
        IOShieldOled.setCursor(0, 2);
        IOShieldOled.putChar(tensc);
        IOShieldOled.setCursor(1, 2);
        IOShieldOled.putChar(onesc);
        IOShieldOled.setCursor(2, 2);
        IOShieldOled.putString(".");
        IOShieldOled.setCursor(3, 2);
        IOShieldOled.putChar(dot_tensc);
        IOShieldOled.setCursor(4, 2);
        IOShieldOled.putChar(dot_onesc);
        IOShieldOled.setCursor(6, 2);
        IOShieldOled.putString(" Degrees C");
        IOShieldOled.setCursor(0, 3);
        IOShieldOled.putChar(tensf);
        IOShieldOled.setCursor(1, 3);
        IOShieldOled.putChar(onesf);
        IOShieldOled.setCursor(2, 3);
        IOShieldOled.putString(".");
        IOShieldOled.setCursor(3, 3);
        IOShieldOled.putChar(dot_tensf);
        IOShieldOled.setCursor(4, 3);
        IOShieldOled.putChar(dot_onesf);
        IOShieldOled.setCursor(6, 3);
        IOShieldOled.putString(" Degrees F");
    
      delay(100);
    }
  16. In this code, the floating point values of temperature in celcius and fahrenheit are received, separated into digits by parsing the value and each digit is expressed in ASCII, aligning the position on OLED screen.
  17. To get more details on each function used with respect to OLED, open the IOShieldOLED folder which you downloaded from Digilent website and refer IOShield Library – Oeld.pdf. The same apply for functions for TEMP sensor too.
  18. To get the display, verify the code and upload it to the board. Once uploaded, you can see the temperature value displayed on OLED.
VN:F [1.9.22_1171]
Rating: 7.3/10 (3 votes cast)

Analog read serial on OLED

Overview:

In this project you will learn to use a basic functionality of chipKIT board, which is to read a analog value and output the corresponding digital reading for it. A potentiometer is a  three-terminal resistor with a sliding contact that forms an adjustable voltage divider. Using a potentiometer measuring instrument, you could measure the electric potential.

Hardware Used:

The hardware used in this tutorial will be a chipKIT Uno32 along with a chipKIT Basic I/O Shield both manufactured by Digilent Inc.

Reference:

The reference guide for each board, schematics and other resources are available on their individual homepages:

Procedure:

  1. Open MPIDE software on your PC and go to File > Examples > Basics > AnalogReadSerial to open the code which reads the analog signal on serial window.
  2. The code should look like this:
    /*
    AnalogReadSerial
    Reads an analog input on pin 0, prints the result to the serial monitor
    
    This example code is in the public domain.
    */
    
    void setup() {
    Serial.begin(9600);
    }
    
    void loop() {
    int sensorValue = analogRead(A0);
    Serial.println(sensorValue, DEC);
    }
    The function Serial.begin(), sets the data rate in bits per second (baud rate) for serial data transmission. In this case, the baud rate for communication between the computer and the chipKIT board is set to 9600. Using analogRead function, enables the chipKIT board to read the input voltage at port A0 ranging from 0 to 3.3 volts into values ranging from 0 to 1023 (as chipKIT board has a 10 bit A/D converter in it). Serial.println function, prints in a new line each time the values from sensorValue variable in decimal format.
  3. Make sure you connect the Uno32 board via the mini-B connector on board to an available port on your computer.
  4. Place the IO shield on top of the Uno32 board with a bit of a firm press. LEDs and A0-potentiometer of the IO shield will be used as peripherals for Uno32 board, in this excercise.
  5. Once connected, in your MPIDE window, select Tools>Board>chipKIT UNO32 to identify the UNO32 Board as the target
  6. Next, select Tools>Serial Port>COMxx. This will depend on which port was assigned to the chipKIT UNO32 Board when first connected.
  7. To load your sketch onto the chipKIT UNO32 board’s Microcontroller, press the upload button. This will compile your sketch (check for errors) and then send to the Microcontroller. Unless you type your own code in the sketch, you wouldn’t need to verify them before uploading.
  8. Once the code is done uploading, open the serial monitor from the toolbar shown below,                                                                                                                analogread96
  9. A new serial monitor window will appear as shown below,                                                                          analogread2
  10. The potentiometer on IO shield which provides input voltage to analog input A0 of UNO32 board, can be turned to get the varying voltage levels. Serial monitor window will show the decimal value change (between 0 to 1023) correspondingly.
  11. As a next step, the Organic LED present in the IO shield can be used to display the potentiometer values. For this, go to the chipKIT Basic I/O Shield homepage mentioned in Reference section.
  12. Download the zip file that contains libraries and documentation for using the Basic I/O Shield™ with the chipKIT MPIDE. Open the downloaded zip folder and copy the three IOShield folders in it. These three folders have the libraries and example programs for EEPROM, OLED and Temperature Sensor peripherals on IO shield.
  13. Now open the drive where you installed the mpide software, inside your mpide folder navigate through hardware > pic32 > libraries and paste the three IOShield folders in it.
  14. Close your mpide software, for the libraries to get included and the changes to take effect.
  15. On restarting the mpide software and navigating through File > Examples; you can find IOShieldEEPROM, IOShieldOled and IOShieldTemp folders with their demo examples being included.
  16. You can run the IOShield_Oled_Demo example as a new sketch, with the existing hardware setup, to observe the change in OLED display of IO shield.
  17. To make the ADC values display on OLED, create a new sketch, save it by giving a name and insert the code below in the sketch space.
    #include <IOShieldOled.h>
    
    int adc_data = 0;
    int thousands = 0;
    int hundreds = 0;
    int tens = 0;
    int ones = 0;
    
    void setup()
    {
      IOShieldOled.begin();
      IOShieldOled.displayOn();
    }
    
    void loop()
    {
      adc_data = analogRead(0);
    
      //parse data
      ones = adc_data%10;
      adc_data = adc_data/10;
      tens = adc_data%10;
      adc_data = adc_data/10;
      hundreds = adc_data%10;
      adc_data = adc_data/10;
      thousands = adc_data%10;
    
      //convert data to ASCII
       thousands = thousands+48;
       hundreds = hundreds+48;
       tens = tens+48;
       ones = ones+48;
    
      //Clear the virtual buffer
      IOShieldOled.clearBuffer();
    
      //Draw a rectangle over wrting then slide the rectagle
      //down slowly displaying all writing
        IOShieldOled.clearBuffer();
        IOShieldOled.setCursor(0, 0);
        IOShieldOled.putString("Analog read");
        IOShieldOled.setCursor(0, 1);
        IOShieldOled.putString("result is");
        IOShieldOled.setCursor(0, 3);
        IOShieldOled.putChar(thousands);
        IOShieldOled.setCursor(1, 3);
        IOShieldOled.putChar(hundreds);
        IOShieldOled.setCursor(2, 3);
        IOShieldOled.putChar(tens);
        IOShieldOled.setCursor(3, 3);
        IOShieldOled.putChar(ones);
    
      delay(100);
    
    }
  18. The above code gets the decimal valued data from the potentiometer in the IO shield, separates each number by modulo operation, converts the decimals into ASCII characters which are suitable OLED to read and displays it in OLED by assigning the cursor position.
  19. To get more details on each function used with respect to OLED, open the IOShieldOLED folder which you downloaded from Digilent website and refer IOShield Library – Oeld.pdf
  20. To get the display, verify the code and upload it to the board. Once uploaded, you can see the potentiometer value displayed on OLED. Turn the knob, to get values changing correspondingly.
VN:F [1.9.22_1171]
Rating: 8.0/10 (3 votes cast)
VN:F [1.9.22_1171]
Rating: +1 (from 1 vote)