S32K116 Motor Control add throttle (potentiometer) for speed control

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K116 Motor Control add throttle (potentiometer) for speed control

1,013 Views
capacitor70
Contributor I

I want to add ADC channel ADC0_SE13 to measure potentiometer voltage. To control speed of motor. I tried lot of things but unable to set it in PDB block properly. ADC properly configured in ProcessorExpert and then I have configured PDB0. I tried lot of combination but every time I am getting PDB0 Error in MCAT tool.

What I should do in below files? I am using k116 FOC 2sh example code.

1. What is proper settings required to achieve this.

2. ADC configuration in processor expert?

3. PDB configuration in processor expert?

4. code modification in periferals_config.c ?

5. code modification in main.c ?

6. code modifications in meas_s32k.c?

Objective:

1. Connect potentiometer as throttle control for speed.

2. Trigger ADC through PDB back to back.

3. Read ADC value in interrupt routine. Where current and Voltages are measured using meas.c.

4. Set speed according to throttle demand. In ADC interrupt routine. Which variable have speed?

This is configuration code where I am modifying few lines. and Processor expert.

void McuPdbConfig(void)
{
/* PDB0 module initialization */
PDB_DRV_Init(INST_PDB0, &pdb0_InitConfig0);

/* PDB0 CH0 pre-trigger initialization */
PDB_DRV_ConfigAdcPreTrigger(INST_PDB0, 0, &pdb0_AdcTrigInitConfig0);
PDB_DRV_ConfigAdcPreTrigger(INST_PDB0, 0, &pdb0_AdcTrigInitConfig1);
PDB_DRV_ConfigAdcPreTrigger(INST_PDB0, 0, &pdb0_AdcTrigInitConfig2);
>>>>>//PDB_DRV_ConfigAdcPreTrigger(INST_PDB0, 0, &pdb0_AdcTrigInitConfig3);  

/* Set PDB0 modulus value */
PDB_DRV_SetTimerModulusValue(INST_PDB0, 7800);

PDB_DRV_SetAdcPreTriggerDelayValue(INST_PDB0, 0, 0, 0);
PDB_DRV_SetAdcPreTriggerDelayValue(INST_PDB0, 0, 1, 1200);
>>>>//PDB_DRV_SetAdcPreTriggerDelayValue(INST_PDB0, 0, 2, 2400);

 

Screenshot from 2023-09-27 11-57-05.png

0 Kudos
1 Reply

1,001 Views
capacitor70
Contributor I
Solved issue, I forget to read the ADC value to clear the COCO flag.