temp repo

Dependencies:   mbed

Fork of priustroller_2 by N K

Committer:
bwang
Date:
Mon Mar 09 03:05:23 2015 +0000
Revision:
17:fd6771a6685a
Parent:
16:c10d0aa3c0e1
Child:
24:f1ff9c7256b5
tweaks to debugging code - debug registers are now global; define aliases to them in includes.h

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bwang 11:dccbaa9274c5 1 #ifndef __CONTEXT_H
bwang 11:dccbaa9274c5 2 #define __CONTEXT_H
bwang 11:dccbaa9274c5 3
bwang 11:dccbaa9274c5 4 #include "includes.h"
bwang 11:dccbaa9274c5 5 #include "transforms.h"
bwang 11:dccbaa9274c5 6 #include "filters.h"
bwang 11:dccbaa9274c5 7 #include "context.h"
bwang 11:dccbaa9274c5 8 #include "core.h"
bwang 11:dccbaa9274c5 9 #include "meta.h"
bwang 11:dccbaa9274c5 10 #include "sensors.h"
bwang 11:dccbaa9274c5 11
bwang 11:dccbaa9274c5 12 class Context {
bwang 11:dccbaa9274c5 13 public:
bwang 11:dccbaa9274c5 14 Context();
bwang 11:dccbaa9274c5 15 void ConfigureOutputs(PinName oa, PinName ob, PinName oc, PinName en);
bwang 11:dccbaa9274c5 16 void ConfigureCurrentSensors(PinName ib_pin, PinName ic_pin, float scale, float filter_strength);
bwang 11:dccbaa9274c5 17 void ConfigurePidControllers(float ki, float kp, float kd, float pidmin, float pidmax);
bwang 11:dccbaa9274c5 18 void ConfigureThrottle(PinName throttle_pin, float min, float max);
bwang 11:dccbaa9274c5 19 void ConfigurePositionSensor(PinName pos_a_pin, PinName pos_b_pin, float cal1_a, float cal2_a, float cal1_b, float cal2_b, float offset);
bwang 11:dccbaa9274c5 20 void ConfigureReference(float max_current);
bwang 11:dccbaa9274c5 21 void AttachCallBack(void (*f)(Context *), int freq);
bwang 11:dccbaa9274c5 22 void Start();
bwang 11:dccbaa9274c5 23 public:
bwang 11:dccbaa9274c5 24 Inverter *inverter;
bwang 11:dccbaa9274c5 25 Motor *motor;
bwang 11:dccbaa9274c5 26 User *user;
bwang 11:dccbaa9274c5 27 Throttle *throttle;
bwang 11:dccbaa9274c5 28 CurrentSensor *sense_ib, *sense_ic;
bwang 11:dccbaa9274c5 29 PositionSensor *sense_p;
bwang 11:dccbaa9274c5 30 TempSensor *sense_t_motor, *sense_t_inverter;
bwang 11:dccbaa9274c5 31 VoltageSensor *sense_bus;
bwang 11:dccbaa9274c5 32 PidController *pid_d, *pid_q;
bwang 11:dccbaa9274c5 33 Modulator *modulator;
bwang 17:fd6771a6685a 34 Serial *serial;
bwang 11:dccbaa9274c5 35 ReferenceSynthesizer *reference;
bwang 11:dccbaa9274c5 36 LtiFilter *filter_d, *filter_q;
bwang 11:dccbaa9274c5 37 private:
bwang 11:dccbaa9274c5 38 void InitData();
bwang 11:dccbaa9274c5 39 private:
bwang 11:dccbaa9274c5 40 void upd_function();
bwang 11:dccbaa9274c5 41 private:
bwang 11:dccbaa9274c5 42 PinName _oa, _ob, _oc, _ib_pin, _ic_pin, _throttle_pin, _pos_a_pin, _pos_b_pin, _en;
bwang 11:dccbaa9274c5 43 float _ki, _kp, _kd, _min, _max, _cal1_a, _cal2_a, _cal1_b, _cal2_b, _scale, _offset, _max_current, _filter_strength;
bwang 11:dccbaa9274c5 44 float _pidmax, _pidmin;
bwang 11:dccbaa9274c5 45 void (*_callbacks[16])(Context *);
bwang 11:dccbaa9274c5 46 unsigned long _call_times[16];
bwang 11:dccbaa9274c5 47 int _call_periods[16];
bwang 11:dccbaa9274c5 48 int _index;
bwang 11:dccbaa9274c5 49 unsigned long _time;
bwang 11:dccbaa9274c5 50
bwang 11:dccbaa9274c5 51 Ticker *_time_upd_ticker;
bwang 11:dccbaa9274c5 52 };
bwang 11:dccbaa9274c5 53 #endif