Skip to content

Commit 647e07d

Browse files
authored
update library.json, license, minor edits (#4)
1 parent 6f6d07c commit 647e07d

12 files changed

Lines changed: 54 additions & 62 deletions

File tree

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2015-2021 Rob Tillaart
3+
Copyright (c) 2015-2022 Rob Tillaart
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
# FunctionGenerator
1010

11-
Arduino library to generate (numeric) wave forms for a DAC
11+
Arduino library to generate (numeric) wave forms for a DAC.
1212

1313

1414
## Description
@@ -31,28 +31,30 @@ Indication of what performance can be expected (based upon 0.2.1 version).
3131
Note that the values need to be transported to a DAC or serial port too.
3232
Numbers based on performance example, for one single signal.
3333

34+
3435
| Processor | Clock | Waveform | usec/calls | max freq |
3536
|:-------------|---------:|:---------|-----------:|---------:|
36-
| Arduino UNO | 16 MHz | sawtooth | 62 | 60 Hz |
37-
| Arduino UNO | 16 MHz | triangle | 74 | 50 Hz |
37+
| Arduino UNO | 16 MHz | sawtooth | 62 | 60 Hz |
38+
| Arduino UNO | 16 MHz | triangle | 74 | 50 Hz |
3839
| Arduino UNO | 16 MHz | square | 53 | 1000 Hz |
39-
| Arduino UNO | 16 MHz | sinus | 164 | 25 Hz |
40-
| Arduino UNO | 16 MHz | stair | 81 | 50 Hz |
40+
| Arduino UNO | 16 MHz | sinus | 164 | 25 Hz |
41+
| Arduino UNO | 16 MHz | stair | 81 | 50 Hz |
4142
| Arduino UNO | 16 MHz | random | 37 | 1000 Hz |
4243
| | | | | |
4344
| ESP32 | 240 MHz | sawtooth | 3.8 | 1000 Hz |
4445
| ESP32 | 240 MHz | triangle | 3.9 | 1000 Hz |
4546
| ESP32 | 240 MHz | square | 2.8 | 1000 Hz |
46-
| ESP32 | 240 MHz | sinus | 13.6 | 250 Hz |
47-
| ESP32 | 240 MHz | stair | 4.8 | 800 Hz |
47+
| ESP32 | 240 MHz | sinus | 13.6 | 250 Hz |
48+
| ESP32 | 240 MHz | stair | 4.8 | 800 Hz |
4849
| ESP32 | 240 MHz | random | 1.3 | 1000 Hz |
4950

5051

5152
- assumption minimal 250 samples per period to get a smooth signal.
5253
if a rougher signal is OK, higher frequencies are possible.
5354
- ESP32 can do more calculations however 1000 Hz seems to be a nice
5455
upper limit for a software based function generator.
55-
- if one wants to control multiple DAC's one need to divide the numbers.
56+
- if one wants to control multiple DAC's one need to divide the numbers
57+
and round down.
5658

5759

5860
Note: hardware function generator https://github.com/RobTillaart/AD985X
@@ -71,7 +73,7 @@ All parameters can be set in the constructor but also later in configuration.
7173
- **void setPeriod(float period = 1.0)** set the period of the wave in seconds.
7274
- **float getPeriod()** returns the set period.
7375
- **void setFrequency(float frequency = 1.0)** set the frequency of the wave in Hertz (1/s).
74-
- **float getFrequency()** returns the set frequency.
76+
- **float getFrequency()** returns the set frequency in Hertz.
7577
- **void setAmplitude(float amplitude = 1.0)** sets the amplitude of the wave. TODO point to point?
7678
Setting the amplitude to 0 gives ?what?
7779
- **float getAmplitude()** returns the set amplitude.
@@ -92,7 +94,7 @@ t is time in seconds
9294
- **float sinus(float t)** sinus wave, has no duty cycle.
9395
- **float stair(float t, uint16_t steps = 8, uint8_t mode = 0)** mode = 0 ==> steps up, mode = 1 steps down.
9496
- **float random()** noise generation.
95-
- **float line()** constant voltage line
97+
- **float line()** constant voltage line. Depends on the set YShift and amplitude.
9698
- **float zero()** constant zero.
9799

98100
Line() and zero() are functions that can be used to drive a constant voltage from a DAC
@@ -112,6 +114,7 @@ See examples.
112114
- square duty-cycle (will be slower!)
113115
- triangle duty-cycle (makes sawtooth a special triangle)
114116
- trapezium wave (would merge square and triangle and sawtooth)
117+
- Bezier curve?
115118

116119
#### investigate
117120

examples/functionGenerator/functionGenerator.ino

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//
22
// FILE: functionGenerator.ino
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.2.0
54
// PURPOSE: demo function generators
65
// DATE: 2015-01-03
76
// URL: https://github.com/RobTillaart/FunctionGenerator
@@ -37,24 +36,24 @@ void loop()
3736
// wave selection by potMeter
3837
// int choice = analogRead(A0) / 200;
3938

40-
float val;
39+
float value;
4140
// wait for next millisecond;
4241
if (millis() - lastTime > 0)
4342
{
4443
lastTime = millis();
4544
float t = lastTime * 0.001;
4645
switch (choice)
4746
{
48-
case '0': val = gen.square(t); break;
49-
case '1': val = gen.sawtooth(t); break;
50-
case '2': val = gen.triangle(t); break;
51-
case '3': val = gen.stair(t); break;
52-
case '4': val = gen.sinus(t); break;
53-
case '5': val = gen.line(); break;
54-
case '6': val = gen.random(); break;
55-
default: val = gen.zero(); break;
47+
case '0': value = gen.square(t); break;
48+
case '1': value = gen.sawtooth(t); break;
49+
case '2': value = gen.triangle(t); break;
50+
case '3': value = gen.stair(t); break;
51+
case '4': value = gen.sinus(t); break;
52+
case '5': value = gen.line(); break;
53+
case '6': value = gen.random(); break;
54+
default: value = gen.zero(); break;
5655
}
57-
Serial.println(val);
56+
Serial.println(value);
5857
}
5958
}
6059

