Prius IPM controller

Dependencies:   mbed

Fork of analoghalls5_5 by N K

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers context.h Source File

context.h

00001 #ifndef __CONTEXT_H
00002 #define __CONTEXT_H
00003 
00004 #include "includes.h"
00005 #include "transforms.h"
00006 #include "filters.h"
00007 #include "context.h"
00008 #include "core.h"
00009 #include "meta.h"
00010 #include "sensors.h"
00011 
00012 class BufferedDebugger;
00013 
00014 class Context {
00015 public:
00016     Context();
00017     void ConfigureOutputs(PinName oa, PinName ob, PinName oc, PinName en);
00018     void ConfigureCurrentSensors(PinName ib_pin, PinName ic_pin, float scale, float filter_strength);
00019     void ConfigureIdPidController(float ki, float kp, float kd, float pidmin, float pidmax);
00020     void ConfigureIqPidController(float ki, float kp, float kd, float pidmin, float pidmax);
00021     void ConfigureThrottle(PinName throttle_pin, float min, float max);
00022     void ConfigurePositionSensor(PinName pos_a_pin, PinName pos_b_pin, float cal1_a, float cal2_a, float cal1_b, float cal2_b, float offset);
00023     void ConfigureReference(float max_current);
00024     void ConfigureDebugger(int debugger_channels, int debugger_size);
00025     void AttachCallBack(void (*f)(Context *), int freq);
00026     void Start();
00027 public:
00028     Inverter *inverter;
00029     Motor *motor;
00030     User *user;
00031     Throttle *throttle;
00032     CurrentSensor *sense_ib, *sense_ic;
00033     PositionSensor *sense_p;
00034     TempSensor *sense_t_motor, *sense_t_inverter;
00035     VoltageSensor *sense_bus;
00036     PidController *pid_d, *pid_q;
00037     Modulator *modulator;
00038     Serial *serial;
00039     ReferenceSynthesizer *reference;
00040     LtiFilter *filter_d, *filter_q;
00041     BufferedDebugger *debugger;
00042 private:
00043     void InitData();
00044 private:
00045     void upd_function();
00046 private:
00047     PinName _oa, _ob, _oc, _ib_pin, _ic_pin, _throttle_pin, _pos_a_pin, _pos_b_pin, _en;
00048     float _dki, _dkp, _dkd, _qki, _qkp, _qkd, _min, _max, _cal1_a, _cal2_a, 
00049           _cal1_b, _cal2_b, _scale, _offset, _max_current, _filter_strength;
00050     int _debugger_channels, _debugger_size;
00051     float _dpidmax, _dpidmin, _qpidmax, _qpidmin;
00052     void (*_callbacks[16])(Context *);
00053     unsigned long  _call_times[16];
00054     int _call_periods[16];
00055     int _index;
00056     unsigned long _time;
00057     
00058     Ticker *_time_upd_ticker;
00059 };
00060 #endif