How do I convert an internal variable into frequency


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Nov 2006
    Location
    Brooklyn,NY
    Posts
    32

    Default 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?

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default

    Hi! You have not mentioned if the values come with a regular rate. If they do then I suppose you have to use maths (diferrentiation) to get your value.

    I am not an math's expert though.

    Another method might be to use Interrupts and check the value from A/D. Then use select case commands to decide whta to do.

    Ioannis

  3. #3
    Join Date
    Nov 2006
    Location
    Brooklyn,NY
    Posts
    32


    Did you find this post helpful? Yes | No

    Default 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.

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default

    Hi,
    You need to sample your analog signal at precise intervals. Then, to find the rate of change, it's just a matter of comparing the last reading with the new one.

    At what interval you sample depends on the expected rate of change of the signal. If it's temperature you should perhaps sample once every second, minute or even hour but if it's voltage perhaps once every mS or even faster - it all depends on the application.


    /Henrik Olsson.

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default

    Henrik, Hi!

    Just comparing the samples, would require a lot of if then or select case commands. That is why I suggested differentiation. Also now it came to my mind that differentiation could happily be done in hardware with op-amp's. Select the proper R-C values according to the signal and then get an analog value, proportional to the rate of signal change.

    I would prefer the digital way though...

    Ioannis

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default

    Hi Ioannis,
    OK, you lost me there.... I'm no math expert either but isn't differentiation the same as derivative ie. the difference between two samples with respect to time. (in this case)

    Let's say we read a voltage once every second first reading is 2.2V second reading is 2.5V the rate of change is then 0.3V/second third reading is 4.0V, rate of change is now 1.5V/second and so on.

    It may very well be that I misunderstood the original question, if so you'll have to excuse me, but he said he was looking for the rate of change.

    /Henrik Olsson.

Similar Threads

  1. EEPROM Variables (EE_Vars.pbp)
    By Darrel Taylor in forum Code Examples
    Replies: 79
    Last Post: - 26th October 2012, 00:06
  2. internal TMR for frequency output
    By Samoele in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th January 2009, 09:38
  3. Read/write variable into PIC internal eeprom
    By Pic2008 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 13th August 2008, 07:06
  4. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  5. Convert a word variable to decimal
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 4th December 2004, 20:02

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts