Bayley Wang
/
priustroller_3
temp repo
Fork of priustroller_2 by
context.h
- Committer:
- bwang
- Date:
- 2015-03-09
- Revision:
- 16:c10d0aa3c0e1
- Parent:
- 12:c35ad58f6620
- Child:
- 17:fd6771a6685a
File content as of revision 16:c10d0aa3c0e1:
#ifndef __CONTEXT_H #define __CONTEXT_H #include "includes.h" #include "transforms.h" #include "filters.h" #include "context.h" #include "core.h" #include "meta.h" #include "sensors.h" class Context { public: Context(); void ConfigureOutputs(PinName oa, PinName ob, PinName oc, PinName en); void ConfigureCurrentSensors(PinName ib_pin, PinName ic_pin, float scale, float filter_strength); void ConfigurePidControllers(float ki, float kp, float kd, float pidmin, float pidmax); void ConfigureThrottle(PinName throttle_pin, float min, float max); void ConfigurePositionSensor(PinName pos_a_pin, PinName pos_b_pin, float cal1_a, float cal2_a, float cal1_b, float cal2_b, float offset); void ConfigureReference(float max_current); void AttachCallBack(void (*f)(Context *), int freq); void Start(); public: Inverter *inverter; Motor *motor; User *user; Throttle *throttle; CurrentSensor *sense_ib, *sense_ic; PositionSensor *sense_p; TempSensor *sense_t_motor, *sense_t_inverter; VoltageSensor *sense_bus; PidController *pid_d, *pid_q; Modulator *modulator; ReferenceSynthesizer *reference; LtiFilter *filter_d, *filter_q; float debug_registers[16]; private: void InitData(); private: void upd_function(); private: PinName _oa, _ob, _oc, _ib_pin, _ic_pin, _throttle_pin, _pos_a_pin, _pos_b_pin, _en; float _ki, _kp, _kd, _min, _max, _cal1_a, _cal2_a, _cal1_b, _cal2_b, _scale, _offset, _max_current, _filter_strength; float _pidmax, _pidmin; void (*_callbacks[16])(Context *); unsigned long _call_times[16]; int _call_periods[16]; int _index; unsigned long _time; Ticker *_time_upd_ticker; }; extern Serial *serial; #endif