examples/functionGeneratorDuoPlot/functionGeneratorDuoPlot.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//
22
// FILE: functionGeneratorDuoPlot.ino
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.0
54
// PURPOSE: demo function generators
65
// DATE: 2020-06-10
76
// URL: https://github.com/RobTillaart/FunctionGenerator

examples/functionGeneratorPerformance/functionGeneratorPerformance.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//
22
// FILE: functionGeneratorPerformance.ino
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.2.0
54
// PURPOSE: demo function generators
65
// DATE: 2015-01-01
76
// URL: https://github.com/RobTillaart/FunctionGenerator
@@ -24,7 +23,7 @@ void setup()
2423
Serial.begin(115200);
2524
Serial.print("Start functionGeneratorPerformance - LIB VERSION: ");
2625
Serial.println(FUNCTIONGENERATOR_LIB_VERSION);
27-
26+
2827
Serial.println("func \t\tusec\tmax calls/sec");
2928
y = analogRead(A0) / 1024;
3029
test_square();

examples/functionGeneratorPlotter/functionGeneratorPlotter.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//
22
// FILE: functionGeneratorPlotter.ino
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.1
54
// PURPOSE: demo function generators
65
// DATE: 2020-06-10
76
// URL: https://github.com/RobTillaart/FunctionGenerator

examples/functionGenerator_MCP4725/functionGenerator_MCP4725.ino

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
//
22
// FILE: functionGenerator_MCP4725.ino
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.0
54
// PURPOSE: demo function generators
65
// DATE: 2021-01-06
76
// URL: https://github.com/RobTillaart/FunctionGenerator
87
//
98
// depending on the platform, the range of "smooth" sinus is limited.
109
// other signals are less difficult so have a slightly larger range.
11-
//
12-
// PLATFORM RANGE Points/sec Points/period
13-
// UNO - 25 Hz ~1900 ~75
14-
// ESP32 to be tested
10+
// see readme.md for mac frequency table.
1511
//
1612

1713

@@ -21,9 +17,9 @@
2117

