arduino documentation.docxedge.rit.edu/content/p13623/public/workingdocuments/msd... · web...

9
Arduino Documentation Arduino-LabVIEW Interface: Heat Transfer Hardware Heat Transfer Apparatus 1. Temperature Sensors: Thermistors a. The thermistors, model 317-1381-ND procured by Digikey, are mounted at the end of plastic arms. The resistance in a thermistor is variable (function of temperature) and is measured by the voltage drop across a 10K ohm resistor. 2. LCD Screen a. The LCD screen is a LCD-00710 with a number of inputs and outputs as indicated by the table below.

Upload: others

Post on 03-Sep-2020

24 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Arduino Documentation.docxedge.rit.edu/content/P13623/public/WorkingDocuments/MSD... · Web viewArduino Documentation Arduino-LabVIEW Interface: Heat Transfer Hardware Heat Transfer

Arduino DocumentationArduino-LabVIEW Interface: Heat Transfer

Hardware

Heat Transfer Apparatus

1. Temperature Sensors: Thermistorsa. The thermistors, model 317-1381-ND procured by Digikey, are mounted at the

end of plastic arms. The resistance in a thermistor is variable (function of temperature) and is measured by the voltage drop across a 10K ohm resistor.

2. LCD Screena. The LCD screen is a LCD-00710 with a number of inputs and outputs as

indicated by the table below.

Page 2: Arduino Documentation.docxedge.rit.edu/content/P13623/public/WorkingDocuments/MSD... · Web viewArduino Documentation Arduino-LabVIEW Interface: Heat Transfer Hardware Heat Transfer

The LCD operates using the KS0108 Graphics LCD Library, required for modification of the arduino code.

LCD Screen with Two Sensors Connected3. LED Light Array

The LED light array is a series of RGB LEDs that changed color based on the software. These are attached to the arduino to two digital ports for the clock and data, the red to 5V, and yellow to ground.

LED Light Array Wires

Blue Clock

Green Data

Red VCC

Yellow Ground

Page 3: Arduino Documentation.docxedge.rit.edu/content/P13623/public/WorkingDocuments/MSD... · Web viewArduino Documentation Arduino-LabVIEW Interface: Heat Transfer Hardware Heat Transfer

LEDs Example

4. Pressure SensorThe pressure sensors mounted in the apparatus is a 100 lb Flexiforce pressure

sensor, model SEN-08685. The resistance within the sensor is variable based on the pressure applied.

Flexiforce Pressure Sensor (100 lbs)

Software

Software Architecture1. LabVIEW Sampling, Read in Resistances to LabVIEW2. Sensor Reading3. Converting Sensor Reading (Resistance) to Temperature 4. Displaying Temperature Reading on LCD Screen5. Convert Temperature Readings to HSV6. Convert HSV to RGB to Int32 Color Function to LED Strip

Page 4: Arduino Documentation.docxedge.rit.edu/content/P13623/public/WorkingDocuments/MSD... · Web viewArduino Documentation Arduino-LabVIEW Interface: Heat Transfer Hardware Heat Transfer

The majority of the code below is commented. This can be viewed easier in an editor such as notepad++ under C (language).

/********************************************************************************* ** ** Includes. ** ********************************************************************************/// Standard includes. These should always be included.#include <Wire.h>#include <SPI.h>#include <Servo.h>#include "LabVIEWInterface.h" #include <WS2801.h>#include <glcd.h>

// include the Fonts#include <fonts/allFonts.h>

// Constantsfloat RINF = 0.0881613489;int B = 3950; //int dataPin = 2;int clockPin = 3;int MAXHDEG = 240;unsigned long timeReset =0;

// HSV to RGB Convertervoid HSV_to_RGB(float h, float s, float v, byte *r, byte *g, byte *b){ float f,p,q,t; int i; h = max(0.0, min(240.0, h)); s = max(0.0, min(100.0, s)); v = max(0.0, min(100.0, v)); s /= 100; v /= 100; if(s == 0) { // Achromatic (grey) *r = *g = *b = round(v*255); return; } h /= 60; // sector 0 to 5 i = floor(h); f = h - i; // factorial part of h p = v * (1 - s); q = v * (1 - s * f); t = v * (1 - s * (1 - f)); switch(i) { case 0: *r = byte(round(255*v)); *g = byte(round(255*t)); *b = byte(round(255*p));

Page 5: Arduino Documentation.docxedge.rit.edu/content/P13623/public/WorkingDocuments/MSD... · Web viewArduino Documentation Arduino-LabVIEW Interface: Heat Transfer Hardware Heat Transfer

break; case 1: *r = byte(round(255*q)); *g = byte(round(255*v)); *b = byte(round(255*p)); break; case 2: *r = byte(round(255*p)); *g = byte(round(255*v)); *b = byte(round(255*t)); break; case 3: *r = byte(round(255*p)); *g = byte(round(255*q)); *b = byte(round(255*v)); break; case 4: *r = byte(round(255*t)); *g = byte(round(255*p)); *b = byte(round(255*v)); break; default: // case 5: *r = byte(round(255*v)); *g = byte(round(255*p)); *b = byte(round(255*q)); }}

