Gestion pont-H pour moteur CC

Committer:
Jean92
Date:
Sun Sep 13 11:07:45 2015 +0000
Revision:
2:980b46615b6e
Parent:
1:4dc14e8e5ff7
Child:
3:5181bcf1f0a6
v0.4 ok

Who changed what in which revision?

UserRevisionLine numberNew 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 2:980b46615b6e 8 * @version V0.4
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 2:980b46615b6e 22 #define yDB_def 0.3 // dead band around 0.0 for nul speed
Jean92 2:980b46615b6e 23 #define yPeriod_def 0.01 // en 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 2:980b46615b6e 68 bool m_run;
Jean92 0:af7b948d1f33 69
Jean92 0:af7b948d1f33 70 protected: /// Attibuts (accessibles seulement via les methodes)
Jean92 2:980b46615b6e 71 PwmOut _pwm; // par heritage
Jean92 0:af7b948d1f33 72 DigitalOut _av;
Jean92 0:af7b948d1f33 73 DigitalOut _ar;
Jean92 0:af7b948d1f33 74
Jean92 0:af7b948d1f33 75 };
Jean92 0:af7b948d1f33 76
Jean92 0:af7b948d1f33 77 #endif
Jean92 0:af7b948d1f33 78
Jean92 1:4dc14e8e5ff7 79 /* mbed yMOTOR Library
Jean92 1:4dc14e8e5ff7 80 * Copyright (c) 2015 Jean92, https://developer.mbed.org/users/Jean92/
Jean92 1:4dc14e8e5ff7 81 *
Jean92 1:4dc14e8e5ff7 82 * Permission is hereby granted, free of charge, to any person obtaining a copy
Jean92 1:4dc14e8e5ff7 83 * of this software and associated documentation files (the "Software"), to deal
Jean92 1:4dc14e8e5ff7 84 * in the Software without restriction, including without limitation the rights
Jean92 1:4dc14e8e5ff7 85 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Jean92 1:4dc14e8e5ff7 86 * copies of the Software, and to permit persons to whom the Software is
Jean92 1:4dc14e8e5ff7 87 * furnished to do so, subject to the following conditions:
Jean92 1:4dc14e8e5ff7 88 *
Jean92 1:4dc14e8e5ff7 89 * The above copyright notice and this permission notice shall be included in
Jean92 1:4dc14e8e5ff7 90 * all copies or substantial portions of the Software.
Jean92 1:4dc14e8e5ff7 91 *
Jean92 1:4dc14e8e5ff7 92 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Jean92 1:4dc14e8e5ff7 93 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Jean92 1:4dc14e8e5ff7 94 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Jean92 1:4dc14e8e5ff7 95 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Jean92 1:4dc14e8e5ff7 96 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Jean92 1:4dc14e8e5ff7 97 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Jean92 1:4dc14e8e5ff7 98 * THE SOFTWARE.
Jean92 1:4dc14e8e5ff7 99 */
Jean92 1:4dc14e8e5ff7 100 // MIT Licence
Jean92 1:4dc14e8e5ff7 101
Jean92 0:af7b948d1f33 102 /**
Jean92 0:af7b948d1f33 103 * @note \n
Jean92 0:af7b948d1f33 104 * That's all folks!
Jean92 0:af7b948d1f33 105 */