NHK2017Ateamかにろぼ
Dependencies: 2017NHKpin_config mbed FEP HMC6352 MotorDriverController PID QEI omni
\ ̄\ / ̄/ /l \ \ / / lヽ | ヽ ヽ | | / / | \ ` ‐ヽ ヽ ● ● / / ‐ / \ __ l | ||___|| / l __ / \ \ / \/ /\| 人__人 |/\ //\| |/\\ //\| |/\\ / . \_____/ \ ┏┓ ┏━┓┏┓ ┏┓ ┏┓┏┓ ┏┓ ┏┓┗┛ ┏┓ ┗┓┃┗┛ ┏┛┗━┓ ┃┃┃┃ ┃┃┏━┛┗┓┏┓┏┛┗━┓┃┃┏┓┏┓┏━━━┓ ┗┓┏━┛ ┃┃┗┛ ┃┃┗━┓┏┛┗┛┗┓┏┓┃┗┛┗┛┃┃┗━━━┛ ┏┛┃┏━┓┃┗━━┓┃┃┏━┛┗┓ ┏┛┃┃┃ ┃┃ ┃┏┛┗━┛┗━━┓┃┃┃┃┏┓┏┛ ┗━┛┃┃ ┃┃┏┓ ┃┃┏━━┓┏━━┛┃┃┃┃┗┛┃ ┏┛┃ ┃┃┃┗━━┓ ┗┛┗━━┛┗━━━┛┗┛┗━━┛ ┗━┛ ┗┛┗━━━┛
bot/PIDcontroller/PID_controller.cpp@2:ea151e05033a, 2017-08-22 (annotated)
- Committer:
- UCHITAKE
- Date:
- Tue Aug 22 11:56:47 2017 +0000
- Revision:
- 2:ea151e05033a
???????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
UCHITAKE | 2:ea151e05033a | 1 | #include "PID_controller.h" |
UCHITAKE | 2:ea151e05033a | 2 | |
UCHITAKE | 2:ea151e05033a | 3 | void PIDC::updateOutput() |
UCHITAKE | 2:ea151e05033a | 4 | { |
UCHITAKE | 2:ea151e05033a | 5 | rawDegree = sample(); |
UCHITAKE | 2:ea151e05033a | 6 | if(rawDegree - beforeDegree < -1800) turnOverNumber++; |
UCHITAKE | 2:ea151e05033a | 7 | if(rawDegree - beforeDegree > 1800) turnOverNumber--; |
UCHITAKE | 2:ea151e05033a | 8 | initDegree = rawDegree - offSetDegree + turnOverNumber * 3600; |
UCHITAKE | 2:ea151e05033a | 9 | beforeDegree = sample(); |
UCHITAKE | 2:ea151e05033a | 10 | |
UCHITAKE | 2:ea151e05033a | 11 | setProcessValue(initDegree / 10.0); |
UCHITAKE | 2:ea151e05033a | 12 | co = compute(); |
UCHITAKE | 2:ea151e05033a | 13 | } |
UCHITAKE | 2:ea151e05033a | 14 | |
UCHITAKE | 2:ea151e05033a | 15 | PIDC::PIDC() : PID(KC, TI, TD, INTERVAL), HMC6352(Sensor3pin5a, Sensor3pin5a) |
UCHITAKE | 2:ea151e05033a | 16 | { |
UCHITAKE | 2:ea151e05033a | 17 | setInputLimits(-M_PI, M_PI); |
UCHITAKE | 2:ea151e05033a | 18 | setOutputLimits(-1.0, 1.0); |
UCHITAKE | 2:ea151e05033a | 19 | setBias(0.0); |
UCHITAKE | 2:ea151e05033a | 20 | setMode(AUTO_MODE); |
UCHITAKE | 2:ea151e05033a | 21 | setSetPoint(0.0); |
UCHITAKE | 2:ea151e05033a | 22 | |
UCHITAKE | 2:ea151e05033a | 23 | setOpMode(HMC6352_CONTINUOUS, 1, 20); |
UCHITAKE | 2:ea151e05033a | 24 | rawDegree = sample(); |
UCHITAKE | 2:ea151e05033a | 25 | beforeDegree = sample(); |
UCHITAKE | 2:ea151e05033a | 26 | offSetDegree = sample(); |
UCHITAKE | 2:ea151e05033a | 27 | initDegree = 0; |
UCHITAKE | 2:ea151e05033a | 28 | turnOverNumber = 0; |
UCHITAKE | 2:ea151e05033a | 29 | |
UCHITAKE | 2:ea151e05033a | 30 | this -> attach(this, &PIDC::updateOutput, 0.05); |
UCHITAKE | 2:ea151e05033a | 31 | } |