Other Parts Discussed in Thread: LM335
Hello,
I am using LM335 to measure the temperature of the hand
so I am getting quite high values > 700 degree Celsius
I am not sure why that is happening, I have the sensor connected to a ground pin through the negative terminal, and I used a 1 Kohm connected to Vcc and then to the positive terminal which is also connected to A1
I am sure of my code but I will show it just in case
#include <msp430g2553.h>
#ifndef TIMER0_A1_VECTOR
#define TIMER0_A1_VECTOR TIMERA1_VECTOR
#define TIMER0_A0_VECTOR TIMERA0_VECTOR
#endif
void FaultRoutine(void);
void ConfigWDT(void);
void ConfigClocks(void);
void ConfigLED(void);
void ConfigADC10(void);
void ConfigTimerA2(void);
//volatile int lightRead=0;
volatile float TRead=0;
int main(void) {
volatile unsigned int i;
ConfigWDT();
ConfigClocks();
ConfigLED();
ConfigADC10();
ConfigTimerA2();
_BIS_SR(GIE); //Enable global interrupts
while(1);
}
void ConfigWDT(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
}
void ConfigClocks(void)
{
if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)
FaultRoutine(); // If calibration data is erased
// run FaultRoutine()
BCSCTL1 = CALBC1_1MHZ; // Set range
DCOCTL = CALDCO_1MHZ; // Set DCO step + modulation
BCSCTL3 |= LFXT1S_2; // LFXT1 = VLO
IFG1 &= ~OFIFG; // Clear OSCFault flag
BCSCTL2 |= SELM_0 + DIVM_3 + DIVS_3; // MCLK = DCO/8, SMCLK = DCO/8
BCSCTL1 |= DIVA_3; // ACLK -> 1.5 KHz
}
void FaultRoutine(void)
{
P1OUT = BIT0; // P1.0 on (red LED)
while(1); // TRAP
}
void ConfigLED(void){
P1DIR = BIT0+BIT6; // P1.0 (red) output
P1OUT = 0; // LED off
}
void ConfigADC10(void){
ADC10CTL1 = INCH_1 + ADC10DIV_1; //Choose input channel and choose clock frequency
ADC10CTL0 |= SREF_0 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE; //Vcc to Vss as reference and turn on
_delay_cycles(30); // Wait for ADC Ref to settle
ADC10AE0 = BIT1; //Enable ADC input through PIN 1.3
}
void ConfigTimerA2(void){
CCTL0 = CCIE; // Allow periodic interrupt
TACTL = TASSEL_1 + MC_1+ ID_3;
CCR0 = 187; // Enable interrupts every 1 second
}
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_A_ISR (void){
while (!(ADC10IFG & ADC10CTL0)){ // Check if the conversion is completed
ConfigADC10();
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
}
TRead = ADC10MEM;
TRead = TRead - 273.15;
ADC10CTL0 &= ~ADC10IFG;
ADC10CTL0 &= ~ENC; // Disable ADC conversion
ADC10CTL0 &= ~(REFON + ADC10ON); // Reference and ADC10 off
CCR0 += 187;
}