Part Number:TMS320F28379D
Tool/software: Code Composer Studio
Hello everyone, I have a school project where i need to control the speed of a DC motor using a PID and PWM dutycycle. I need to read the speed of this motor using ADC module.
so i used a C2000 motorware example for PID, but unfortunately this example was for F28069M (I'm using F28379D). So i went to change the registers on it, but i have some questions about this example :
1- why did they configure 2 GPIOs in this program as output, don't we have one output which is PWM output and one input which is ADC ?
-----------------------------------------------------------------------------------
/* configure GPIO */
InitGpio(); // [F2806x_Gpio.c]
EALLOW;
GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0; // GPIO34 = I/O pin
GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1; // GPIO34 = output
GpioDataRegs.GPBSET.bit.GPIO34 = 1; // GPIO34 = 1
GpioCtrlRegs.GPBMUX1.bit.GPIO39 = 0; // GPIO39 = I/O pin
GpioCtrlRegs.GPBDIR.bit.GPIO39 = 1; // GPIO39 = output
GpioDataRegs.GPBCLEAR.bit.GPIO39 = 1; // GPIO39 = 0
EDIS;
-------------------------------------------------------------------------------------
2- same in ADC configuration there are using 2 SOC channels (SOC1 and SOC2) even like we just need one channel to read the feedback value. (and the same there used two ADCINT)
---------------------------------------------------------------------------------------------------------
AdcRegs.ADCSOC0CTL.bit.CHSEL = 0; // set SOC0 channel select to ADCINA0
AdcRegs.ADCSOC1CTL.bit.CHSEL = 8; // set SOC1 channel select to ADCINB0
-------------------------------------------------------------------------------------------------------------
3- In pid parameters why do we need the external saturation variable lk ?
hope someone can help understand this better.