![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
LUIS
main.cpp@0:7a912bfb5a4e, 2018-10-05 (annotated)
- Committer:
- pirottealex
- Date:
- Fri Oct 05 14:54:02 2018 +0000
- Revision:
- 0:7a912bfb5a4e
a
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pirottealex | 0:7a912bfb5a4e | 1 | #include "mbed.h" |
pirottealex | 0:7a912bfb5a4e | 2 | #include "digital_filter.h" |
pirottealex | 0:7a912bfb5a4e | 3 | |
pirottealex | 0:7a912bfb5a4e | 4 | |
pirottealex | 0:7a912bfb5a4e | 5 | Serial pc(USBTX,USBRX); |
pirottealex | 0:7a912bfb5a4e | 6 | |
pirottealex | 0:7a912bfb5a4e | 7 | int main() |
pirottealex | 0:7a912bfb5a4e | 8 | { |
pirottealex | 0:7a912bfb5a4e | 9 | pc.baud(460800); |
pirottealex | 0:7a912bfb5a4e | 10 | |
pirottealex | 0:7a912bfb5a4e | 11 | double coef_b[4] = {0.0408, 0.1224, 0.1224, 0.0408}; // Les 4 coefficients ai |
pirottealex | 0:7a912bfb5a4e | 12 | double coef_a[3] = {-1.2978, 0.7875, -0.1632}; // Les 3 coefficients bj |
pirottealex | 0:7a912bfb5a4e | 13 | double echantillons[32] = {0.7362, 0.2071, 1.2774, 1.0, 0.5703, 1.2071, 0.0291, 0.0, -0.0291, -1.2071, -0.5703, -1.0, -1.2774, -0.2071, -0.7362, 0.0, |
pirottealex | 0:7a912bfb5a4e | 14 | 0.7362, 0.2071, 1.2774, 1.0, 0.5703, 1.2071, 0.0291, 0.0, -0.0291, -1.2071, -0.5703, -1.0, -1.2774, -0.2071, -0.7362, 0.0}; |
pirottealex | 0:7a912bfb5a4e | 15 | digital_filter mon_filtre; |
pirottealex | 0:7a912bfb5a4e | 16 | |
pirottealex | 0:7a912bfb5a4e | 17 | init_digital_filter(&mon_filtre, coef_a, 4, coef_b, 3); // Initialisation du filtre avec les coefficients de la fonction de transfert |
pirottealex | 0:7a912bfb5a4e | 18 | |
pirottealex | 0:7a912bfb5a4e | 19 | for(char i = 0; i < 32; i++) |
pirottealex | 0:7a912bfb5a4e | 20 | { // On filtre les échantillons |
pirottealex | 0:7a912bfb5a4e | 21 | pc.printf("Echantillon numero %d : %lf\t | Apres filtrage : %lf\n\r", i, echantillons[i], filter_next_sample(&mon_filtre, echantillons[i])); |
pirottealex | 0:7a912bfb5a4e | 22 | } |
pirottealex | 0:7a912bfb5a4e | 23 | |
pirottealex | 0:7a912bfb5a4e | 24 | while(1) |
pirottealex | 0:7a912bfb5a4e | 25 | { |
pirottealex | 0:7a912bfb5a4e | 26 | wait(1); |
pirottealex | 0:7a912bfb5a4e | 27 | } |
pirottealex | 0:7a912bfb5a4e | 28 | } |