![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
carte esclave pompe 2020 V1
Dependencies: mbed ident_crac
Diff: class_ventouse.cpp
- Revision:
- 0:84a8c24e29ae
- Child:
- 2:4cc8fa2f64be
diff -r 000000000000 -r 84a8c24e29ae class_ventouse.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/class_ventouse.cpp Mon May 06 07:53:34 2019 +0000 @@ -0,0 +1,68 @@ +#include "class_ventouse.h" + +#define SEUIL 0.3 + + + +Ventouse::Ventouse(PinName pinPompe, PinName pinElectrovanne, PinName pinCapteurPression) : m_pinPompe(pinPompe), +m_pinElectrovanne(pinElectrovanne), m_pinCapteurPression(pinCapteurPression) +{ + m_pompe = new PwmOut(m_pinPompe); + m_electrovanne = new PwmOut(m_pinElectrovanne); + m_pression = new AnalogIn(m_pinCapteurPression); + + m_pompe->period_us(50); + m_electrovanne->period_us(50); + + m_pompe->write(0); + m_electrovanne->write(0); +} + +void Ventouse::attraper() +{ + m_pompe->write(0.5); + m_electrovanne->write(0.0); + +} + +void Ventouse::relacher() +{ + m_pompe->write(0.0); + m_electrovanne->write(1.0); + +} + +int Ventouse::getPression() +{ + if(m_pression->read() > SEUIL){ + return 1; + } + else{ + return 0; + } + +} + +int Ventouse::getPompe() +{ + if(m_pompe->read() > 0){ + return 1; + } + else{ + return 0; + } +} + +void Ventouse::setPompe(float val) +{ + m_pompe->write(val); +} + +void Ventouse::setElectrovanne(float val) +{ + m_electrovanne->write(val); +} + + + +