Pianola

Ultrasounds: switching between two frequencies

To solve the problem, we decided to modulate the ultrasonic signal no longer in amplitude (transmission at 40 kHz / no transmission), but in frequency (transmission at frequency f0 / transmission at frequency f1) using two different frequencies around 40 kHz, so included into the "work band" of our piezoelectric sensors. The feasibility of such a solution was confirmed by two papers, which suggest a similar approach, yet when working with a transmitter and just one receiver, to obtain a particularly accurate measure of distance: "A high accuracy ultrasonic distance measurement system using binary frequency shift-keyed signal and phase detection".

October 2002 paper

December 2007 paper

Therefore we modified the program of our PIC, so that the sender transmitted cyclically a certain number of pulses at a frequency lower than 40 kHz and then a certain number of pulses at a frequency higher than 40 kHz. The transition between the two frequencies at the transmitter was almost immediate (just one period at an intermediate frequency), at the receiver instead there were always some periods of transition, but their number seemed to be always the same on both channels. The amplitude, of course, had no longer influence and almost immediately it remained constant at the steady-state value.

So we wrote the program for the DSP. With only two timers, we had to measure the period on both channels(to detect the change in frequency) and also the difference in time between the instant when the change occurs on a channel and when on the other: we thought of an algorithm that in this Excel spreadsheet is described in pseudocode.

The two timers measure the period on the two channels; variable owner indicates the channel which is handling the count of the time difference and is 0 if none of the two channels is counting. If a frequency change happens on a channel, owner is examined: if it is 0, the count of the time difference must be started, if it is the other channel, the count must be ended.

Problems occurred when implementing the algorithm in the DSP because everything is done by interrupts. The results provided were often good, but much worse when placing the emitter at about half distance. Obvious: the closest the sender is to the midpoint between the two receivers, the more complex is the interrupt management. In the ideal case when the transmitter is exactly equidistant from the two receivers, the procedures for starting and stopping the count must be activated simultaneously. It is clear that such a situation is unmanageable.

In addition, physical difference between the two receivers was likely to be still a source of problems. In virtue of these considerations, we decided to change our strategy once again and bring back to a more standard, less complex situation.