![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
carte esclave pompe 2020 V1
Dependencies: mbed ident_crac
Diff: class_ventouse.cpp
- Revision:
- 3:cf33f9d4d6ff
- Parent:
- 2:4cc8fa2f64be
--- a/class_ventouse.cpp Tue May 07 13:14:29 2019 +0000 +++ b/class_ventouse.cpp Tue May 07 18:53:22 2019 +0000 @@ -21,6 +21,27 @@ etat = Attente; m_ack = 0; + + flag_electrovanne = 1; +} + +Ventouse::Ventouse(PinName pinPompe, PinName pinCapteurPression, char index) : m_pinPompe(pinPompe), +m_pinCapteurPression(pinCapteurPression), m_index(index) +{ + m_pompe = new PwmOut(m_pinPompe); + m_pression = new AnalogIn(m_pinCapteurPression); + + m_pompe->period_us(50); + + m_pompe->write(0); + + flag_attraper = 0; + flag_relacher = 0; + + etat = Attente; + m_ack = 0; + + flag_electrovanne = 0; } void Ventouse::automate() @@ -50,7 +71,7 @@ if(flag_relacher) { relacher(); - wait(0.5); + //wait(0.5); etat = Relacher; } break; @@ -58,7 +79,7 @@ case Relacher : if(!getPression()) { - m_electrovanne->write(0.0); + if(flag_electrovanne) m_electrovanne->write(0.0); etat = Attente; } break; @@ -76,20 +97,20 @@ void Ventouse::attraper() { m_pompe->write(0.5); - m_electrovanne->write(0.0); + if(flag_electrovanne) m_electrovanne->write(0.0); } void Ventouse::relacher() { m_pompe->write(0.0); - m_electrovanne->write(1.0); + if(flag_electrovanne) m_electrovanne->write(1.0); } bool Ventouse::getPression() { - if(m_pression->read() > SEUIL){ + if((double)m_pression->read() > SEUIL){ return 1; } else{ @@ -115,7 +136,7 @@ void Ventouse::setElectrovanne(float val) { - m_electrovanne->write(val); + if(flag_electrovanne) m_electrovanne->write(val); }