cancel
Showing results for 
Search instead for 
Did you mean: 

Use MotorControl on B-G431B-ESC1 without using 3 output pins for OPAMP1,2,3 (possible to use interval route to ADC?)

JA.1
Associate III

Hi ST Community

I am having a MotorControl setup with the B-G431B-ESC1 board.

The default project generated with MotorControl Workbench uses the OPAMP1, 2 and 3 and their outputs are set to pin A2, A6 and B1. These output pins are then fed to the ADC: ADC1_IN3 (A2), ADC2_IN3 (A6) and ADC1_IN12 (B1).

In my setup, I need to use the pins A2, A6 and B1 for other GPIO purposes (already used all the other pins). I am having a hard find figuring out whether it is possible to route the OPAMP outputs internally to the corresponding ADC without wasting uC pins. Does anyone know if this is possible?

Edit:

In the document: AN5310 Guideline for using analog features of STM32G4 Series versus STM32F3 Series devices, table 10 shows the overview of "Internal OPAMP to ADC connection without external pin occupancy". So it must indeed be possible. I must figure out how to set this up in the CubeMX project.

1 ACCEPTED SOLUTION

Accepted Solutions
DBE
ST Employee

​Hello,

You can free PA2 and PA6 with the attached files. OPAMP3 is already connected internally and also externally through PB1 because we need to have phase W on both ADCs. There is maybe an issue with current cubeMX version to configure this use case but this need to be confirmed.

Best regards

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

View solution in original post

6 REPLIES 6
JA.1
Associate III

@DB.7ERGANTIN​ Seems to me you might be the right one to ask. 🙂

DBE
ST Employee

​Hello,

You can free PA2 and PA6 with the attached files. OPAMP3 is already connected internally and also externally through PB1 because we need to have phase W on both ADCs. There is maybe an issue with current cubeMX version to configure this use case but this need to be confirmed.

Best regards

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

So, am I understanding this right:

  1. The code attached can free PA2 and PA6.
    1. I cannot build the code since in the file "stm32g4xx_hal_msp.c" the definition M1_OPAMP1_INT_GAIN_Pin' is undeclared (also for OPAMP2 and OPAMP3). Also the line 412 sets up M1_OPAMP1_OUT_Pin as output. This should be removed? (same applies to OPAMP2 and 3).
  2. It is currently not possible to set up this configuration in CubeMX?
  3. It is not possible to free PB1 at all?
    1. In MC Workbench: In The setting "Analog input and protection" one can select between OP1/OP2/OP3 or just OPAMP1/OPAMP2. Selecting the latter frees the usage of PB1. Is this a way of freeing all pins?
DBE
ST Employee

​Concerning the following points:

1.1: This is strange, I created a new project B-G431B-ESC1 and unzipped directly the files in the Src directory, I faced no issues during the project build and the motor spun.

2: It seems so but it needs to be confirmed

3.1:  OPAMP1/OPAMP2 is not a valid configuration in case of B-G431B-ESC1 and should be forbidden. The board is designed to use OPAMPs in differential mode then in this configuration I don't see a way to free PB1.

Best regards   

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

It might be that I've chosen a hall-sensor as the speed sensing element. It worked with me uncommenting the M1_OPAMP1_INT_GAIN_Pin and M1_OPAMP1_OUT_Pin.

Thank you for pointing me in the right direction. I guess I have to change the package type in order to get more pins available.

Laurent Ca...
Lead II

The question has been set only to the "STM32 Motor Control" topic (the question is only about the STM32 MC SDK). 

Best regards