Prius IPM controller

Dependencies:   mbed

Fork of analoghalls5_5 by N K

Committer:
bwang
Date:
Mon Mar 16 15:40:07 2015 +0000
Revision:
35:83cf9564bd0c
Parent:
30:2b6d426f3bfc
Set for 3A Iq, 0A Id, Ki = 1e-3, Kp = Kd = 0, loop still oscillates but is passable

Who changed what in which revision?

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