![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
carte esclave pompe 2020 V1
Dependencies: mbed ident_crac
Diff: class_ventouse.cpp
- Revision:
- 5:176e7353ba1c
- Parent:
- 4:82c90657da4a
- Child:
- 6:fda992188a2f
diff -r 82c90657da4a -r 176e7353ba1c class_ventouse.cpp --- a/class_ventouse.cpp Wed May 08 17:46:13 2019 +0000 +++ b/class_ventouse.cpp Wed May 15 09:09:00 2019 +0000 @@ -5,6 +5,25 @@ #define SEUIL 0.30 +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; +} + + Ventouse::Ventouse(PinName pinPompe, PinName pinElectrovanne, PinName pinCapteurPression, char index) : m_pinPompe(pinPompe), m_pinElectrovanne(pinElectrovanne), m_pinCapteurPression(pinCapteurPression), m_index(index) { @@ -23,6 +42,7 @@ etat = Attente; m_ack = 0; + flag_electrovanne = 1; } void Ventouse::automate() @@ -53,7 +73,6 @@ if(flag_relacher) { relacher(); - wait(0.5); etat = Relacher; } break; @@ -62,7 +81,7 @@ if(!getPression()) { can.write(CANMessage(HACHEUR_RELEASE_ATOM_ACK,&m_index,1)); - m_electrovanne->write(0.0); + if(flag_electrovanne) m_electrovanne->write(0.0); etat = Attente; } break; @@ -79,15 +98,15 @@ void Ventouse::attraper() { - m_pompe->write(0.5); - m_electrovanne->write(0.0); + m_pompe->write(0.7); + 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); } @@ -119,7 +138,7 @@ void Ventouse::setElectrovanne(float val) { - m_electrovanne->write(val); + if(flag_electrovanne)m_electrovanne->write(val); }