this is my code. here i am getting value of adc on uart. but after removing sensor, i am also getting values which is near to original. here i am controlling device using adc. i want zero value on adc when sensor is disconnected
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
this is my code. here i am getting value of adc on uart. but after removing sensor, i am also getting values which is near to original. here i am controlling device using adc. i want zero value on adc when sensor is disconnected
When your pin is floating you will measure
A high impedance floating pin is never an option. Also for a digital input. If you use a pin as an input button for example, then you always set a pull-up/down resistor to have a defined potential on the pin when the button is not pressed and therefore would be floating.
The solution for you depends on the sensor you are using. Can it drive a load (pull-down-resistor)? What type of sensor is it?
Dennis
>i am making ecg acquisition system. so i am using disposable electrode as sensor
Then you shall read www.ti.com/.../slaa486a.pdf
Particular ECG have frontend which does not float ADC inputs while electrodes are not attached.
from document
"If the voltage on the left pad exceeds 1.7 V, the contact is considered good, and the green LED
on the LaunchPad flashes briefly. If the voltage exceeds 1.5 V, the contact is considered bad and the red
LED flashes briefly. The default value on the pad for no contact is 0.825 V "
i think here they use software coding for sensor is connected or not. in my code it take value 1.12,1.2 continuously
#include <msp430.h> #include <math.h> #define UART_TXD 0x02 // TXD on P1.1 (Timer0_A.OUT0) #define UART_TBIT (1000000 / 9600) // 9600 Baud, SMCLK = 1MHz // Globals for transmit UART communication unsigned int txData; // UART internal variable for TX void TimerA_UART_tx(unsigned char byte); // Function prototypes void TimerA_UART_print(char *string); int temp1,adc,adc1; float supply = 3.70; char disp_res; unsigned char temp; int a,b,c; int v; void main(void){ WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer DCOCTL = 0x00; // Set DCOCLK to 1MHz BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; // DCOCTL = CALDCO_16MHZ; // set internal oscillator at 16MHz // BCSCTL1 = CALBC1_16MHZ; // set internal oscillator at 16MHz // ADC10CTL1 |= CONSEQ1; //continuous sample mode, MUST BE SET FIRST! // ADC10CTL0 |= ADC10SHT_2 + ADC10ON + MSC; //sample and hold time, adc on, cont. sample ADC10CTL0 |= ADC10ON + ADC10SHT_3 + MSC; ADC10CTL1 |= ADC10SSEL_3 + ADC10DIV_7 + CONSEQ_2; ADC10AE0 |= 0x01; // select channel A0 ADC10CTL0 |= ADC10SC + ENC; // start conversions P1OUT = UART_TXD; // Initialize P1.1 P1SEL = UART_TXD; // Timer function for TXD pin P1DIR = UART_TXD; // Set TXD pin to output // Timer_A for transmit UART operation TA0CCTL0 = OUT; // Set TXD Idle as Mark = '1' TA0CCTL1 = SCS + CM1 + CAP; // Sync, Neg Edge, Capture TA0CTL = TASSEL_2 + MC_2; // SMCLK, start in continuous mode _BIS_SR(GIE); // Enable CPU interrupts while(1) { //TimerA_UART_print("\n"); //__delay_cycles(500000); // __delay_cycles(500000); //__delay_cycles(500000); v = ADC10MEM; v=v/3; // v=v+6; // v = (v*3.3)/1024; a=v/100; b=v/10; b=b%10; c=v%10; TimerA_UART_tx(a+0x30); TimerA_UART_tx('.'); TimerA_UART_tx(b+0x30); TimerA_UART_tx(c+0x30); TimerA_UART_tx(0x0D); TimerA_UART_tx(0x0A); //disp_res =( v*supply)/1024; //TimerA_UART_print("Volt:"); //TimerA_UART_print(disp_res); //TimerA_UART_tx(disp_res); //TimerA_UART_tx(b); } } void TimerA_UART_tx(unsigned char byte) { // Outputs one byte using the Timer_A UART while (TACCTL0 & CCIE); // Ensure last char got TX'd TA0CCR0 = TAR; // Current state of TA counter TA0CCR0 += UART_TBIT; // One bit time till first bit txData = byte; // Load transmit data, e.g. 'A'=01000001 txData |= 0x100; // Add mark stop bit, e.g. 101000001 txData <<= 1; // Add space start bit, e.g. 1010000010 TA0CCTL0 = OUTMOD0 + CCIE; // Set TXD on, enable counter interrupt } void TimerA_UART_print(char *string) { // Prints a string using the Timer_A UART while (*string) TimerA_UART_tx(*string++); } #pragma vector = TIMER0_A0_VECTOR // Timer_A UART - Transmit ISR __interrupt void Timer_A0_ISR(void) { static unsigned char txBitCnt = 10; TA0CCR0 += UART_TBIT; // Add Offset to CCRx if (txBitCnt == 0) { // All bits TXed? TA0CCTL0 &= ~CCIE; // All bits TXed, disable interrupt txBitCnt = 10; // Re-load bit counter } else { if (txData & 0x01) TA0CCTL0 &= ~OUTMOD2; // TX Mark '1' else TA0CCTL0 |= OUTMOD2; // TX Space '0' } txData >>= 1; // Shift right 1 bit (low bits TX'ed first) txBitCnt--; }
still i am confused about solution
**Attention** This is a public forum