// Set the first variable to the NUMBER of pixels. 25 = 25 pixels in a rowWS2801 strip = WS2801(18, dataPin, clockPin);

// Thermistor Function , Returns Temp in Ffloat TemperatureReturn(int sensorValue){ //float T0 = 298.15; // K float voltage= sensorValue * (5.0 / 1024.0); float resistance = ((5.0/voltage) - 1)*10000; float divs = resistance/RINF; float logval = log(divs); float t1 = B/ logval; return (( t1 - 273.15) * 9.0)/ 5.0 + 32.0; // Deg F }// Thermistor Function , Returns Temp in Ffloat ResistanceReturn(int sensorValue){ //float T0 = 298.15; // K float voltage= sensorValue * (5.0 / 1024.0); return ((5.0/voltage) - 1)*10000; }

/* Helper functions */

// Create a 24 bit color value from R,G,Buint32_t Color(byte r, byte g, byte b){ uint32_t c; c = r; c <<= 8; c |= g; c <<= 8; c |= b;

Page 6: Arduino Documentation.docxedge.rit.edu/content/P13623/public/WorkingDocuments/MSD... · Web viewArduino Documentation Arduino-LabVIEW Interface: Heat Transfer Hardware Heat Transfer

return c;}

/********************************************************************************* ** setup() ** ** Initialize the Arduino and setup serial communication. ** ** Input: None ** Output: None *********************************************************************************/void setup(){ // Initialize Serial Port With The Default Baud Rate syncLV(); GLCD.Init(); Serial.begin(9600); // Select the font for the default text area GLCD.SelectFont(System5x7); // Place your custom setup code here strip.begin(); // Update LED contents, to start they are all 'off' strip.show();}

/********************************************************************************* ** loop() ** ** The main loop. This loop runs continuously on the Arduino. It ** receives and processes serial commands from LabVIEW. ** ** Input: None ** Output: None *********************************************************************************/

void loop(){ // Check for commands from LabVIEW and process them.

checkForCommand(); // Place your custom loop code here (this may slow down communication with LabVIEW) int sensorValue[5]; float Temp[9]; float Res[9]; byte r,g,b; float SATURAION = 100.0; float VALUE = 100.0; if (millis() >= (timeReset+2000)) { // Read Sensor Values sensorValue[0] = analogRead(A0); sensorValue[1] = analogRead(A1); sensorValue[2] = analogRead(A2); sensorValue[3] = analogRead(A3); sensorValue[4] = analogRead(A4);

Page 7: Arduino Documentation.docxedge.rit.edu/content/P13623/public/WorkingDocuments/MSD... · Web viewArduino Documentation Arduino-LabVIEW Interface: Heat Transfer Hardware Heat Transfer

sensorValue[5] = analogRead(A5); sensorValue[6] = analogRead(A6); sensorValue[7] = analogRead(A7); sensorValue[8] = analogRead(A8); sensorValue[9] = analogRead(A9); sensorValue[10] = analogRead(A10); sensorValue[11] = analogRead(A11);

// GLCD Stuff GLCD.ClearScreen(); GLCD.CursorTo(0, 1); GLCD.print("#|Temp (F)|# |Temp(F)\n"); for(int i = 0; i < 6; i++){ GLCD.print((i+1), DEC); GLCD.print("| "); Temp[i] = TemperatureReturn(sensorValue[i]); if ( (Temp[i]) > 0){ GLCD.print(Temp[i], 2); GLCD.print(" |"); } else { GLCD.print("-------"); GLCD.print("|"); }

// Returning Resistance //Temp[2*i+1] = TemperatureReturn(sensorValue[2*i+1]); if (i < 5){ GLCD.print((i+7), DEC); GLCD.print("| ");

if ( (Temp[i+7]) > 0){ Temp[i+7] = TemperatureReturn(sensorValue[i+7]); GLCD.print(Temp[i+7], 2); } else { GLCD.print("-----");

} } GLCD.print("\n"); //Temp[2*i+2] = TemperatureReturn(sensorValue[2*i+1]);// //Set the Pixel Color For each of the 18 // //H = 240*Temp/212 (0 to 240 deg) of (0 to 212 deg)

//There are 18 for(int ii = 0; ii < 4; ii++){ HSV_to_RGB((240*Temp[i]/212), SATURAION, VALUE,&r,&g,&b); strip.setPixelColor(i*4+ii,Color(r,g,b)); } // set the cursor to column 0, line 1 // (note: line 1 is the second row, since counting begins with 0): } timeReset = millis(); //Reset time since last reading strip.show(); // Write out pixels

Page 8: Arduino Documentation.docxedge.rit.edu/content/P13623/public/WorkingDocuments/MSD... · Web viewArduino Documentation Arduino-LabVIEW Interface: Heat Transfer Hardware Heat Transfer

} // Some example procedures showing how to display to the pixels //colorWipe(Color(TemperatureReturn(sensorValue[0])/250, 0, 0), 50);

if(acqMode==1) { sampleContinously(); }}