cancel
Showing results for 
Search instead for 
Did you mean: 

Gauge Widget + ADC + PWM.

Abucio24
Associate II

Hello people, 

I'm a newborn baby in this microcontroller world, I'm hoping in getting some help with my current project and know if it's possible to do it first of all. I did a program to control a BLDC motor in a simple Nucleo board using an ADC channel and PWM output. Then I bought an STM32F4291 and I'm trying to implement the gauge widget animation with the same purpose of controlling a BLDC. I have the Widget running thanks to a good video in YouTube but I'm struggling in adding the PWM output to the project. Does my PWM function needs to be in ScreenView.cpp , Model.cpp etc? Can I use the same value that I'm getting from the gauge? I don't exactly what to do, I did try the main loop but didn't work. 

 

Thank You for your time! 

 

3 REPLIES 3
GaetanGodart
ST Employee

Hello @Abucio24 ,

 

To control a BLDC motor you have a few solution.

  • The best is probably to use a hardware element made specifically for that purpose, they are called Electronic Speed Controller (ESC)
  • You can use ST's solution called Motor Control 
  • You can try to control yourself with code and feedback from the speed or the sensors available, this is not the easiest way)

You say you have an STM32F4291, I assume that you have bought a discovery board STM32F429i-DK and used the available TBS in TouchGFX Designer to create your project.
This TBS uses FreeRTOS to share the MCU usage to various tasks such as the TouchGFX task or the communication tasks.
This is why the code you put in the main loop is never executed : with an RTOS, the main loop is never reached.
Instead you have 2 solutions :

  1. Put your code in an existing task. In that case, you could put your code in the TouchGFX tasks or files and specifically in the Model.cpp file where you can implement the HandleTickEvent() function that is called 60 times per second
  2. Create a specific task to run your code independently

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)
Abucio24
Associate II

Hi Gaetan! 

Thanks for the reply, indeed I read the documentation, and I already did my code using FreeRTOS I did obtain the PWM signal required for running the motor, but it has a lower peak voltage than my Nucleo Board. I'm wondering if it is due to the task scheduler, or the board is not capable of giving the same voltage as the Nucleo (L476RG) ? 

Thanks for the help! 

 

I don't see why a pin from an STM32F4 would have lower voltage than a pin from a STM32L4.

Can you check the pin in STM32CubeMX and in the documentation, make sure this pin is not limited in voltage or power.

Also, can you try to use a different pin?

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)