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