Frequency to period adjustment in program loop calculation

In summary, the conversation discusses adjusting a program loop so that the frequency changes linearly with keyboard increments or decrements. The current calculation involves adjusting about 40 counts in the delay loop, but the problem arises when the frequency gets high and the step becomes too large with each decrement in the loop. The conversation also mentions various loop delays and their corresponding frequencies. The attempted solution involves using a program offset to adjust the loop, and the final summary suggests using the formula id& = ((1/Desired Frequency)/(1/Program Counts per Second))-program offset in counts to achieve the desired frequency.
  • #1
smokingwheels
70
0

Homework Statement



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

Homework Equations


1/Period = Frequency and 1/Frequency = Period



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

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


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.
 
Physics news on Phys.org
  • #2
smokingwheels said:

Homework Statement



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

Homework Equations


1/Period = Frequency and 1/Frequency = Period



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

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


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.


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

Ok so I've 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 that's 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
 

Related to Frequency to period adjustment in program loop calculation

What is frequency to period adjustment in program loop calculation?

Frequency to period adjustment in program loop calculation is a method used to convert a frequency value to a period value in a program loop. This is commonly used in programming to control the timing and execution of code based on a specific frequency.

Why is frequency to period adjustment important in program loop calculation?

Frequency to period adjustment is important because it allows for precise control of code execution based on a desired frequency. It also ensures that the program loop is running at the correct speed, which is essential for many applications.

How does frequency to period adjustment work in program loop calculation?

Frequency to period adjustment works by using a mathematical formula to convert the frequency value to a period value. This usually involves dividing the frequency by the clock speed of the program loop and can also include adjustments for any delays or overhead in the code.

What are some common uses of frequency to period adjustment in program loop calculation?

Frequency to period adjustment is commonly used in applications that require precise timing, such as real-time systems, signal processing, and data acquisition. It can also be used in event-driven programming to control the frequency of events or tasks.

Are there any potential issues or limitations with frequency to period adjustment in program loop calculation?

One potential issue with frequency to period adjustment is that it relies on the accuracy of the clock speed and any adjustments made to it. This can introduce errors or inconsistencies in the timing of the program loop. Additionally, if the frequency value is too high, it may not be possible to accurately convert it to a period value due to limitations in the clock speed.

Similar threads

  • Electrical Engineering
Replies
1
Views
5K
Replies
7
Views
23K
Back
Top