-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfuncGenFreeWavePlotter.ino
95 lines (80 loc) · 2.28 KB
/
funcGenFreeWavePlotter.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//
// FILE: funcGenFreeWavePlotter.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo function generators
// URL: https://github.com/RobTillaart/FunctionGenerator
//
// use a Serial plotter to show the data
#include "functionGenerator.h"
funcgen gen;
// sin(t).
int16_t arr_sin[101] =
{
0, 627, 1253, 1873, 2486, 3090,
3681, 4257, 4817, 5358, 5877,
6374, 6845, 7289, 7705, 8090,
8443, 8763, 9048, 9297, 9510,
9685, 9822, 9921, 9980, 10000,
9980, 9921, 9822, 9685, 9510,
9297, 9048, 8763, 8443, 8090,
7705, 7289, 6845, 6374, 5877,
5358, 4817, 4257, 3681, 3090,
2486, 1873, 1253, 627, 0,
-627, -1253, -1873, -2486, -3090,
-3681, -4257, -4817, -5358, -5877,
-6374, -6845, -7289, -7705, -8090,
-8443, -8763, -9048, -9297, -9510,
-9685, -9822, -9921, -9980, -10000,
-9980, -9921, -9822, -9685, -9510,
-9297, -9048, -8763, -8443, -8090,
-7705, -7289, -6845, -6374, -5877,
-5358, -4817, -4257, -3681, -3090,
-2486, -1873, -1253, -627, 0,
};
// sin(t) + 0.25 * sin(5t)
int16_t arr_two_sin[101] =
{
0, 1120, 2178, 3117, 3891, 4472,
4847, 5024, 5029, 4904, 4702,
4481, 4300, 4213, 4261, 4472,
4852, 5392, 6063, 6820, 7608,
8366, 9033, 9554, 9886, 10000,
9886, 9554, 9033, 8366, 7608,
6820, 6063, 5392, 4852, 4472,
4261, 4213, 4300, 4481, 4702,
4904, 5029, 5024, 4847, 4472,
3891, 3117, 2178, 1120, 0,
-1120, -2178, -3117, -3891, -4472,
-4847, -5024, -5029, -4904, -4702,
-4481, -4300, -4213, -4261, -4472,
-4852, -5392, -6063, -6820, -7608,
-8366, -9033, -9554, -9886, -10000,
-9886, -9554, -9033, -8366, -7608,
-6820, -6063, -5392, -4852, -4472,
-4261, -4213, -4300, -4481, -4702,
-4904, -5029, -5024, -4847, -4472,
-3891, -3117, -2178, -1120, 0,
};
void setup()
{
Serial.begin(115200);
// Serial.println(__FILE__);
// Serial.print("FUNCTIONGENERATOR_LIB_VERSION: ");
// Serial.println(FUNCTIONGENERATOR_LIB_VERSION);
// Serial.println();
gen.setAmplitude(80);
gen.setFrequency(0.5);
gen.setDutyCycle(50);
}
void loop()
{
float t = millis() * 0.001;
Serial.print(80);
Serial.print("\t");
Serial.print(-80);
Serial.print("\t");
Serial.print(gen.freeWave(t, arr_two_sin, 100));
Serial.println();
delay(10);
}
// -- END OF FILE --