temp repo

Dependencies:   mbed

Fork of priustroller_2 by N K

Committer:
nki
Date:
Sun Mar 15 01:45:22 2015 +0000
Revision:
30:2b6d426f3bfc
Parent:
29:cb03760ba9ea
Child:
33:e7b132029bae
New interrupt driven current-sensing; current sensors have a ~0.2A offset

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
nki 29:cb03760ba9ea 5 Motor::Motor(PositionSensor *sense_p, TempSensor *sense_t) {
bwang 0:54cf32d35f4d 6 _sense_p = sense_p;
bwang 0:54cf32d35f4d 7 _sense_t = sense_t;
bwang 0:54cf32d35f4d 8 }
bwang 0:54cf32d35f4d 9
bwang 11:dccbaa9274c5 10 float Motor::GetCurrentC() {
nki 30:2b6d426f3bfc 11 float x = (float) global_ic / 4095.0f;
nki 30:2b6d426f3bfc 12 return (x - _ic_zero) / _scale;
bwang 0:54cf32d35f4d 13 }
bwang 0:54cf32d35f4d 14
bwang 11:dccbaa9274c5 15 float Motor::GetCurrentB() {
nki 30:2b6d426f3bfc 16 float x = (float) global_ib / 4095.0f;
nki 30:2b6d426f3bfc 17 return (x - _ib_zero) / _scale;
bwang 0:54cf32d35f4d 18 }
bwang 0:54cf32d35f4d 19
bwang 11:dccbaa9274c5 20 float Motor::GetPosition() {
bwang 11:dccbaa9274c5 21 return _sense_p->GetPosition();
bwang 0:54cf32d35f4d 22 }
bwang 0:54cf32d35f4d 23
bwang 11:dccbaa9274c5 24 float Motor::GetTemp() {
bwang 11:dccbaa9274c5 25 return _sense_t->GetTemp();
bwang 0:54cf32d35f4d 26 }
bwang 0:54cf32d35f4d 27
bwang 0:54cf32d35f4d 28 void Motor::Config(int num_poles, float kv) {
bwang 0:54cf32d35f4d 29 _num_poles = num_poles;
bwang 0:54cf32d35f4d 30 _kv = kv;
nki 30:2b6d426f3bfc 31 }
nki 30:2b6d426f3bfc 32
nki 30:2b6d426f3bfc 33 void Motor::InitSensors(float ib_zero, float ic_zero, float scale) {
nki 30:2b6d426f3bfc 34 _ib_zero = ib_zero;
nki 30:2b6d426f3bfc 35 _ic_zero = ic_zero;
nki 30:2b6d426f3bfc 36 _scale = scale;
bwang 0:54cf32d35f4d 37 }