利用MAXQ7667確定超聲傳感器的諧振頻率和阻尼特性
// Use the "damping_half_time" routine to measure the time in μs that it takes for the
// ringing to drop to half of the peak value. Do this at more than one frequency so that
// one of the frequencies will be within range of the transducer.
wait2measure = damping_half_time(128, 88); //Measure damping time at 35kHz.
halfpeak = damping_half_time(256, 101); //Measure damping time at 40kHz.
if (wait2measure halfpeak) {wait2measure = halfpeak;} // Save the longest time.
halfpeak = damping_half_time(384, 113); //Measure damping time at 45kHz.
if (wait2measure halfpeak) {wait2measure = halfpeak;} // Save the longest time.
// Repeatedly pulse the transducer with a constant width pulse while sweeping the receiver
// frequency. Use the half-time value from the damping test (wait2measure) for the interval
// between pulse transmission and reading LPFD (lowpass filter data).
PLLF_bit.PLLF = 0; // Start the sweep at 30kHz.
BPH = 77; // Pulse ~6.3μs. This value is easy to maintain over frequency.
peak = 0;
number_of_steps = 0;
do // Sweep from 30kHz to 50kHz with step_size * 39.062500kHz.
{
usWaitTimer2(5000); // Wait 5ms for the frequency to settle.
STIM = 0; // Reset the system timer. It controls the Pulse to LPF read time.
BPH_bit .BSTT = 1; // Send burst.
while(STIM wait2measure) {} // Wait the specified amount of time for the ringing to dampen.
lpfdata[number_of_steps]= LPFD; // Store the LPF reading.
if(lpfdata[number_of_steps]> peak) {peak = lpfdata[number_of_steps];} //Save the peak value.
number_of_steps++;
PLLF_bit.PLLF = number_of_steps * step_size; // Increase the frequency.
BPH = 77 + number_of_steps; // Increase the duty cycle to maintain pulse width.
} while (PLLF 512-step_size);
評論