![](/media/cache/profiles/Cristian_Castro_-_Foto.jpg.50x50_q85.jpg)
Control de velocidad y dirección de giro de un motor PAP con la tarjeta F407. Se incluyen las librerías con la clase Motor.
Motor.h@0:3ca0289b7f8a, 2021-09-03 (annotated)
- Committer:
- CCastrop1012
- Date:
- Fri Sep 03 04:58:03 2021 +0000
- Revision:
- 0:3ca0289b7f8a
Control de velocidad y direccion de giro de un motor PAP con la tarjeta F407. Se incluyen las librerias con la clase Motor.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
CCastrop1012 | 0:3ca0289b7f8a | 1 | #ifndef Motor_H |
CCastrop1012 | 0:3ca0289b7f8a | 2 | #define Motor_H |
CCastrop1012 | 0:3ca0289b7f8a | 3 | #include "mbed.h" |
CCastrop1012 | 0:3ca0289b7f8a | 4 | /* ************************************************************************** |
CCastrop1012 | 0:3ca0289b7f8a | 5 | |
CCastrop1012 | 0:3ca0289b7f8a | 6 | @CCastrop |
CCastrop1012 | 0:3ca0289b7f8a | 7 | cristiank.castrop@ecci.edu.co |
CCastrop1012 | 0:3ca0289b7f8a | 8 | |
CCastrop1012 | 0:3ca0289b7f8a | 9 | |
CCastrop1012 | 0:3ca0289b7f8a | 10 | datasheet https://www.mouser.com/catalog/specsheets/TCS3200-E11.pdf |
CCastrop1012 | 0:3ca0289b7f8a | 11 | |
CCastrop1012 | 0:3ca0289b7f8a | 12 | |
CCastrop1012 | 0:3ca0289b7f8a | 13 | S0 Frequency scaling |
CCastrop1012 | 0:3ca0289b7f8a | 14 | S1 Frequency scaling |
CCastrop1012 | 0:3ca0289b7f8a | 15 | S2 Photo diode selection |
CCastrop1012 | 0:3ca0289b7f8a | 16 | S3 Photo diode selection |
CCastrop1012 | 0:3ca0289b7f8a | 17 | OutFreq Frequency |
CCastrop1012 | 0:3ca0289b7f8a | 18 | |
CCastrop1012 | 0:3ca0289b7f8a | 19 | ----------------------------------- |
CCastrop1012 | 0:3ca0289b7f8a | 20 | | ____________ ____________ | |
CCastrop1012 | 0:3ca0289b7f8a | 21 | ----> | | | | | | ___ ___ |
CCastrop1012 | 0:3ca0289b7f8a | 22 | Light | | Photodiode | | Current |--|---OUTPUT_FREQ | |___| |___ |
CCastrop1012 | 0:3ca0289b7f8a | 23 | ----> | | Array |---| to | | |
CCastrop1012 | 0:3ca0289b7f8a | 24 | | | | | Frequency | | |
CCastrop1012 | 0:3ca0289b7f8a | 25 | | |____________| |____________| | |
CCastrop1012 | 0:3ca0289b7f8a | 26 | | ^ ^ ^ ^ | |
CCastrop1012 | 0:3ca0289b7f8a | 27 | -------|--|-------------|--|------- |
CCastrop1012 | 0:3ca0289b7f8a | 28 | | | | | |
CCastrop1012 | 0:3ca0289b7f8a | 29 | S2 S3 S0 S1 |
CCastrop1012 | 0:3ca0289b7f8a | 30 | |
CCastrop1012 | 0:3ca0289b7f8a | 31 | SO | S1 | OUTPUT FREQUENCY SCALING | | S2 | S3 | PHOTODIODE TYPE | |
CCastrop1012 | 0:3ca0289b7f8a | 32 | 0 | 0 | power down | | 0 | 0 | Red | |
CCastrop1012 | 0:3ca0289b7f8a | 33 | 0 | 1 | 2% | | 0 | 1 | Blue | |
CCastrop1012 | 0:3ca0289b7f8a | 34 | 1 | 0 | 20% | | 1 | 0 | Clear (no filter) | |
CCastrop1012 | 0:3ca0289b7f8a | 35 | 1 | 1 | 100% | | 1 | 1 | Green | |
CCastrop1012 | 0:3ca0289b7f8a | 36 | |
CCastrop1012 | 0:3ca0289b7f8a | 37 | ******************************************************************************/ |
CCastrop1012 | 0:3ca0289b7f8a | 38 | |
CCastrop1012 | 0:3ca0289b7f8a | 39 | |
CCastrop1012 | 0:3ca0289b7f8a | 40 | |
CCastrop1012 | 0:3ca0289b7f8a | 41 | class MotorContinuo { |
CCastrop1012 | 0:3ca0289b7f8a | 42 | public: |
CCastrop1012 | 0:3ca0289b7f8a | 43 | |
CCastrop1012 | 0:3ca0289b7f8a | 44 | MotorContinuo(PinName L1, PinName L2, PinName speedPin); // declaracion del Objeto |
CCastrop1012 | 0:3ca0289b7f8a | 45 | |
CCastrop1012 | 0:3ca0289b7f8a | 46 | void Forward(); // Da un sentido de giro al motor |
CCastrop1012 | 0:3ca0289b7f8a | 47 | void Back(); // Genera un sentido de giro contrario al de Forward |
CCastrop1012 | 0:3ca0289b7f8a | 48 | void Stop(); // Detiene el motor dejando el movimiento libre |
CCastrop1012 | 0:3ca0289b7f8a | 49 | void StopT(); // Detiene el motor truncando o enclavando el movimiento(Lo mantiene quieto). |
CCastrop1012 | 0:3ca0289b7f8a | 50 | void SpeedDuty(int v); // Varia la velocidad de giro del motor de 0 a 100% |
CCastrop1012 | 0:3ca0289b7f8a | 51 | void SpinLength_ms(float t); // Duración del giro en ms |
CCastrop1012 | 0:3ca0289b7f8a | 52 | void SpinLength(float t); // Duración del giro |
CCastrop1012 | 0:3ca0289b7f8a | 53 | |
CCastrop1012 | 0:3ca0289b7f8a | 54 | float GetSpeed(); // Return Duty Cycle of PWM in % de 0 a 100 |
CCastrop1012 | 0:3ca0289b7f8a | 55 | |
CCastrop1012 | 0:3ca0289b7f8a | 56 | private: |
CCastrop1012 | 0:3ca0289b7f8a | 57 | DigitalOut _L1; |
CCastrop1012 | 0:3ca0289b7f8a | 58 | DigitalOut _L2; |
CCastrop1012 | 0:3ca0289b7f8a | 59 | PwmOut _speedPin; |
CCastrop1012 | 0:3ca0289b7f8a | 60 | |
CCastrop1012 | 0:3ca0289b7f8a | 61 | |
CCastrop1012 | 0:3ca0289b7f8a | 62 | }; |
CCastrop1012 | 0:3ca0289b7f8a | 63 | #endif |
CCastrop1012 | 0:3ca0289b7f8a | 64 | |
CCastrop1012 | 0:3ca0289b7f8a | 65 | |
CCastrop1012 | 0:3ca0289b7f8a | 66 | |
CCastrop1012 | 0:3ca0289b7f8a | 67 | |
CCastrop1012 | 0:3ca0289b7f8a | 68 | |
CCastrop1012 | 0:3ca0289b7f8a | 69 | |
CCastrop1012 | 0:3ca0289b7f8a | 70 | |
CCastrop1012 | 0:3ca0289b7f8a | 71 | |
CCastrop1012 | 0:3ca0289b7f8a | 72 | |
CCastrop1012 | 0:3ca0289b7f8a | 73 | |
CCastrop1012 | 0:3ca0289b7f8a | 74 | |
CCastrop1012 | 0:3ca0289b7f8a | 75 | |
CCastrop1012 | 0:3ca0289b7f8a | 76 | |
CCastrop1012 | 0:3ca0289b7f8a | 77 | |
CCastrop1012 | 0:3ca0289b7f8a | 78 |