Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: motor_relay
Dependents: dog_V3_3_testmotor
motion_control.h@6:41d7cf11fdb1, 2015-07-20 (annotated)
- Committer:
- soulx
- Date:
- Mon Jul 20 09:15:28 2015 +0000
- Revision:
- 6:41d7cf11fdb1
- Parent:
- 5:91d905f8bef7
- Child:
- 7:94518aee126b
add comment
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
soulx | 0:77ab14788110 | 1 | #ifndef MBED_MOTOR_RE_H |
soulx | 0:77ab14788110 | 2 | #define MBED_MOTOR_RE_H |
soulx | 0:77ab14788110 | 3 | |
soulx | 0:77ab14788110 | 4 | #include "mbed.h" |
soulx | 0:77ab14788110 | 5 | #include "motor_relay.h" |
soulx | 0:77ab14788110 | 6 | |
soulx | 0:77ab14788110 | 7 | class MOTION_CONTROL |
soulx | 0:77ab14788110 | 8 | { |
soulx | 0:77ab14788110 | 9 | public: |
soulx | 0:77ab14788110 | 10 | MOTION_CONTROL(PinName dirA, PinName dirB, PinName limitUp, PinName limitDown, PinName vr ); |
soulx | 0:77ab14788110 | 11 | |
soulx | 4:6509fec6a6fb | 12 | int limit_motor(uint8_t dirction); |
soulx | 4:6509fec6a6fb | 13 | int8_t position_control(uint16_t target); |
soulx | 0:77ab14788110 | 14 | void calibration(); |
soulx | 5:91d905f8bef7 | 15 | |
soulx | 6:41d7cf11fdb1 | 16 | //limit |
soulx | 6:41d7cf11fdb1 | 17 | // open : '1' |
soulx | 6:41d7cf11fdb1 | 18 | // shot : '0' |
soulx | 6:41d7cf11fdb1 | 19 | int GetLimitUp(); |
soulx | 3:4fa191f2194d | 20 | int GetLimitDown(); |
soulx | 5:91d905f8bef7 | 21 | |
soulx | 0:77ab14788110 | 22 | void SetMargin(int16_t data); |
soulx | 2:2cadf29245f4 | 23 | int16_t GetMargin(); |
soulx | 5:91d905f8bef7 | 24 | |
soulx | 2:2cadf29245f4 | 25 | uint16_t GetMaxPosition(); |
soulx | 2:2cadf29245f4 | 26 | uint16_t GetMinPosition(); |
soulx | 5:91d905f8bef7 | 27 | void SetMaxPosition(uint16_t value); |
soulx | 5:91d905f8bef7 | 28 | void SetMinPosition(uint16_t value); |
soulx | 4:6509fec6a6fb | 29 | |
soulx | 4:6509fec6a6fb | 30 | uint16_t GetAnalog(); |
soulx | 4:6509fec6a6fb | 31 | uint16_t GetPosition(); |
soulx | 5:91d905f8bef7 | 32 | |
soulx | 4:6509fec6a6fb | 33 | void stop(); |
soulx | 0:77ab14788110 | 34 | |
soulx | 0:77ab14788110 | 35 | private: |
soulx | 0:77ab14788110 | 36 | |
soulx | 4:6509fec6a6fb | 37 | uint16_t Scale(uint16_t data); |
soulx | 5:91d905f8bef7 | 38 | |
soulx | 4:6509fec6a6fb | 39 | MOTOR_RELAY motor; |
soulx | 0:77ab14788110 | 40 | |
soulx | 0:77ab14788110 | 41 | DigitalIn _limit_up; |
soulx | 0:77ab14788110 | 42 | DigitalIn _limit_down; |
soulx | 0:77ab14788110 | 43 | AnalogIn _position; |
soulx | 5:91d905f8bef7 | 44 | |
soulx | 0:77ab14788110 | 45 | int16_t error; |
soulx | 0:77ab14788110 | 46 | int16_t MARGIN; |
soulx | 5:91d905f8bef7 | 47 | |
soulx | 2:2cadf29245f4 | 48 | uint16_t MAX_POSITION; |
soulx | 2:2cadf29245f4 | 49 | uint16_t MIN_POSITION; |
soulx | 5:91d905f8bef7 | 50 | |
soulx | 4:6509fec6a6fb | 51 | const static uint16_t scale = 64; |
soulx | 5:91d905f8bef7 | 52 | const static uint16_t LOOP = 100; |
soulx | 5:91d905f8bef7 | 53 | |
soulx | 5:91d905f8bef7 | 54 | //float Kp; |
soulx | 5:91d905f8bef7 | 55 | //float Ki; |
soulx | 5:91d905f8bef7 | 56 | //float Kd; |
soulx | 5:91d905f8bef7 | 57 | //float margin_pid; |
soulx | 0:77ab14788110 | 58 | |
soulx | 0:77ab14788110 | 59 | }; |
soulx | 0:77ab14788110 | 60 | |
soulx | 0:77ab14788110 | 61 | #endif |