V1
Dependents: VITI_motor_angle_1 VITI_motor_angle_2 VITI_motor_angle_3
TB6549.h@0:1b8889c40a44, 2020-05-21 (annotated)
- Committer:
- gr66
- Date:
- Thu May 21 17:42:47 2020 +0000
- Revision:
- 0:1b8889c40a44
V1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gr66 | 0:1b8889c40a44 | 1 | /* mbed simple H-bridge motor controller |
gr66 | 0:1b8889c40a44 | 2 | * Copyright (c) |
gr66 | 0:1b8889c40a44 | 3 | |
gr66 | 0:1b8889c40a44 | 4 | */ |
gr66 | 0:1b8889c40a44 | 5 | |
gr66 | 0:1b8889c40a44 | 6 | #ifndef MBED_MOTOR_H |
gr66 | 0:1b8889c40a44 | 7 | #define MBED_MOTOR_H |
gr66 | 0:1b8889c40a44 | 8 | |
gr66 | 0:1b8889c40a44 | 9 | #include "mbed.h" |
gr66 | 0:1b8889c40a44 | 10 | |
gr66 | 0:1b8889c40a44 | 11 | /** Interface to control a standard DC motor |
gr66 | 0:1b8889c40a44 | 12 | * |
gr66 | 0:1b8889c40a44 | 13 | * with an H-bridge using a PwmOut and 3 DigitalOuts |
gr66 | 0:1b8889c40a44 | 14 | */ |
gr66 | 0:1b8889c40a44 | 15 | class Motor { |
gr66 | 0:1b8889c40a44 | 16 | public: |
gr66 | 0:1b8889c40a44 | 17 | |
gr66 | 0:1b8889c40a44 | 18 | /** Create a motor control interface |
gr66 | 0:1b8889c40a44 | 19 | * |
gr66 | 0:1b8889c40a44 | 20 | * @param pwm A PwmOut pin, driving the H-bridge enable line to control the speed |
gr66 | 0:1b8889c40a44 | 21 | * @param in1 A DigitalOut, |
gr66 | 0:1b8889c40a44 | 22 | * @param in2 A DigitalOut, |
gr66 | 0:1b8889c40a44 | 23 | * @param sb |
gr66 | 0:1b8889c40a44 | 24 | A DigitalOut, |
gr66 | 0:1b8889c40a44 | 25 | */ |
gr66 | 0:1b8889c40a44 | 26 | Motor(PinName pwm, PinName in1, PinName in2, PinName sb); |
gr66 | 0:1b8889c40a44 | 27 | |
gr66 | 0:1b8889c40a44 | 28 | /** Set the speed of the motor |
gr66 | 0:1b8889c40a44 | 29 | * |
gr66 | 0:1b8889c40a44 | 30 | * @param speed The speed of the motor as a normalised value between -1.0 and 1.0 |
gr66 | 0:1b8889c40a44 | 31 | */ |
gr66 | 0:1b8889c40a44 | 32 | void speed(float speed); |
gr66 | 0:1b8889c40a44 | 33 | |
gr66 | 0:1b8889c40a44 | 34 | protected: |
gr66 | 0:1b8889c40a44 | 35 | PwmOut _pwm; |
gr66 | 0:1b8889c40a44 | 36 | DigitalOut _in1; |
gr66 | 0:1b8889c40a44 | 37 | DigitalOut _in2; |
gr66 | 0:1b8889c40a44 | 38 | DigitalOut _sb; |
gr66 | 0:1b8889c40a44 | 39 | |
gr66 | 0:1b8889c40a44 | 40 | }; |
gr66 | 0:1b8889c40a44 | 41 | |
gr66 | 0:1b8889c40a44 | 42 | #endif |
gr66 | 0:1b8889c40a44 | 43 |