|page created : August 19th, 2009||updated : August 20th, 2009|
In January 2007 we have tried to run a real-time Fourier transform application on the NXT and we were somehow disappointed about the bad NXT performance. Now, we thought it was the time to repeat the experiment with the new toolkit ( http://zone.ni.com/devzone/cda/tut/p/id/4435 ), because meanwhile both the NXT firmware and the NI tookit have changed a lot.
Right at the beginning of this page we want to point out that LEGO and NI tremendously have improved the firmware and the toolkit. Running the 2007-program in a first test with 25 harmonics shows that one cycle now just takes 0.25sec compared to 11,9sec recorded in 2006. We just want to congratulate the programmers for this performance. (Hey, Greg and Co., well done !!! I'm impressed !!!)
2. Test conditions:
In this experiment we intend to have the NXT display the power spectrum of data that is read from the LEGO legacy rotation sensor. The NXT is run first in normal mode and then in debugging mode, where the data is tranferred to the PC. In order to pep the whole experiment, we rotate the sensor shaft through a belt drive from an old toy steam engine (just for fun) as shown on (Fig.1, 2 and 3).
Fig.1: An old Wilesco steam engine drives the LEGO legacy rotation sensor.
Fig. 2&3: The steam engine is heated with solid fuel from Esbit.
3. NXT program:
By contrast to the 2007-experiment, this program now runs continuously and displays the power of the first 8 harmonics of interest only. ==> DOWNLOAD.
The Discrete Fourier Transform (DFT) is based on the RFT-algorithm that we developed some years ago. It has the particularity that it may be used either as a sliding point-by-point algorithm or traditionally as a DFT that is applied on a recorded data-set. Also it is quite fast, because it doesn't compute any trigonometry values itself, but picks them from a look-up table. This is possible, since only a finite number of sine and cosine values -in fact the dataset size- is required. These value are precomputed, scaled and stored in an array (Fig.4) . The new NXT firmware supports single precision floating point data. Therefore it is possible to have the NXT calculate the power-spectrum (Fig.5). The program reads the LEGO legacy rotation sensor values as raw light-sensor values. The RFT-step is shown on the diagram in (Fig.6).
Fig. 4: Only 128 sine values are needed. They are precomputed using this VI and stored in an array that is manually moved to the diagram of (Fig.5).
Fig. 5: The program samples 128 values, then operates the DFT, computes the power-spectrum and display the harmonics in a bar plot.
Fig. 6: The inner loop of the algorithm has not changed since the 2007-experiment.
The program is run either in normal or debugging mode. Changing to debugging mode slightly affects the timing. The NXT displays the power spectrum, as shown on (Fig.7). In debugging mode the data is constantly uploaded to the PC. (Fig.8). Just a note about the DFT timing:
If the NXT shows that the 6th harmonic is the strongest, this means that for the duration of 128 samples (T=128*3=384ms), one signal-period has the duration 384/6=64ms. We know that 16 pulses (=4 cycle periods) of the legacy rotation sensor correspond to one shaft revolution. We then have a complete rotation every 256ms, which is about 4 rot/sec or 240 rot/min.
Fig. 7: The 6th harmonic is the strongest.
Fig. 8: The power-spectrum shows that there are 6 complete rotation sensor cycles for the duration of the sampling pedriod T=128*3=384ms.