
The above RC circuit functions as a low-pass filter characterized by the transfer function and frequency response bode plot given below.
We then programmed Matlab to send a stream of white noise to Arduino, which outputs the white noise as a PWM signal to the RC circuit, senses the response, and transmits it back to Matlab. At first, we had Matlab and Arduino communicating signals one at a time (i.e., Matlab would send a single piece of white noise (a random number) to Arduino, and Arduino would respond with the RC circuit's response). We found this method to be incredibly slow, with sample rates less than 10HZ, well below the cut-off frequency of our low-pass filter. To remedy this, we reprogrammed the system so that each operation (e.g., creating the white noise, sending the PWM signal and sensing the response, etc.) was done separately with no overlap. Using this method, the system was programmed to follow these steps:
Step 1: Create the white noise and save it as an array
Rather than retrieve one random number from Matlab at a time, we programmed Arduino to create an array of random numbers that serves as the white noise. This eliminated the delay between when Arduino transmits the RC circuit's response and when it receives another random number from Matlab.
Step 2: Output the white noise as a PWM signal and sense the response
After the array of white noise is created, Arduino outputs a single element as a PWM signal to the RC circuit, senses the response and saves it to an array, and then delays for 0.9ms. This operation iterates until every element of the white noise array has been output.
Step 3: Transmit the white noise array and the RC circuit response array to Matlab
After all white noise output and response sensing is complete, Arduino transmits the two arrays to Matlab for processing. Delaying the serial communication until after all signal output/sensing is complete significantly increases the sampling rate. Using this method, we were able to achieve sampling rates of 1000Hz.
Step 4: Read and process the data from Arduino in Matlab
We programmed Matlab to process the data and produce two figures. The first figure, included below, shows the white noise (in blue) and the system's response (in green) with respect to time. The second figure, also included below, shows the bode plot of Matlab's estimate of the transfer function (in blue) and the bode plot of the actual transfer function (in green).

No comments:
Post a Comment