Bayley Wang
/
priustroller_3
temp repo
Fork of priustroller_2 by
motor.cpp@6:99ee0ce47fb2, 2015-03-04 (annotated)
- Committer:
- nki
- Date:
- Wed Mar 04 15:33:32 2015 +0000
- Revision:
- 6:99ee0ce47fb2
- Parent:
- 1:1f58bdcf2956
- Child:
- 7:76d6ceb23e0d
3/4;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bwang | 0:54cf32d35f4d | 1 | #include "includes.h" |
bwang | 1:1f58bdcf2956 | 2 | #include "core.h" |
bwang | 1:1f58bdcf2956 | 3 | #include "sensors.h" |
bwang | 0:54cf32d35f4d | 4 | |
nki | 6:99ee0ce47fb2 | 5 | Motor::Motor(CurrentSensor *sense_c, CurrentSensor *sense_b, PositionSensor *sense_p, TempSensor *sense_t) { |
nki | 6:99ee0ce47fb2 | 6 | _sense_c = sense_c; |
bwang | 0:54cf32d35f4d | 7 | _sense_b = sense_b; |
bwang | 0:54cf32d35f4d | 8 | _sense_p = sense_p; |
bwang | 0:54cf32d35f4d | 9 | _sense_t = sense_t; |
bwang | 0:54cf32d35f4d | 10 | UpdateState(); |
bwang | 0:54cf32d35f4d | 11 | } |
bwang | 0:54cf32d35f4d | 12 | |
nki | 6:99ee0ce47fb2 | 13 | float Motor::UpdateCurrentC() { |
nki | 6:99ee0ce47fb2 | 14 | return I_c = _sense_c->GetCurrent(); |
bwang | 0:54cf32d35f4d | 15 | } |
bwang | 0:54cf32d35f4d | 16 | |
bwang | 0:54cf32d35f4d | 17 | float Motor::UpdateCurrentB() { |
bwang | 0:54cf32d35f4d | 18 | return I_b = _sense_b->GetCurrent(); |
bwang | 0:54cf32d35f4d | 19 | } |
bwang | 0:54cf32d35f4d | 20 | |
bwang | 0:54cf32d35f4d | 21 | float Motor::UpdatePosition() { |
bwang | 0:54cf32d35f4d | 22 | return angle = _sense_p->GetPosition(); |
bwang | 0:54cf32d35f4d | 23 | } |
bwang | 0:54cf32d35f4d | 24 | |
bwang | 1:1f58bdcf2956 | 25 | float Motor::UpdateTemp() { |
bwang | 1:1f58bdcf2956 | 26 | return temp = _sense_t->GetTemp(); |
bwang | 0:54cf32d35f4d | 27 | } |
bwang | 0:54cf32d35f4d | 28 | |
bwang | 0:54cf32d35f4d | 29 | void Motor::UpdateState() { |
nki | 6:99ee0ce47fb2 | 30 | UpdateCurrentC(); |
bwang | 0:54cf32d35f4d | 31 | UpdateCurrentB(); |
bwang | 0:54cf32d35f4d | 32 | UpdatePosition(); |
bwang | 0:54cf32d35f4d | 33 | } |
bwang | 0:54cf32d35f4d | 34 | |
bwang | 0:54cf32d35f4d | 35 | void Motor::Config(int num_poles, float kv) { |
bwang | 0:54cf32d35f4d | 36 | _num_poles = num_poles; |
bwang | 0:54cf32d35f4d | 37 | _kv = kv; |
bwang | 0:54cf32d35f4d | 38 | } |