Microcontroller › AVR › frequency measurement and display on LCD
- This topic has 8 replies, 3 voices, and was last updated 12 years, 3 months ago by AJISH ALFRED.
-
AuthorPosts
-
May 13, 2012 at 8:53 pm #1797sanamParticipant
Dear reader,
could you please provide me code for sampling frequency readings from 555 timer oscillator into ATmega 16 kit. I am finding it difficult to count the frequency reading and display it in the LCD showing the level of water level measurement. From the hardware configuration i a have found frequency reading as follows
at 0cm water level = frequency is 900khz
at 1 cm ,872khz
at 2 cm 864khz
.
.
.
at 30 cm, 435 khz
how can intake this random frequency range into the atmega16 kit and display the output in the LCD.
i would be most grateful for your support and guidance.
Thank you.
May 14, 2012 at 2:54 pm #7797AnonymousGuestHi,
Really interesting project. Could you please tell me how are you generating different frequencies according to the water level using 555 IC ?
May 14, 2012 at 2:54 pm #7810AnonymousGuestHi,
Really interesting project. Could you please tell me how are you generating different frequencies according to the water level using 555 IC ?
May 14, 2012 at 7:33 pm #7801sanamParticipantDear reader,
Lets say the experiment i am doing is divided into 4 parts like any other measurement device principle: 1) the sensing element, 2)The signal conditioning element 3)signal processing element and software 4)data presentation element.
The sensing element in my experiment is the capacitive co-axial probe that operates using capacitive principle,As you immerse the probe in the water, the di-electric medium in between the 2 electrodes increase further increasing the capacitance. I have connected this probe to a frequency oscillator designed using a 555 timer in astable mode. The sensed signal is enhanced by this oscillator into a frequency domain. The frequency of the signal decreases as capacitance of the probe increases.WE have the relation as,
f =1/(2*pi*(LC)^1/2) for an LC circuit
f= 1.44/{(R1+2R2) C} for an RC circuit n this is my circuit and i have designed keeping my own values.
hence, when the probe is immersed in the water at0 cm scale, the frequency received is 872khz,further more as i went on taking the reading,the final point i needed to take is at 30 cm scaling and i received 435khz. So there is a frequency range of 400khz to 900khz.now i need to feed this signal to the ATmega16 controller. Its bit tricky at this point. The data sheet for atmega16 can be found in the internet. I know frequency and time is inversely related and i need to use timers .how ever i am stuck at this point of writing the codes,if anyone could help ma,then please i ask for it ,your effort,guidance and sample codes could lead to my progress.
thanking you
May 14, 2012 at 7:33 pm #7812sanamParticipantDear reader,
Lets say the experiment i am doing is divided into 4 parts like any other measurement device principle: 1) the sensing element, 2)The signal conditioning element 3)signal processing element and software 4)data presentation element.
The sensing element in my experiment is the capacitive co-axial probe that operates using capacitive principle,As you immerse the probe in the water, the di-electric medium in between the 2 electrodes increase further increasing the capacitance. I have connected this probe to a frequency oscillator designed using a 555 timer in astable mode. The sensed signal is enhanced by this oscillator into a frequency domain. The frequency of the signal decreases as capacitance of the probe increases.WE have the relation as,
f =1/(2*pi*(LC)^1/2) for an LC circuit
f= 1.44/{(R1+2R2) C} for an RC circuit n this is my circuit and i have designed keeping my own values.
hence, when the probe is immersed in the water at0 cm scale, the frequency received is 872khz,further more as i went on taking the reading,the final point i needed to take is at 30 cm scaling and i received 435khz. So there is a frequency range of 400khz to 900khz.now i need to feed this signal to the ATmega16 controller. Its bit tricky at this point. The data sheet for atmega16 can be found in the internet. I know frequency and time is inversely related and i need to use timers .how ever i am stuck at this point of writing the codes,if anyone could help ma,then please i ask for it ,your effort,guidance and sample codes could lead to my progress.
thanking you
May 14, 2012 at 7:36 pm #7803sanamParticipanti would be most grateful if anybody could help me.
Thanking you
May 14, 2012 at 7:36 pm #7813sanamParticipanti would be most grateful if anybody could help me.
Thanking you
May 16, 2012 at 10:46 am #7835sanamParticipantThis is my approach but i am not getting anything. could u please help me where am i doing wrong.
Your help and guidance is heartily acknowledged.
#include <avr/io.h>#include <util/delay.h>#include <stdio.h>#include <avr/interrupt.h>#include <compat/ina90.h>#include “easyavr_lcd.c”volatile ov_counter;unsigned long frequency;ISR(TIMER1_CAPT_vect){// Counter to 0TCNT1 = 0;// The result is valid only if the counter// has not overflowed yetif (!(TIFR & (1 << TOV1))){// Calculating the frequency from the periodfrequency = (unsigned long)8000000 /(unsigned long)ICR1;}}ISR(TIMER1_OVF_vect){ov_counter++;}void init_timer(){TCCR1B = (1<<ICES1) | (1<<CS10);TIMSK = (1<<TICIE1) | (1<<TOIE1);}int main(){DDRB = 0x00;init_timer();lcdinit();lcdmsg(“CURRENT LVL”,1);char a1[7];sei();while(1){lcdmsg(“CURRENT LVL”,1);itoa(frequency, a1, 10);lcdmsg(a1,2);lcdmsg(“CURRENT LVL”,1);_delay_ms(500);lcdclr();}return 1;}May 21, 2012 at 6:19 pm #7863AJISH ALFREDParticipantThe LCD is your only output device; you are not getting means, no display on LCD?
First thing I’ve noted in your code is the refereshing rate. Try giving a bit more delay around 2 seconds before clearing the LCD inside the while loop.
-
AuthorPosts
- You must be logged in to reply to this topic.