View Single Post
Old 03-14-2016, 11:50 AM   #2629 (permalink)
shaggythegangsta
EcoModding Lurker
 
Join Date: Mar 2016
Location: italy
Posts: 40
Thanks: 5
Thanked 2 Times in 2 Posts
Hello guys i "All thanks to e*clipse" started trying the code on dspic30f6010a
serial comunication runs fine, configuration commands works just fine.. streaming part i'don't know how it works.. i someone wants to explain....

my configuration is:

current sensors: LEM LTS25-NP IN 8 AMPS RMS CONFIGURATION. with 13.33 A/V gain. i used 13.
Motor is ac induction motor with 230v 8.5A 2 pole motor 2850RPM

this is my configuration in software:
motor-type=1
kp=01000 ki=00010
current-sensor-amps-per-volt=0013
max-regen-position=0390
min-regen-position=0490
min-throttle-position=0510
max-throttle-position=0610
fault-throttle-position=0005
max-battery-amps=0008 amps
max-battery-amps-regen=0008 amps
max-motor-amps=008 amps
max-motor-amps-regen=008 amps
precharge-time=0050 tenths of a sec
rotor-time-constant=018 ms
pole-pairs=001
max-rpm=03000 rev/min
throttle-type=1
encoder-ticks=1024 ticks/rev
pi-ratio=062
raw-throttle=0513

but when the motor starts it oscillates and then it blocks.... i dont know why.. i'm sure that hardaware is ok because it works in openloop with 1162 app note's code..

i'm attaching also the modifactions done in the code.

Lines commented with SINGH are changed.

ACController.h
Code:
//#define PAULS_MOTOR
//#define ANDREWS_MOTOR
#define AC_INDUCTION_MOTOR_CONFIG
//#define DEBUG_MODE
#define OREGON_MOTOR_CONTROLLER

#define I_TRIS_THROTTLE 		_TRISB7         //B0  //previous settings singh
#define I_TRIS_CURRENT1			_TRISB0         //B1
#define I_TRIS_CURRENT2			_TRISB1         //B2
#define I_TRIS_INDEX			_TRISB3         //B3
#define I_TRIS_QEA              _TRISB4         //B4
#define I_TRIS_QEB			    _TRISB5         //B5
#define O_TRIS_CLEAR_FLIP_FLOP  _TRISB6         //B6
#define I_TRIS_TEMPERATURE		_TRISB2         //B7
#define I_TRIS_REGEN_THROTTLE   _TRISB8         //B8
#define I_TRIS_DESAT_FAULT		_TRISB9         //C13
#define I_TRIS_OVERCURRENT_FAULT 	_TRISB10        //C14
#define I_TRIS_UNDERVOLTAGE_FAULT	_TRISB11        //E8
#define O_TRIS_LED  			    _TRISA9         // high means turn ON the LED.      //D1
#define O_TRIS_PRECHARGE_RELAY      _TRISA10        // HIGH means turn ON the precharge relay.     //D3
#define I_TRIS_GLOBAL_FAULT		_TRISB12        //D2
#define O_TRIS_CONTACTOR		_TRISA14        //D0
#define O_TRIS_CLEAR_DESAT		_TRISB15        //F6
#define O_TRIS_BUFFER_ENABLE    _TRISD11        //SINGH For enbling the buffer ic on pcb
#define O_TRIS_PWM_3H			_TRISE5
#define O_TRIS_PWM_3L			_TRISE4
#define O_TRIS_PWM_2H			_TRISE3
#define O_TRIS_PWM_2L			_TRISE2
#define O_TRIS_PWM_1H			_TRISE1
#define O_TRIS_PWM_1L			_TRISE0