2218

2319
funcgen gen;
24-
float val = 0;
25-
float freq = 40;
26-
float amp = 1.0;
20+
float value = 0;
21+
float frequency = 40;
22+
float amplitude = 1.0;
2723

2824
// q = square
2925
// s = sinus
@@ -42,8 +38,8 @@ void setup()
4238
Serial.begin(230400);
4339
gen.setAmplitude(1);
4440
gen.setYShift(1);
45-
gen.setFrequency(freq);
46-
val = 0;
41+
gen.setFrequency(frequency);
42+
value = 0;
4743

4844
Wire.begin();
4945
MCP.begin();
@@ -73,23 +69,23 @@ void setup()
7369
switch (c)
7470
{
7571
case '+':
76-
freq += 0.01;
72+
frequency += 0.01;
7773
break;
7874
case '-':
79-
freq -= 0.01;
75+
frequency -= 0.01;
8076
break;
8177
case '*':
82-
freq *= 10;
78+
frequency *= 10;
8379
break;
8480
case '/':
85-
freq /= 10;
81+
frequency /= 10;
8682
break;
8783
case '0' ... '9':
88-
freq *= 10;
89-
freq += (c - '0');
84+
frequency *= 10;
85+
frequency += (c - '0');
9086
break;
9187
case 'c':
92-
freq = 0;
88+
frequency = 0;
9389
break;
9490
case 'A':
9591
break;
@@ -105,30 +101,30 @@ void setup()
105101
default:
106102
break;
107103
}
108-
gen.setFrequency(freq);
109-
Serial.println(freq);
104+
gen.setFrequency(frequency);
105+
Serial.println(frequency);
110106
}
111107

112108
switch (mode)
113109
{
114110
case 'q':
115-
val = 2047 * gen.square(t);
111+
value = 2047 * gen.square(t);
116112
break;
117113
case 'w':
118-
val = 2047 * gen.sawtooth(t);
114+
value = 2047 * gen.sawtooth(t);
119115
break;
120116
case 't':
121-
val = 2047 * gen.triangle(t);
117+
value = 2047 * gen.triangle(t);
122118
break;
123119
case 'r':
124-
val = 2047 * gen.random();
120+
value = 2047 * gen.random();
125121
break;
126122
default:
127123
case 's':
128-
val = 2047 * gen.sinus(t);
124+
value = 2047 * gen.sinus(t);
129125
break;
130126
}
131-
MCP.setValue(val);
127+
MCP.setValue(value);
132128
}
133129
}
134130

functionGenerator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// FILE: functionGenerator.cpp
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.2.2
4+
// VERSION: 0.2.3
55
// PURPOSE: wave form generating functions (use with care)
66
// URL: https://github.com/RobTillaart/FunctionGenerator
77
//
@@ -16,7 +16,7 @@
1616
// 0.2.1 2020-12-24 Arduino-CI + unit tests
1717
// 0.2.2 2021-11-02 update Arduino-CI, badges
1818
// add mode for sawtooth and stair.
19-
//
19+
// 0.2.3 2021-12-18 update library.json, license, minor edits
2020

2121

2222
#include "functionGenerator.h"

functionGenerator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
//
33
// FILE: functionGenerator.h
44
// AUTHOR: Rob Tillaart
5-
// VERSION: 0.2.2
5+
// VERSION: 0.2.3
66
// PURPOSE: wave form generating functions (use with care)
77
// URL: https://github.com/RobTillaart/FunctionGenerator
88
//
99

1010

1111
#include "Arduino.h"
1212

13-
#define FUNCTIONGENERATOR_LIB_VERSION (F("0.2.2"))
13+
#define FUNCTIONGENERATOR_LIB_VERSION (F("0.2.3"))
1414

1515

1616
class funcgen

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"type": "git",
1616
"url": "https://github.com/RobTillaart/FunctionGenerator"
1717
},
18-
"version": "0.2.2",
18+
"version": "0.2.3",
1919
"license": "MIT",
2020
"frameworks": "arduino",
2121
"platforms": "*",

0 commit comments

Comments
 (0)