Real-time fast Fourier transform

Absolute Overkill !!! (needs Ultimate ROBOLAB v.1489)

7 years after its release it must still be affirmed that not all the power has been unlocked from the RCX. The reason probably is that the RCX-module represents such a well wrapped device that the number of applications really is unlimited. Although in news-groups like LUGNET there always appear people to criticize that it would be preferable to have a much more performing module, the RCX remains a respectable piece of electronics. If there will ever be a successor, LEGO will have to work hard to do it better.

This site is known to press the last drop out of the citron. Here one of the extreme projects:

With only little effort it is possible to have the RCX compute the DFT (Discrete Fourier Transform) up to 500Hz signal frequency. Not yet knowing any serious application of this feature, we present it as one of the bizarre facilities that reveal the power of the RCX.

The applied algorithm may be studied in the following document RFT.pdf . As a point to point sliding algorithm it has the particularity to update the bins at the signal frequency and to be independent of the window-size. It only depends on the number of observed harmonics.

The following program has been tested with a slow motion poor man's rotation sensor. The program first initializes the sine and the cosine look-up-tables, then configures port 1 as "powered" in raw mode. The motor is switched on. After a pause the control-timer is reset (this is only needed to get an idea of the duration of the calculations). A loop is started to read 500 samples and also compute the DFT. After the sampling the motor is stopped and an acoustic signal tells the user that a complete set has been read. Now the resulting data can be uploaded from the addresses of the arrays A(k) -holding the cosine coefficients- and B(k) with the sine coefficients.

To know the addresses, the user should add a TRUE Boolean constant to the  "SHOW ASM" option of the BEGIN icon. End_asm.vi will indicate the address of all the arrays and variables. The data can be uploaded with the ..Ultimate_Robolab\Demos\poll_from_RCX.vi . (You'll need to change the representation of the output array to I32. Therefore right-click on the array and choose representation). The user also can use the standard ROBOLAB pollm (opcode 0x63) to upload the data.

Pressing the RCX Prgm-button will start the motor once again and compute the next data-set.

IMPORTANT NOTE: This application shows only half of the power of the algorithm, since the program is interrupted for data upload after each 500 samples. In fact the program could run continuously and the bin update would be done at the actual sensor reading frequency.

Note that the dc.w instruction is not a standard H8/300 Assembly mnemonic term, but an instruction for the compiler to write a constant to the program memory. This is a very economic way to deal with constant arrays.


RetourMain Page