cancel
Showing results for 
Search instead for 
Did you mean: 

Read only from one channel of the ADC

luke514
Senior

I have two active ADCs with many channels reading, some in regular converison, some injected, etc.

luke514_0-1729697663038.png

The code is autogenerated from MC Workbench, but I added a channel 11 for an external potentiometer.

I don't really know in the autogenerated files where the other ADC channels are read, and in addition to reading those channels, I should also read channel 11.

I ask you if this code is sufficient (in the main.c) to read also from ADC1 and channel 11:

there is the error: ADC_HandleTypeDef has no member named rank

luke514_0-1729698295963.png

 

Maybe I should add these lines of code where the other channels are also read? ..to avoid two HAL_ADC_ConvCpltCallbacks in the project.

I kindly ask you how to solve (I think bases a simple line of code that unfortunately I do not know)

Thank you.

 

 

4 REPLIES 4
SofLit
ST Employee

Since the code was autogenerated from MC Workbench, the thread was moved to STM32 MCUs Motor control forum.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
GMA
ST Employee

Hello @luke514,

If you are using B-G431B-ESC1 board, why not taking the advantage of enabling potentiometer feature through Workbench>Stage Configuraton>Potentiomer? ADC1_IN11 input is used, and capture is done via RCM_ExecRegularConv() function call.

If you agree with the answer, please accept it by clicking on 'Accept as solution'.
Best regards.
GMA

I used it when I selected a speed control. 

In the case of torque control, I think it can not be used to vary the motor torque .. in fact during the debug nothing happens during its rotation. Am I wrong?

If I am wrong and there is the possibility to activate it also with the torque control .. my question remains the same because I have always read channels simultaneously, but now I would like to know how to read one of the many initialized ones.

That's why I asked the question in the main thread and not in the specific one for Mc workbench, because in my opinion the question is of a general nature and is independent of the fact that I used Mc workmage to generate the code. 

Hello @luke514,

You are right, potentiometer is fully speed control oriented, and we do not plan to add this feature for the moment.
Based on current provided FW potentiometer, you can extend SPDPOT_Run() function to handle MCM_TORQUE_MODE as STC_ExecRamp() function handles this control mode.

If you agree with the answer, please accept it by clicking on 'Accept as solution'.
Best regards.
GMA