Frequency to period adjustment in program loop calculation

Click For Summary
SUMMARY

The discussion focuses on adjusting a program loop in QuickBASIC to achieve linear frequency changes via keyboard input. The current implementation allows for frequency adjustments but results in large steps at higher frequencies. The proposed solution involves modifying the delay loop calculation to account for a desired frequency, using the formula id&=((1/Desired Frequency)/(1/Program Counts per Second))-program offset in counts. This adjustment enables more precise control over frequency settings for a digital-to-analog converter driving speakers in a Rubens tube experiment.

PREREQUISITES
  • Understanding of QuickBASIC programming
  • Familiarity with digital-to-analog conversion concepts
  • Knowledge of frequency and period calculations
  • Experience with keyboard input handling in programming
NEXT STEPS
  • Research "QuickBASIC keyboard input handling" for better user interaction
  • Explore "digital-to-analog converter design" for enhanced project understanding
  • Learn about "frequency modulation techniques" for advanced frequency control
  • Investigate "Rubens tube experiments" to apply findings in practical scenarios
USEFUL FOR

This discussion is beneficial for programmers working with QuickBASIC, electronics enthusiasts involved in digital-to-analog conversion, and educators conducting experiments related to sound and frequency manipulation.

smokingwheels
Messages
69
Reaction score
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
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
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
7K
Replies
7
Views
24K
  • · Replies 1 ·
Replies
1
Views
5K