cancel
Showing results for 
Search instead for 
Did you mean: 

How to write coding for inbuilt potentiometer on EVSPIN32G4

Mathan Raja
Associate II

Hi,

How to use an inbuilt potentiometer? what are the steps (APIs) need to use?

I have used the below-linked code. But it didn't work.

code i used

 

Thanks 

Mathan

1 ACCEPTED SOLUTION

Accepted Solutions

Hello Mathan Raja,

Sorry for the misunderstanding, let me rephrase : by enabling the Potentiometer in the MC WorkBench, the generated code should allow you to control your motor with the inbuilt potentiometer without changing anything in the code, the feature is enabled by default and should work nicely. Have you tried this ?
If you can't control your motor nevertheless, could you tell me what is happening : is the motor turning or not ? Does the MotorPilot return any error ?

If you agree with my answer, please consider accepting it by clicking on 'Accept as solution'.

Hope this will help,
Gaël A.

View solution in original post

5 REPLIES 5
Gael A
ST Employee

Hello Mathan Raja,

Using the MCSDK v6.2.1, you can generate code for the EVSPIN32G4 that will support Potentiometer feature. You will find it in the Stage Configuration tab.

If you agree with my answer, please consider accepting it by clicking on 'Accept as solution'.

Hope this will help,
Gaël A.
Mathan Raja
Associate II

Hi, 

I have already enabled the potentiometer and generated code by using the MC workbench.

But how to control the speed by using a potentiometer? Do you have any example code?

 

Thanks

Mathan

Hello Mathan Raja,

I don't understand, if you have followed the steps, the generated code should already allow you to control speed using the inbuilt potentiometer.
If it doesn't, please tell me your way of proceeding, as well as the errors you eventually encounter.

If you agree with my answer, please consider accepting it by clicking on 'Accept as solution'.

Hope this will help,
Gaël A.
Mathan Raja
Associate II

Hi,

I have used the below code for reading the ADC values from the potentiometer. By using this ADC value, how to control the motor speed.  I tried with this API ( SPDPOT_Run(&SpeedPotentiometer_M1, potentiometer_value);) but it didn't control.

 

 
 

 

RegConv_t PotRegConv_M1 =

{

.regADC = ADC1,

.channel = MC_ADC_CHANNEL_9,

.samplingTime = POTENTIOMETER_ADC_SAMPLING_TIME_M1,

};

while(1){

RCM_RegisterRegConv (&PotRegConv_M1);

if (RCM_GetUserConvState() == RCM_USERCONV_IDLE)

{

/* if Idle, then program a new conversion request */

RCM_RequestUserConv(&PotRegConv_M1 );

}

else if (RCM_GetUserConvState() == RCM_USERCONV_EOC)

{

/* if Done, then read the captured value */

potentiometer_value = RCM_GetUserConv();

// SPDPOT_Run(&SpeedPotentiometer_M1, potentiometer_value);

}}

 

In the MC workbench, I enabled the potentiometer (ADC1_IN9) and generated the code. Then I added above code for reading the ADC values

 

Thanks

Mathan

Hello Mathan Raja,

Sorry for the misunderstanding, let me rephrase : by enabling the Potentiometer in the MC WorkBench, the generated code should allow you to control your motor with the inbuilt potentiometer without changing anything in the code, the feature is enabled by default and should work nicely. Have you tried this ?
If you can't control your motor nevertheless, could you tell me what is happening : is the motor turning or not ? Does the MotorPilot return any error ?

If you agree with my answer, please consider accepting it by clicking on 'Accept as solution'.

Hope this will help,
Gaël A.