=====VATT Thermal System===== The VATT Thermal System is controlled by an Arduino Mega board located in the mirror cell. It is connected to 7 analog AD 590K thermal sensors. Four of these sensors are located on the telescope struts and 3 are in the mirror cell. The Arduino board communicates with vatttel through an RS-232 serial port. vatttel (TCS) requests the thermal information from each thermal sensor over the serial port by sending a 't' followed a carriage return '\r'. The arduino board then sends a string of white space separated temperatures. ===Thermal Daughter Board=== The thermal daughter board is a circuit board that sits on top of the arduino board. It has 1 serial port 2 mux chips and 3 Phoenix Connectors. Each Mux chip has four channels to handle the analog signal coming from the 7 thermal sensors. ^Mux Channel^ GUI Name ^ Wire Label ^ Phoenix Connector ^ Signal Wire Color^ |00 |Mirror Temp | T1 |P9 |White | |01 |Mirror Air Temp| T0 |P9 |Red | |02 |Mirror Temp | T2 |P9 |Red | |03 |Air Temp | T3 |P10 |Red | |10 |Strut Temp | T4 |P10 |White | |11 |Strut Temp | T5 |P10 |Red | |11 |Air Temp | T6 |P11 |White | ===Firmware=== Firmware as of 9-3-2014 #include #include #define NCHAN 8//Number of channels. #define AVGCNTS 100.0//Number of values to average over #define MV_PER_KEL 10.0 //Resistor value #define KEL2CEL -272.1 #define MV_PER_CNT 0.188 #define KELS_PER_CNT MV_PER_CNT/MV_PER_KEL /*This is the firmware that resides on the Arduino mMega VATT Thermal system board. It reads in temperatures from seven analog sensors located on the VATT Telescope. When Querried with a 't\r' via its serial port it returns a string of 7 white space seperated temperatures followed by a '\n' The order of the sensor data located in the return string is as follows: MIRROR_TEMP MIRROR_AIR_TEMP MIRROR_TEMP AIR_TEMP STRUT_TEMP STRUT_TEMP AIR_TEMP For more information on the VATT thermal system please go to this website: https://soweb.as.arizona.edu/~tscopewiki/doku.php?id=vatt:mirror_cell_thermal_reader Author Scott Swindell Date 9-3-2014 */ Adafruit_ADS1115 ads1( 0x48 ); //first mux chip Adafruit_ADS1115 ads2( 0x49 ); //Second mux chip char inChar;//The charactre read in from the serial port. char lastInChar; long adc_sum[NCHAN];//keeps a sum of the temperature readings for averaging int16_t adc[NCHAN];//Stores averaged temperature readings int inVal; int val13;//For toggling pin 13 short sum_iter = 1;//keeps count of how many we have summed //Offsets. Most of this is counter-acting the hard coded offsets in //vatttel float temp_offsets[NCHAN] = {0.4, 2.7, 0.4, -1.5, 3.3, 3.3, -1.5, 0.0}; void setup(void) { val13 = HIGH; pinMode(13, OUTPUT); digitalWrite( 13, val13 ); //Serial.begin(9600); Serial3.begin(9600); /* Serial.println("Hello!"); Serial.println("Getting single-ended readings from AIN0..3"); Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV/ADS1015, 0.1875mV/ADS1115)");*/ // The ADC input range (or gain) can be changed via the following // functions, but be careful never to exceed VDD +0.3V max, or to // exceed the upper and lower limits if you adjust the input range! // Setting these values incorrectly may destroy your ADC! // ADS1015 ADS1115 // ------- ------- ads1.setGain(GAIN_TWOTHIRDS); // 2/3x gain +/- 6.144V 1 bit = 3mV 0.1875mV (default) ads2.setGain(GAIN_TWOTHIRDS); // ads.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV // ads.setGain(GAIN_TWO); // 2x gain +/- 2.048V 1 bit = 1mV 0.0625mV // ads.setGain(GAIN_FOUR); // 4x gain +/- 1.024V 1 bit = 0.5mV 0.03125mV // ads.setGain(GAIN_EIGHT); // 8x gain +/- 0.512V 1 bit = 0.25mV 0.015625mV // ads.setGain(GAIN_SIXTEEN); // 16x gain +/- 0.256V 1 bit = 0.125mV 0.0078125mV //ads2.setGain(GAIN_TWOTHIRDS); // ads1.begin(); ads2.begin(); } void loop(void) { /*In the arduino loop function we do the reading of the *analogue temp sensors and keep a sum of each channel *After ACGCNTS number of loops we average the last previous data and *store it in the adc array. */ //read first mux chip and sum it with last previous readings for (short channel_num=0; channel_num<( 4 ); channel_num++) { inVal = ads1.readADC_SingleEnded( channel_num ); adc_sum[channel_num] = inVal + adc_sum[channel_num]; } //read the second mux chip and average it with last reading for (short channel_num=0; channel_num<( 4 ); channel_num++) { inVal = ads2.readADC_SingleEnded( channel_num ); adc_sum[channel_num + 4] = inVal + adc_sum[channel_num+4]; //delay(10); //if( channel_num+4 == 6 ){ Serial.println(inVal); } } if (sum_iter == AVGCNTS) { for( short channel_num=0; channel_num