|
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 | | - |
22 | 1 | # -*- coding: utf-8 -*- |
23 | 2 | # MLC (Machine Learning Control): A genetic algorithm library to solve chaotic problems |
24 | 3 | # Copyright (C) 2015-2017, Thomas Duriez (thomas.duriez@gmail.com) |
|
62 | 41 | import matplotlib.pyplot as plt |
63 | 42 |
|
64 | 43 | # Sine amplitud |
65 | | -A = 1 |
| 44 | +A = 1.1 |
66 | 45 | # Offset |
67 | | -Offset = 1.6 |
| 46 | +Offset = 1.65 |
68 | 47 | f0 = 10 |
69 | 48 | w0 = 2 * np.pi * f0 |
70 | | -fs = 10e3 |
| 49 | +fs = 1e3 |
71 | 50 |
|
72 | 51 | n = np.linspace(0, fs, num=fs) |
73 | 52 | sinewave = Offset + A * np.cos(w0 * n / fs) |
74 | 53 |
|
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 | + |
77 | 61 |
|
78 | 62 | # Normalization |
79 | 63 | 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 |
81 | 65 | sinewave = [int(x) for x in sinewave] |
82 | 66 |
|
83 | 67 | fig = plt.figure() |
84 | | -plt.plot(n, sinewave, 'k') |
| 68 | +plt.plot(n, sinewave, 'k', linestyle=':') |
85 | 69 | plt.show(block=True) |
86 | 70 |
|
87 | 71 | output = "" |
|
0 commit comments