El presente sitio presenta diseños y proyectos realizados con Solidworks y otros programas 3d , además de laminas y modelos 3d para practicar en casa, con el único objetivo de poder aprender y explorar la capacidad de Solidworks, no existiendo en ningún caso fines de lucro.

Saturday, July 11, 2015

medidor de frecuencias con TIMER y PIC / Frequency measurement using PIC as timer

Posted by Juan Francisco | Saturday, July 11, 2015 | Category: |

frequency measurement using two counterThis tutorial is about measuring the frequency of a signal.To count a signal frequency many techniques are available.After some googling results in a delay method which makes a 1 second delay, by the meantime a counter counts the pulses.Then the number of pules will be the frequency of the signal. But it makes some problem such as
  • When it makes delay microcontroller cpu is idle for 1 second.
  • It reduces the speed of the process.
  • Other works are stopped at the time of frequency measurement.
So we need a solution where we can measure frequency as well as all the problems will be solved.
Actually the solution is very easy.You have to use two timer at a time.One timer as a counter and another one is used to make a delay.As timer can run freely without disturbing the cpu and can generate interrupts so all problems will be vanished and calculation will be more accurate and smart.
In this tutorial PIC16f873 is used,codes are written in MikroC Pro For PIC ,whole project are simulated in Proteus 7.6. You can download the all the files (including ISIS schematic,MikroC Project files) from the link given below the post.
Here Timer1 is used to make a delay of 1 second.You can make any time delay using a timer just take help of a very good tool called Timer Calculator which can generate code according to your need. Just input your controller frequency,the timer you want to use,the time delay you want.According to my need it was like below
 image
Then just copy the code to your MikroC editor.Then initialize Timer0 as a counter.You have to write the code
T0CS_bit=1;
T0SE_bit=0;
TMR0IE_bit=1;
Now open the project file which you downloaded and build it.Open the .DSN schematic file in Proteus and load the hex.A pulse of frequency 1000Hz is fed to T0CKI pin.Then run the schematic.If there is no error then Lcd will show exactly 1000Hz.You can change the frequency.
frequency measurement using two counter
You can add your code according to your project and just take the value of frequency when you need. If you have any problem to understand the tutorial please put a comment or mail me.Don,t forget to share the post.
Download the project files from here.

Currently have 1 comentarios:

  1. Aw, this was an incredibly good post. Finding the time and actual effort to make a great
    article… but what can I say… I procrastinate a whole lot and never
    seem to get anything done.


Leave a Reply

Te doy la bienvenida al blog , puedes escribir tu comentario en la casilla mostrada abajo ,gracias.
You are welcome in this blog , you can write your comment in the box shown below, thanks.