motor spins

Dependencies:   mbed

Fork of analoghalls5 by Bayley Wang

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers motor.cpp Source File

motor.cpp

00001 #include "includes.h"
00002 #include "core.h"
00003 #include "sensors.h"
00004 
00005 Motor::Motor(CurrentSensor *sense_c, CurrentSensor *sense_b, PositionSensor *sense_p, TempSensor *sense_t) {
00006     _sense_c = sense_c;
00007     _sense_b = sense_b;
00008     _sense_p = sense_p;
00009     _sense_t = sense_t;
00010     UpdateState();
00011 }
00012 
00013 float Motor::UpdateCurrentC() {
00014     return I_c = _sense_c->GetCurrent();
00015 }
00016 
00017 float Motor::UpdateCurrentB() {
00018     return I_b = _sense_b->GetCurrent();
00019 }
00020 
00021 float Motor::UpdatePosition() {
00022     return angle = _sense_p->GetPosition();
00023 }
00024 
00025 float Motor::UpdateTemp() {
00026     return temp = _sense_t->GetTemp();
00027 }
00028 
00029 void Motor::UpdateState() {
00030     UpdateCurrentC();
00031     UpdateCurrentB();
00032     UpdatePosition();
00033 }
00034 
00035 void Motor::Config(int num_poles, float kv) {
00036     _num_poles = num_poles;
00037     _kv = kv;
00038 }