Gestion pont-H pour moteur CC
yMOTOR.h@1:4dc14e8e5ff7, 2015-09-12 (annotated)
- Committer:
- Jean92
- Date:
- Sat Sep 12 19:17:55 2015 +0000
- Revision:
- 1:4dc14e8e5ff7
- Parent:
- 0:af7b948d1f33
- Child:
- 2:980b46615b6e
Librairie de gestion d'un pont-H pour moteur (v0.2)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jean92 | 0:af7b948d1f33 | 1 | /* mbed yMOTOR Library |
Jean92 | 0:af7b948d1f33 | 2 | * Copyright (c) 2015 Jean92, https://developer.mbed.org/users/Jean92/ |
Jean92 | 0:af7b948d1f33 | 3 | */ |
Jean92 | 0:af7b948d1f33 | 4 | |
Jean92 | 0:af7b948d1f33 | 5 | /** |
Jean92 | 0:af7b948d1f33 | 6 | * @file yMOTOR.h |
Jean92 | 0:af7b948d1f33 | 7 | * @brief Header de la classe 'yMOTOR' |
Jean92 | 1:4dc14e8e5ff7 | 8 | * @version V0.2 |
Jean92 | 1:4dc14e8e5ff7 | 9 | * @date Sept-2015 |
Jean92 | 0:af7b948d1f33 | 10 | * @note by Jean92 \n |
Jean92 | 0:af7b948d1f33 | 11 | * Controlleur pour Pont-H (MC33886)" |
Jean92 | 0:af7b948d1f33 | 12 | * |
Jean92 | 0:af7b948d1f33 | 13 | */ |
Jean92 | 0:af7b948d1f33 | 14 | |
Jean92 | 0:af7b948d1f33 | 15 | #ifndef DEF_yMOTOR_H |
Jean92 | 0:af7b948d1f33 | 16 | #define DEF_yMOTOR_H |
Jean92 | 0:af7b948d1f33 | 17 | |
Jean92 | 0:af7b948d1f33 | 18 | #include "mbed.h" |
Jean92 | 0:af7b948d1f33 | 19 | |
Jean92 | 0:af7b948d1f33 | 20 | #define yARRET 0 |
Jean92 | 0:af7b948d1f33 | 21 | #define yMARCHE 1 |
Jean92 | 0:af7b948d1f33 | 22 | #define yDB_def 0.3 // dead band around 0.0 for nul speed |
Jean92 | 0:af7b948d1f33 | 23 | #define yPeriod_def 0.01 // seconds |
Jean92 | 0:af7b948d1f33 | 24 | |
Jean92 | 0:af7b948d1f33 | 25 | class yMOTOR |
Jean92 | 0:af7b948d1f33 | 26 | { |
Jean92 | 0:af7b948d1f33 | 27 | public: /// Methodes (visibles par tous!) |
Jean92 | 0:af7b948d1f33 | 28 | |
Jean92 | 0:af7b948d1f33 | 29 | /** Interface de controle du moteur |
Jean92 | 0:af7b948d1f33 | 30 | * @param pwm (Pwmout, vitesse variable) |
Jean92 | 0:af7b948d1f33 | 31 | * @param av (DigitalOut, marche avant) |
Jean92 | 0:af7b948d1f33 | 32 | * @param ar (DigialOut, marche arriere) |
Jean92 | 0:af7b948d1f33 | 33 | */ |
Jean92 | 0:af7b948d1f33 | 34 | yMOTOR(PinName pwm, PinName av, PinName ar); /// Constructeur par defaut |
Jean92 | 0:af7b948d1f33 | 35 | ~yMOTOR(); /// Destructeur |
Jean92 | 0:af7b948d1f33 | 36 | |
Jean92 | 0:af7b948d1f33 | 37 | /** Vitesse request |
Jean92 | 0:af7b948d1f33 | 38 | * @param speed (float normalised [-1.0,+1.0] |
Jean92 | 0:af7b948d1f33 | 39 | * negative ==> reverse, positive ==> forward |
Jean92 | 0:af7b948d1f33 | 40 | */ |
Jean92 | 0:af7b948d1f33 | 41 | void Speed(float speed); |
Jean92 | 0:af7b948d1f33 | 42 | |
Jean92 | 0:af7b948d1f33 | 43 | /** PWM duty cycle periode in seconde |
Jean92 | 0:af7b948d1f33 | 44 | * wrapper for PwmOut::period() |
Jean92 | 0:af7b948d1f33 | 45 | * @param seconds (PWM duty cycle) |
Jean92 | 0:af7b948d1f33 | 46 | */ |
Jean92 | 0:af7b948d1f33 | 47 | void Period(float seconds); |
Jean92 | 0:af7b948d1f33 | 48 | |
Jean92 | 0:af7b948d1f33 | 49 | /** Marche/Arret request |
Jean92 | 0:af7b948d1f33 | 50 | * yARRET ==> av = ar = 0 |
Jean92 | 0:af7b948d1f33 | 51 | * yMARCHE ==> av & ar = sign of speed |
Jean92 | 0:af7b948d1f33 | 52 | */ |
Jean92 | 0:af7b948d1f33 | 53 | //void mararr(int mararr = yARRET); |
Jean92 | 0:af7b948d1f33 | 54 | void MarArr(int mararr); |
Jean92 | 0:af7b948d1f33 | 55 | |
Jean92 | 0:af7b948d1f33 | 56 | /** Etat marche (running state) |
Jean92 | 0:af7b948d1f33 | 57 | */ |
Jean92 | 0:af7b948d1f33 | 58 | bool Run(); |
Jean92 | 0:af7b948d1f33 | 59 | |
Jean92 | 0:af7b948d1f33 | 60 | /** Vitesse effective |
Jean92 | 0:af7b948d1f33 | 61 | * float normalised [-1.0,+1.0] |
Jean92 | 0:af7b948d1f33 | 62 | * negative ==> reverse, positive ==> forward |
Jean92 | 0:af7b948d1f33 | 63 | */ |
Jean92 | 0:af7b948d1f33 | 64 | float Velocity(); |
Jean92 | 0:af7b948d1f33 | 65 | |
Jean92 | 0:af7b948d1f33 | 66 | private: /// Attributs - m_membres (visibles par les methodes) |
Jean92 | 0:af7b948d1f33 | 67 | float m_speed; |
Jean92 | 0:af7b948d1f33 | 68 | |
Jean92 | 0:af7b948d1f33 | 69 | protected: /// Attibuts (accessibles seulement via les methodes) |
Jean92 | 0:af7b948d1f33 | 70 | PwmOut _pwm; |
Jean92 | 0:af7b948d1f33 | 71 | DigitalOut _av; |
Jean92 | 0:af7b948d1f33 | 72 | DigitalOut _ar; |
Jean92 | 0:af7b948d1f33 | 73 | |
Jean92 | 0:af7b948d1f33 | 74 | }; |
Jean92 | 0:af7b948d1f33 | 75 | |
Jean92 | 0:af7b948d1f33 | 76 | #endif |
Jean92 | 0:af7b948d1f33 | 77 | |
Jean92 | 1:4dc14e8e5ff7 | 78 | /* mbed yMOTOR Library |
Jean92 | 1:4dc14e8e5ff7 | 79 | * Copyright (c) 2015 Jean92, https://developer.mbed.org/users/Jean92/ |
Jean92 | 1:4dc14e8e5ff7 | 80 | * |
Jean92 | 1:4dc14e8e5ff7 | 81 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
Jean92 | 1:4dc14e8e5ff7 | 82 | * of this software and associated documentation files (the "Software"), to deal |
Jean92 | 1:4dc14e8e5ff7 | 83 | * in the Software without restriction, including without limitation the rights |
Jean92 | 1:4dc14e8e5ff7 | 84 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
Jean92 | 1:4dc14e8e5ff7 | 85 | * copies of the Software, and to permit persons to whom the Software is |
Jean92 | 1:4dc14e8e5ff7 | 86 | * furnished to do so, subject to the following conditions: |
Jean92 | 1:4dc14e8e5ff7 | 87 | * |
Jean92 | 1:4dc14e8e5ff7 | 88 | * The above copyright notice and this permission notice shall be included in |
Jean92 | 1:4dc14e8e5ff7 | 89 | * all copies or substantial portions of the Software. |
Jean92 | 1:4dc14e8e5ff7 | 90 | * |
Jean92 | 1:4dc14e8e5ff7 | 91 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
Jean92 | 1:4dc14e8e5ff7 | 92 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
Jean92 | 1:4dc14e8e5ff7 | 93 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
Jean92 | 1:4dc14e8e5ff7 | 94 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
Jean92 | 1:4dc14e8e5ff7 | 95 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
Jean92 | 1:4dc14e8e5ff7 | 96 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
Jean92 | 1:4dc14e8e5ff7 | 97 | * THE SOFTWARE. |
Jean92 | 1:4dc14e8e5ff7 | 98 | */ |
Jean92 | 1:4dc14e8e5ff7 | 99 | // MIT Licence |
Jean92 | 1:4dc14e8e5ff7 | 100 | |
Jean92 | 0:af7b948d1f33 | 101 | /** |
Jean92 | 0:af7b948d1f33 | 102 | * @note \n |
Jean92 | 0:af7b948d1f33 | 103 | * That's all folks! |
Jean92 | 0:af7b948d1f33 | 104 | */ |