ennng
Junior Member level 2
- Joined
- Nov 1, 2012
- Messages
- 20
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,420
Hi everyone!
I am trying to measure the phase shift between two signals that have the same frequency.
I want use two channels of ADC and then use a counter to count if the first signal reach zero and the counter stop when the second signal hit the zero and then measure this time with give the phase difference. Any help please.
I am trying to measure the phase shift between two signals that have the same frequency.
I want use two channels of ADC and then use a counter to count if the first signal reach zero and the counter stop when the second signal hit the zero and then measure this time with give the phase difference. Any help please.
Code:
int i;
int time;
signed flot x;
signed flot y;
void main(){
TRISA=1; TRISB=0;
PORTB=0;
TRISC=0;
PORTC=0;
time=0;
while(1){
x=adc_read(0);
y=adc_read(1);
if(adc_read(0)==0)while(adc_read(1)>0){time++; delay_ms(1)}
{portc=time;}
}
}