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