torchd
Newbie level 3

Hi guys
I am new to PIC microcontrollers. I am measuring relative humidity in a room by using a resistive humidity sensor. The sensor uses an ac signal. I have generated the ac signal by using the PWM signal from a PIC 4520( 1kHz 0-5V). I send this signal to an op amp and convert the signal to -1 to +1 V square wave. What I need to know is how do I sample the voltage across the sensor and know when my voltage is high(+1V) to be able to sync my ADC samplings.
(I am using CCP1 and Timer 2 )
Thanks in advance
The Code I used to generate the PWM signal is shown below:
#include <htc.h>
void main()
{
int i;
OSCCON = 0b01111110; //oscillator control register set for 8mhz
TRISC=0x00;
T2CON = 0b00000110; // prescaler + turn on TMR2;
PR2 = 0b001111111;
CCP1CON = 0b00111100;
CCPR1L=63;
//TMR2ON=1;
while(1)
{
}
}
I am new to PIC microcontrollers. I am measuring relative humidity in a room by using a resistive humidity sensor. The sensor uses an ac signal. I have generated the ac signal by using the PWM signal from a PIC 4520( 1kHz 0-5V). I send this signal to an op amp and convert the signal to -1 to +1 V square wave. What I need to know is how do I sample the voltage across the sensor and know when my voltage is high(+1V) to be able to sync my ADC samplings.
(I am using CCP1 and Timer 2 )
Thanks in advance
The Code I used to generate the PWM signal is shown below:
#include <htc.h>
void main()
{
int i;
OSCCON = 0b01111110; //oscillator control register set for 8mhz
TRISC=0x00;
T2CON = 0b00000110; // prescaler + turn on TMR2;
PR2 = 0b001111111;
CCP1CON = 0b00111100;
CCPR1L=63;
//TMR2ON=1;
while(1)
{
}
}