The process:
Testing an R-C low pass filter response R=100k, C= 10uF sampled at 500ms. intervals
On an Espruino board the resistor connects to pin A4. The resistor-capacitor junction connects to pin A1. The remaining capacitor lead connects to ground.
The RC circuit has a time constant of R*C = 1 second. The cut off frequency is 1/(2pi*R*C) = 1/6.28 =0.159 Hz or 6.28 seconds per cycle.
The software constructs an adaptive linear combiner. This consists of a N element shift register (X array) (sample 0, sample 1, … sample N), and a weight vector (W array) of equal length. The W array is initially all zeros.
A sample is shifted into the X array. The dot product of W and X is computed (output).
The error between a desired value and the output is calculated and the values in the W vector are adjusted. Wi= 2 * mu * error * Xi, where mu is the adaptive gain. If mu is too large the error increases. Below a critical value the error tends toward zero as successive iterations of the modeling process occur.
Adapt1.js Adapt2.csv and Adapt2.xlsx connects the adaptive linear combiner in parallel with the RC filter process. The RC filter is discharged to zero and then charged. The W array in the adaptive linear combiner acquires the transfer function of the RC filter process. Finally the acquired model is used to repeat the discharge/charge cycle.
The spreadsheet compares the RC process and the modeled process.
The program Acontrol.js and the output files Acontrol.csv and Acontrol.xlxs show the results of connecting the adaptive linear combiner to model the inverse transfer function of the RC filter process. Then the program uses the model to control the process while continuing to adapt the W vector. The set point goes from 1.0 to 0.5 and then to 0.6.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Source for the algorithm
http://adsabs.harvard.edu/abs/1985ph...book.....W%E5%AF%86
The process:
Testing an R-C low pass filter response R=100k, C= 10uF sampled at 500ms. intervals
On an Espruino board the resistor connects to pin A4. The resistor-capacitor junction connects to pin A1. The remaining capacitor lead connects to ground.
The RC circuit has a time constant of R*C = 1 second. The cut off frequency is 1/(2pi*R*C) = 1/6.28 =0.159 Hz or 6.28 seconds per cycle.
The software constructs an adaptive linear combiner. This consists of a N element shift register (X array) (sample 0, sample 1, … sample N), and a weight vector (W array) of equal length. The W array is initially all zeros.
A sample is shifted into the X array. The dot product of W and X is computed (output).
The error between a desired value and the output is calculated and the values in the W vector are adjusted. Wi= 2 * mu * error * Xi, where mu is the adaptive gain. If mu is too large the error increases. Below a critical value the error tends toward zero as successive iterations of the modeling process occur.
Adapt1.js Adapt2.csv and Adapt2.xlsx connects the adaptive linear combiner in parallel with the RC filter process. The RC filter is discharged to zero and then charged. The W array in the adaptive linear combiner acquires the transfer function of the RC filter process. Finally the acquired model is used to repeat the discharge/charge cycle.
The spreadsheet compares the RC process and the modeled process.
The program Acontrol.js and the output files Acontrol.csv and Acontrol.xlxs show the results of connecting the adaptive linear combiner to model the inverse transfer function of the RC filter process. Then the program uses the model to control the process while continuing to adapt the W vector. The set point goes from 1.0 to 0.5 and then to 0.6.
6 Attachments