1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Frequency to period adjustment in program loop calculation

  1. Nov 28, 2011 #1
    1. The problem statement, all variables and given/known data

    Adjust a program loop so frequency will change linearly with a keyboard increment or decrement.
    The current calculation adjusts about 40 counts in the delay loop but when the frequency gets high the step is frequency is very large with each decrement in the loop.

    A loop delay of 0 counts is 428 Hz eg as fast as the program will run
    A loop delay of 10000 counts is 4.911 Hz
    A loop delay of 49840 counts is 1 Hz

    2. Relevant equations
    1/Period = Frequency and 1/Frequency = Period

    3. The attempt at a solution
    tid# is the adjustment frequency controlled from keystrokes either increment or decrement in small steps eg + .02 or - .02
    id& is the number of loops in the counter eg period

    tid# = tid# + .02
    id& = 1 / ((1 / tid#) * (1 / 2000))

    Its part of a 3 phase digital to analog converter driven off a printer port using QuickBASIC and win98 and below, using 3 4 bit 8421 ladder networks.
    I made the prototype to drive 3 speakers 120 degrees apart. I intend to finsh the program so that you can record the frequencys and phase shifts for Rubens tube experments.
  2. jcsd
  3. Nov 28, 2011 #2

    tid# = tid# + .02
    id& = 1 / ((1 / tid#) * (1 / 2000))

    Ok so Ive been working on it here is one solution
    I ran a few points in the program then adjusted the loop when 265 was calculated to read 100 Hz then took the difference 256 - 200 = 56 so thats the offset...
    id&=((1/Desired Frequency)/(1/Program Counts per Second)
    256 = 81 Hz
    2568 = 9.8 Hz
    5136 = 4.9 Hz
    25680 = 1 Hz
    51359 = .5 Hz
    so finally
    id&=((1/Desired Frequency)/(1/Program Counts per Second))-program offset in counts
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: Frequency to period adjustment in program loop calculation