N K
/
GaNtroller
a fork of priustroller
Fork of priustroller_current by
Diff: context.h
- Revision:
- 11:dccbaa9274c5
- Child:
- 12:c35ad58f6620
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/context.h Sun Mar 08 08:37:38 2015 +0000 @@ -0,0 +1,53 @@ +#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; + Serial *serial; + ReferenceSynthesizer *reference; + LtiFilter *filter_d, *filter_q; +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; +}; +#endif \ No newline at end of file