Skip to content

Commit e63ab5a

Browse files
committed
Changes in sinewave_generator
1 parent 7f9ef92 commit e63ab5a

File tree

1 file changed

+12
-28
lines changed

1 file changed

+12
-28
lines changed

tests/pocs/sine_generation/sinewave_generator.py

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
# MLC (Machine Learning Control): A genetic algorithm library to solve chaotic problems
3-
# Copyright (C) 2015-2017, Thomas Duriez (thomas.duriez@gmail.com)
4-
# Copyright (C) 2015, Adrian Durán (adrianmdu@gmail.com)
5-
# Copyright (C) 2015-2017, Ezequiel Torres Feyuk (ezequiel.torresfeyuk@gmail.com)
6-
# Copyright (C) 2016-2017, Marco Germano Zbrun (marco.germano@intraway.com)
7-
# Copyright (C) 2016-2017, Raúl Lopez Skuba (raulopez0@gmail.com)
8-
#
9-
# This program is free software: you can redistribute it and/or modify
10-
# it under the terms of the GNU General Public License as published by
11-
# the Free Software Foundation, either version 3 of the License, or
12-
# (at your option) any later version.
13-
#
14-
# This program is distributed in the hope that it will be useful,
15-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17-
# GNU General Public License for more details.
18-
#
19-
# You should have received a copy of the GNU General Public License
20-
# along with this program. If not, see <http://www.gnu.org/licenses/>
21-
221
# -*- coding: utf-8 -*-
232
# MLC (Machine Learning Control): A genetic algorithm library to solve chaotic problems
243
# Copyright (C) 2015-2017, Thomas Duriez (thomas.duriez@gmail.com)
@@ -62,26 +41,31 @@
6241
import matplotlib.pyplot as plt
6342

6443
# Sine amplitud
65-
A = 1
44+
A = 1.1
6645
# Offset
67-
Offset = 1.6
46+
Offset = 1.65
6847
f0 = 10
6948
w0 = 2 * np.pi * f0
70-
fs = 10e3
49+
fs = 1e3
7150

7251
n = np.linspace(0, fs, num=fs)
7352
sinewave = Offset + A * np.cos(w0 * n / fs)
7453

75-
dac_max_value = 3800
76-
dac_min_value = 100
54+
dac_max_value = 4095
55+
dac_min_value = 0
56+
dac_amp_pp = dac_max_value - dac_min_value
57+
min_value = 0.55
58+
max_value = 2.75
59+
amp_pp = max_value - min_value
60+
7761

7862
# Normalization
7963
min_value = Offset - A
80-
sinewave = (sinewave - min_value) * (dac_max_value - dac_min_value) / 2 + dac_min_value
64+
sinewave = (sinewave - min_value) * dac_amp_pp / amp_pp + dac_min_value
8165
sinewave = [int(x) for x in sinewave]
8266

8367
fig = plt.figure()
84-
plt.plot(n, sinewave, 'k')
68+
plt.plot(n, sinewave, 'k', linestyle=':')
8569
plt.show(block=True)
8670

8771
output = ""

0 commit comments

Comments
 (0)