#define I_LAT_THROTTLE 			_LATB7
#define I_LAT_CURRENT1			_LATB0
#define I_LAT_CURRENT2			_LATB1
#define I_LAT_INDEX             _LATB3
#define I_LAT_QEA               _LATB4
#define I_LAT_QEB               _LATB5
#define O_LAT_CLEAR_FLIP_FLOP   _LATB6
#define I_LAT_TEMPERATURE		_LATB2
#define I_LAT_REGEN_THROTTLE    _LATB8
#define I_LAT_DESAT_FAULT		_LATB9
#define I_LAT_OVERCURRENT_FAULT     _LATB10
#define I_LAT_UNDERVOLTAGE_FAULT	_LATB11
#define O_LAT_LED                   _LATA9      // high means turn ON the LED.
#define O_LAT_PRECHARGE_RELAY       _LATA10      // HIGH means turn ON the precharge relay.
#define I_LAT_GLOBAL_FAULT		_LATB12
#define O_LAT_CONTACTOR			_LATA14
#define O_LAT_CLEAR_DESAT		_LATB15
#define O_LAT_BUFFER_ENABLE     _LATB15
#define O_LAT_PWM_3H			_LATE5
#define O_LAT_PWM_3L			_LATE4
#define O_LAT_PWM_2H			_LATE3
#define O_LAT_PWM_2L			_LATE2
#define O_LAT_PWM_1H			_LATE1
#define O_LAT_PWM_1L			_LATE0

#define I_PORT_THROTTLE 		_RB7
#define I_PORT_CURRENT1			_RB0
#define I_PORT_CURRENT2			_RB1
#define I_PORT_INDEX			_RB3
#define I_PORT_QEA                      _RB4
#define I_PORT_QEB                      _RB5
#define O_PORT_CLEAR_FLIP_FLOP          _RB6
#define I_PORT_TEMPERATURE              _RB2
#define I_PORT_REGEN_THROTTLE           _RB8
#define I_PORT_DESAT_FAULT              _RB9
#define I_PORT_OVERCURRENT_FAULT        _RB10
#define I_PORT_UNDERVOLTAGE_FAULT       _RB11
#define O_PORT_LED                      _RA9        // high means turn ON the LED.
#define O_PORT_PRECHARGE_RELAY          _RA10        // HIGH means turn ON the precharge relay.
#define I_PORT_GLOBAL_FAULT		_RB12
#define O_PORT_CONTACTOR		_RA14
#define O_PORT_CLEAR_DESAT		_RB15
#define O_PORT_BUFFER_ENABLE    _RD11
#define O_PORT_PWM_3H			_RE5
#define O_PORT_PWM_3L			_RE4
#define O_PORT_PWM_2H			_RE3
#define O_PORT_PWM_2L			_RE2
#define O_PORT_PWM_1H			_RE1
#define O_PORT_PWM_1L			_RE0
ACController.c

Code:
// CH0 corresponds to ADCBUF0. etc...
	// CH0=AN7, CH1=AN0, CH2=AN1, CH3=AN2. 
	// AN0 = CH1 = ADCurrent1   dspic30f6010a configurations by singh
	// AN1 = CH2 = ADCurrent2   dspic30f6010a configurations by singh
	// AN2 = CH3 = temperature  dspic30f6010a configurations by singh
	// AN7 = CH0 = ADThrottle   dspic30f6010a configurations by singh

	ADCurrent1 = ADCBUF1;
	ADCurrent2 = ADCBUF2;
	Ia = ADCurrent1;                // CH1 = ADCurrent1
	Ib = ADCurrent2;		// CH2 = ADCurrent2.

	Ia -= vRef1;  // vRef1 is just a constant found at the beginning of the program, approximately = 512, that changes the current feedback from being centered at 512 to centered at 0.  It's specific to current sensor #1.
	Ib -= vRef2;  // vRef2 is just a constant found at the beginning of the program, approximately = 512, that changes the current feedback from being centered at 512 to centered at 0.  It's specific to current sensor #2.
	// So, you must change the interval to [-4096, 4096], so as to match the throttle range below to make feedback comparable with commanded current. So...

	Ia <<= 4;	// Ia is now in [-4096, 4096] if it was in  [-256, 256].  In other words, if it was in [-2*LEM Rating, 2*LEM Rating]. 
	Ib <<= 4;   // Ib is now in [-4096, 4096] if it was in  [-256, 256].  In other words, if it was in [-2*LEM Rating, 2*LEM Rating]. 
	Ic = -Ia - Ib;
	Ib_times2 = (Ib << 1);

	rawThrottle = ADCBUF0;          //Singh
	throttleSum += rawThrottle;
	temperatureSum += ADCBUF3;      //Singh
  Reply With Quote