How do I convert an internal variable into frequency
I am using a 10 bit A/D converter on a 16F877A. The input is from a voltage divider where one of the resistors is the sensing element. What I want to do is determine the dv/dt (frequency) across the sensor and use a set value to trigger an event. All of the examples I have come across have an external frequency source, my application is using the output from the A/D converter (0 t0 1024). I have some code (peak detector) to give me a count and I know this value must be divided by a time period to give me the frequency. Can someone steer me in the right direction?
How do I convert an internal variable into frequency
For sake of argument, let us say that I am using a temperature sensor. Normally the temperature (output of the A/D) is constant. When the temperature changes, I want to know the rate of change.
How do I convert an internal variable into frequency
The sensor connected to the A/D normally produces a constant , fixed output. The A/D output is therefore also fixed at this point in time. When a flow is present, the sensor produces a sin wave output whose frequency is dependant on the flow rate. The A/D output produces a series of varying numerical values if plotted against time would look like a sin wave. I have a program that will detect the numerical peak of each sin wave and I can count these peaks. Right now, I am using a timer (TMR0) with interrupts to generate the time base. This timer is activated when flow starts. The count /time will give me the frequency. The program will have a variable trip value i.e. when f >= trip then alarm. My program is almost operational with a few bugs remaining to be worked out.
I have built this circuit using Op Amps etc., and now I would like to keep up with the times and reduce the number of components using a PIC.
I wish to thank all those who have contributed and still might contribute to this thread.
R.W.S.
How do I convert an internal variable into frequency
It was my error to mention dv/dt. Although I would like to measure this also, the frequency is what I am looking for.
Thank you IOANNIS for your suggestions but my thrust right now is to try and do it all with the 16F877A.
The program I have right now runs just fine when it is compiled and programmed under ICD. Using the real time compiler and programmer it doesn't work?????
Any suggestions?
How do I convert an internal variable into frequency
After playing with the program over the weekend I discovered two registers (intcon and option_reg) were incorrectly configured. The "Clock" generating ticks was not turning off . Steping through the program with the registers displayed the MCSP revealed the defect. Thank you IOANNIS for you offer to provide further assistance. I think I have a good start now with other obsticles yet to overcome.