temp repo

Dependencies:   mbed

Fork of priustroller_2 by N K

Committer:
bwang
Date:
Sun Mar 01 10:51:28 2015 +0000
Revision:
1:1f58bdcf2956
Parent:
0:54cf32d35f4d
Child:
6:99ee0ce47fb2
moar

Who changed what in which revision?

UserRevisionLine numberNew 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
bwang 0:54cf32d35f4d 5 Motor::Motor(CurrentSensor *sense_a, CurrentSensor *sense_b, PositionSensor *sense_p, TempSensor *sense_t) {
bwang 0:54cf32d35f4d 6 _sense_a = sense_a;
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
bwang 0:54cf32d35f4d 13 float Motor::UpdateCurrentA() {
bwang 0:54cf32d35f4d 14 return I_a = _sense_a->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() {
bwang 0:54cf32d35f4d 30 UpdateCurrentA();
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 }