Classes et code de la partie pompe du Robot 2021
Dependencies: mbed ident_crac
bloc_monopompe.cpp@4:4bae30d48662, 2021-01-18 (annotated)
- Committer:
- goldmas
- Date:
- Mon Jan 18 15:24:35 2021 +0000
- Revision:
- 4:4bae30d48662
- Parent:
- 0:253443d82cba
- Child:
- 5:88ab89ab12ad
- Child:
- 6:b06c430a7e14
Code avec bus CAN(non teste)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
goldmas | 0:253443d82cba | 1 | #include "bloc_monopompe.h" |
goldmas | 0:253443d82cba | 2 | |
goldmas | 0:253443d82cba | 3 | bloc_monopompe::bloc_monopompe (PinName pompe, PinName electrovanne, PinName capteur) |
goldmas | 0:253443d82cba | 4 | : _pompe(pompe), _electrovanne(electrovanne), _capteur(capteur) |
goldmas | 0:253443d82cba | 5 | { |
goldmas | 0:253443d82cba | 6 | _pompe.period_us(20) ; |
goldmas | 0:253443d82cba | 7 | } |
goldmas | 0:253443d82cba | 8 | |
goldmas | 4:4bae30d48662 | 9 | void bloc_monopompe::aspirer (void) |
goldmas | 0:253443d82cba | 10 | { |
goldmas | 0:253443d82cba | 11 | _pompe = PWM_POMPE ; |
goldmas | 0:253443d82cba | 12 | _electrovanne = ELEC_OUVERTE ; |
goldmas | 0:253443d82cba | 13 | wait_ms(100) ; |
goldmas | 0:253443d82cba | 14 | |
goldmas | 0:253443d82cba | 15 | if(_capteur.read() >= SEUIL_CPT) |
goldmas | 0:253443d82cba | 16 | { |
goldmas | 0:253443d82cba | 17 | _electrovanne = ELEC_FERME ; |
goldmas | 0:253443d82cba | 18 | wait_ms(100) ; |
goldmas | 0:253443d82cba | 19 | if(_capteur.read() >= SEUIL_CPT) |
goldmas | 0:253443d82cba | 20 | { |
goldmas | 0:253443d82cba | 21 | _pompe = 0 ; |
goldmas | 0:253443d82cba | 22 | _gobelet_en_place = 1 ; |
goldmas | 0:253443d82cba | 23 | } |
goldmas | 0:253443d82cba | 24 | else |
goldmas | 0:253443d82cba | 25 | { |
goldmas | 0:253443d82cba | 26 | _electrovanne = ELEC_OUVERTE ; |
goldmas | 0:253443d82cba | 27 | _gobelet_en_place = 0 ; |
goldmas | 0:253443d82cba | 28 | } |
goldmas | 0:253443d82cba | 29 | } |
goldmas | 0:253443d82cba | 30 | } |
goldmas | 0:253443d82cba | 31 | |
goldmas | 4:4bae30d48662 | 32 | void bloc_monopompe::relacher (void) |
goldmas | 0:253443d82cba | 33 | { |
goldmas | 0:253443d82cba | 34 | _electrovanne = ELEC_OUVERTE ; |
goldmas | 0:253443d82cba | 35 | wait_ms(100) ; |
goldmas | 0:253443d82cba | 36 | if(_capteur.read() >= SEUIL_CPT) |
goldmas | 0:253443d82cba | 37 | _gobelet_en_place = 1 ; |
goldmas | 0:253443d82cba | 38 | else |
goldmas | 0:253443d82cba | 39 | _gobelet_en_place = 0 ; |
goldmas | 0:253443d82cba | 40 | } |
goldmas | 0:253443d82cba | 41 | |
goldmas | 4:4bae30d48662 | 42 | char bloc_monopompe::etat_actuel (void) |
goldmas | 0:253443d82cba | 43 | { |
goldmas | 4:4bae30d48662 | 44 | char etat_groupe = 0 ; |
goldmas | 4:4bae30d48662 | 45 | bool etat_pompe; |
goldmas | 4:4bae30d48662 | 46 | bool etat_electrovanne ; |
goldmas | 4:4bae30d48662 | 47 | |
goldmas | 4:4bae30d48662 | 48 | if(_pompe.read() != 0) //test de la pompe |
goldmas | 4:4bae30d48662 | 49 | etat_pompe = 1 ; |
goldmas | 4:4bae30d48662 | 50 | else |
goldmas | 4:4bae30d48662 | 51 | etat_pompe = 0 ; |
goldmas | 4:4bae30d48662 | 52 | |
goldmas | 4:4bae30d48662 | 53 | if(_capteur.read() >= SEUIL_CPT) //test du capteur |
goldmas | 0:253443d82cba | 54 | _gobelet_en_place = 1 ; |
goldmas | 0:253443d82cba | 55 | else |
goldmas | 0:253443d82cba | 56 | _gobelet_en_place = 0 ; |
goldmas | 0:253443d82cba | 57 | |
goldmas | 4:4bae30d48662 | 58 | if(_electrovanne.read()) //test de l'electrovanne |
goldmas | 4:4bae30d48662 | 59 | etat_pompe = 1 ; |
goldmas | 4:4bae30d48662 | 60 | else |
goldmas | 4:4bae30d48662 | 61 | etat_pompe = 0 ; |
goldmas | 4:4bae30d48662 | 62 | |
goldmas | 4:4bae30d48662 | 63 | // contenue du char : (cela evite l'utilisation de pointeurs (car on a la flemme)) |
goldmas | 4:4bae30d48662 | 64 | //0000 0 "bit pompe" "bit elec" "bit cpt" |
goldmas | 4:4bae30d48662 | 65 | return etat_groupe = (etat_pompe << 2) + (etat_electrovanne << 1) + _gobelet_en_place ; |
goldmas | 4:4bae30d48662 | 66 | } |
goldmas | 4:4bae30d48662 | 67 | |
goldmas | 4:4bae30d48662 | 68 | void bloc_monopompe::stop_pompe (void) |
goldmas | 4:4bae30d48662 | 69 | { |
goldmas | 4:4bae30d48662 | 70 | _pompe = PWM_STOP_POMPE ; |
goldmas | 4:4bae30d48662 | 71 | _electrovanne = ELEC_OUVERTE ; |
goldmas | 0:253443d82cba | 72 | } |