// in-progress 18 dec 23
#include <stdio.h>
#include <math.h>
int indx;
int indx2 = 0;
int tmp;
float samples;
float oup;
float cor;
int rng = 10; // 0 -- 9
float angle;
float v_angle;
float y0;
float y1;
float y2;
float duration = 1.00;
float frequency = 1000; // 1 kHz
float a[2] = {0.95, 0.25}; // amplitude
float s[2] = {0.60, 1.20}; // sigma
float m[2] = {-M_PI_2, M_PI_4}; // mu
float d[100][10] ; // dataset
void setup() {
pinMode(13, OUTPUT);
pinMode(2, OUTPUT); // for analog write
pinMode(A0, INPUT); // for analog read
Serial.begin(9600);
samples = frequency / duration;
v_angle = 2 * M_PI / samples;
}
void loop() {
for (indx=0;indx<samples;indx++) {
angle = - M_PI + (indx * v_angle);
y1 = (angle - m[0]) / s[0];
y1 = pow(y1, 2);
y1 = exp(- y1 / 2);
y1 = a[0] * y1;
y2 = (angle - m[1]) / s[1];
y2 = pow(y2, 2);
y2 = exp(- y2 / 2);
y2 = a[1] * y2;
y0 = y1 + y2;
oup = y0 * rng; // scale to output
if (indx == 0){cor = oup; };
oup = oup - cor; // correction
if (((indx+1) % 10) == 0) {
Serial.print("\n");
tmp = int((indx+1)/10)-1;
d[tmp][indx2] = oup;
// Serial.print(tmp);
// Serial.print(", ");
// Serial.print(indx2);
// Serial.print(", ");
Serial.print(d[tmp][indx2]);
// Serial.print(", ");
};
if (((indx+1) % 1000) == 0) {
indx2 = indx2+1;
if (indx2 >= 10) {
// call it now!
// new beginning
indx2 = 0;
} // circular index
};
delay(1);
};
}