![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
carte esclave pompe 2020 V1
Dependencies: mbed ident_crac
class_ventouse.cpp@0:84a8c24e29ae, 2019-05-06 (annotated)
- Committer:
- marwanesaich
- Date:
- Mon May 06 07:53:34 2019 +0000
- Revision:
- 0:84a8c24e29ae
- Child:
- 2:4cc8fa2f64be
Code petit robot sans ISR capteurs pompes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
marwanesaich | 0:84a8c24e29ae | 1 | #include "class_ventouse.h" |
marwanesaich | 0:84a8c24e29ae | 2 | |
marwanesaich | 0:84a8c24e29ae | 3 | #define SEUIL 0.3 |
marwanesaich | 0:84a8c24e29ae | 4 | |
marwanesaich | 0:84a8c24e29ae | 5 | |
marwanesaich | 0:84a8c24e29ae | 6 | |
marwanesaich | 0:84a8c24e29ae | 7 | Ventouse::Ventouse(PinName pinPompe, PinName pinElectrovanne, PinName pinCapteurPression) : m_pinPompe(pinPompe), |
marwanesaich | 0:84a8c24e29ae | 8 | m_pinElectrovanne(pinElectrovanne), m_pinCapteurPression(pinCapteurPression) |
marwanesaich | 0:84a8c24e29ae | 9 | { |
marwanesaich | 0:84a8c24e29ae | 10 | m_pompe = new PwmOut(m_pinPompe); |
marwanesaich | 0:84a8c24e29ae | 11 | m_electrovanne = new PwmOut(m_pinElectrovanne); |
marwanesaich | 0:84a8c24e29ae | 12 | m_pression = new AnalogIn(m_pinCapteurPression); |
marwanesaich | 0:84a8c24e29ae | 13 | |
marwanesaich | 0:84a8c24e29ae | 14 | m_pompe->period_us(50); |
marwanesaich | 0:84a8c24e29ae | 15 | m_electrovanne->period_us(50); |
marwanesaich | 0:84a8c24e29ae | 16 | |
marwanesaich | 0:84a8c24e29ae | 17 | m_pompe->write(0); |
marwanesaich | 0:84a8c24e29ae | 18 | m_electrovanne->write(0); |
marwanesaich | 0:84a8c24e29ae | 19 | } |
marwanesaich | 0:84a8c24e29ae | 20 | |
marwanesaich | 0:84a8c24e29ae | 21 | void Ventouse::attraper() |
marwanesaich | 0:84a8c24e29ae | 22 | { |
marwanesaich | 0:84a8c24e29ae | 23 | m_pompe->write(0.5); |
marwanesaich | 0:84a8c24e29ae | 24 | m_electrovanne->write(0.0); |
marwanesaich | 0:84a8c24e29ae | 25 | |
marwanesaich | 0:84a8c24e29ae | 26 | } |
marwanesaich | 0:84a8c24e29ae | 27 | |
marwanesaich | 0:84a8c24e29ae | 28 | void Ventouse::relacher() |
marwanesaich | 0:84a8c24e29ae | 29 | { |
marwanesaich | 0:84a8c24e29ae | 30 | m_pompe->write(0.0); |
marwanesaich | 0:84a8c24e29ae | 31 | m_electrovanne->write(1.0); |
marwanesaich | 0:84a8c24e29ae | 32 | |
marwanesaich | 0:84a8c24e29ae | 33 | } |
marwanesaich | 0:84a8c24e29ae | 34 | |
marwanesaich | 0:84a8c24e29ae | 35 | int Ventouse::getPression() |
marwanesaich | 0:84a8c24e29ae | 36 | { |
marwanesaich | 0:84a8c24e29ae | 37 | if(m_pression->read() > SEUIL){ |
marwanesaich | 0:84a8c24e29ae | 38 | return 1; |
marwanesaich | 0:84a8c24e29ae | 39 | } |
marwanesaich | 0:84a8c24e29ae | 40 | else{ |
marwanesaich | 0:84a8c24e29ae | 41 | return 0; |
marwanesaich | 0:84a8c24e29ae | 42 | } |
marwanesaich | 0:84a8c24e29ae | 43 | |
marwanesaich | 0:84a8c24e29ae | 44 | } |
marwanesaich | 0:84a8c24e29ae | 45 | |
marwanesaich | 0:84a8c24e29ae | 46 | int Ventouse::getPompe() |
marwanesaich | 0:84a8c24e29ae | 47 | { |
marwanesaich | 0:84a8c24e29ae | 48 | if(m_pompe->read() > 0){ |
marwanesaich | 0:84a8c24e29ae | 49 | return 1; |
marwanesaich | 0:84a8c24e29ae | 50 | } |
marwanesaich | 0:84a8c24e29ae | 51 | else{ |
marwanesaich | 0:84a8c24e29ae | 52 | return 0; |
marwanesaich | 0:84a8c24e29ae | 53 | } |
marwanesaich | 0:84a8c24e29ae | 54 | } |
marwanesaich | 0:84a8c24e29ae | 55 | |
marwanesaich | 0:84a8c24e29ae | 56 | void Ventouse::setPompe(float val) |
marwanesaich | 0:84a8c24e29ae | 57 | { |
marwanesaich | 0:84a8c24e29ae | 58 | m_pompe->write(val); |
marwanesaich | 0:84a8c24e29ae | 59 | } |
marwanesaich | 0:84a8c24e29ae | 60 | |
marwanesaich | 0:84a8c24e29ae | 61 | void Ventouse::setElectrovanne(float val) |
marwanesaich | 0:84a8c24e29ae | 62 | { |
marwanesaich | 0:84a8c24e29ae | 63 | m_electrovanne->write(val); |
marwanesaich | 0:84a8c24e29ae | 64 | } |
marwanesaich | 0:84a8c24e29ae | 65 | |
marwanesaich | 0:84a8c24e29ae | 66 | |
marwanesaich | 0:84a8c24e29ae | 67 | |
marwanesaich | 0:84a8c24e29ae | 68 |