temp repo

Dependencies:   mbed

Fork of priustroller_2 by N K

core/motor.cpp

Committer:
nki
Date:
2015-03-15
Revision:
30:2b6d426f3bfc
Parent:
29:cb03760ba9ea
Child:
33:e7b132029bae

File content as of revision 30:2b6d426f3bfc:

#include "includes.h"
#include "core.h"
#include "sensors.h"

Motor::Motor(PositionSensor *sense_p, TempSensor *sense_t) {
    _sense_p = sense_p;
    _sense_t = sense_t;
}

float Motor::GetCurrentC() {
    float x = (float) global_ic / 4095.0f;
    return (x - _ic_zero) / _scale;
}

float Motor::GetCurrentB() {
    float x = (float) global_ib / 4095.0f;
    return (x - _ib_zero) / _scale;
}

float Motor::GetPosition() {
    return _sense_p->GetPosition();
}

float Motor::GetTemp() {
    return _sense_t->GetTemp();
}

void Motor::Config(int num_poles, float kv) {
    _num_poles = num_poles;
    _kv = kv;
}

void Motor::InitSensors(float ib_zero, float ic_zero, float scale) {
    _ib_zero = ib_zero;
    _ic_zero = ic_zero;
    _scale = scale;
}