temp repo

Dependencies:   mbed

Fork of priustroller_2 by N K

Committer:
bwang
Date:
Sun Mar 01 06:16:01 2015 +0000
Revision:
0:54cf32d35f4d
Child:
1:1f58bdcf2956
first publish

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bwang 0:54cf32d35f4d 1 #include "includes.h"
bwang 0:54cf32d35f4d 2 #include "classes.h"
bwang 0:54cf32d35f4d 3
bwang 0:54cf32d35f4d 4 Motor::Motor(CurrentSensor *sense_a, CurrentSensor *sense_b, PositionSensor *sense_p, TempSensor *sense_t) {
bwang 0:54cf32d35f4d 5 _sense_a = sense_a;
bwang 0:54cf32d35f4d 6 _sense_b = sense_b;
bwang 0:54cf32d35f4d 7 _sense_p = sense_p;
bwang 0:54cf32d35f4d 8 _sense_t = sense_t;
bwang 0:54cf32d35f4d 9 UpdateState();
bwang 0:54cf32d35f4d 10 }
bwang 0:54cf32d35f4d 11
bwang 0:54cf32d35f4d 12 float Motor::UpdateCurrentA() {
bwang 0:54cf32d35f4d 13 return I_a = _sense_a->GetCurrent();
bwang 0:54cf32d35f4d 14 }
bwang 0:54cf32d35f4d 15
bwang 0:54cf32d35f4d 16 float Motor::UpdateCurrentB() {
bwang 0:54cf32d35f4d 17 return I_b = _sense_b->GetCurrent();
bwang 0:54cf32d35f4d 18 }
bwang 0:54cf32d35f4d 19
bwang 0:54cf32d35f4d 20 float Motor::UpdatePosition() {
bwang 0:54cf32d35f4d 21 return angle = _sense_p->GetPosition();
bwang 0:54cf32d35f4d 22 }
bwang 0:54cf32d35f4d 23
bwang 0:54cf32d35f4d 24 float Motor::GetTemp() {
bwang 0:54cf32d35f4d 25 return _sense_t->GetTemp();
bwang 0:54cf32d35f4d 26 }
bwang 0:54cf32d35f4d 27
bwang 0:54cf32d35f4d 28 void Motor::UpdateState() {
bwang 0:54cf32d35f4d 29 UpdateCurrentA();
bwang 0:54cf32d35f4d 30 UpdateCurrentB();
bwang 0:54cf32d35f4d 31 UpdatePosition();
bwang 0:54cf32d35f4d 32 }
bwang 0:54cf32d35f4d 33
bwang 0:54cf32d35f4d 34 void Motor::Config(int num_poles, float kv) {
bwang 0:54cf32d35f4d 35 _num_poles = num_poles;
bwang 0:54cf32d35f4d 36 _kv = kv;
bwang 0:54cf32d35f4d 37 }