SPRUJ26A September 2021 – April 2024
A potentiometer is often used to allow a motor to run, stop and set the reference speed. As an example, the user may connect ADCA12 to a potentiometer. To do this, enable the pre-define symbol CMD_POT_EN in project build properties as shown in Figure 3-19. The results from reading the ADC will be converted to a speed value and assigned to the variables motorVars_M1.flagEnableRunAndIdentify to start/stop the motor and to motorVars_M1.speedRef_Hz to set the reference speed. The detailed steps are as the follows.
#define MTR1_POT_ADC_BASE ADCA_BASE
#define MTR1_POT_ADCRES_BASE ADCARESULT_BASE
#define MTR1_POT_ADC_CH_NUM ADC_CH_ADCIN12
#define MTR1_POT_ADC_SOC_NUM ADC_SOC_NUMBER6
// POT_M1
ADC_setupSOC(MTR1_POT_ADC_BASE, MTR1_POT_ADC_SOC_NUM, MTR1_ADC_TIGGER_SOC,
MTR1_POT_ADC_CH_NUM, MTR1_ADC_V_SAMPLEWINDOW);
// read POT adc value
pADCData->potAdc = ADC_readResult(MTR1_POT_ADCRES_BASE, MTR1_POT_ADC_SOC_NUM);