How to generate a PWM Signal with STM32

Ғылым және технология

PWM stands for Pulse Width Modulation. It is a technique used in electronics and digital systems to control the amount of power delivered to a device or component. PWM signals are commonly used in applications such as motor speed control, dimming LEDs, and generating analog signals.
In this tutorial, I make use of the STM32 MCU to generate a pwm signal in a few easy steps.
Explore how to generate PWM signals with STM32 microcontrollers in this detailed tutorial. Tailored for embedded systems enthusiasts and developers, this video provides a step-by-step guide to configuring and programming STM32 timers for PWM output.
Learn essential concepts such as timer configuration, PWM signal parameters setting, and practical implementation examples. Gain insights into controlling motor speeds, LED brightness, and other applications using STM32 PWM capabilities. Whether you're new to STM32 development or looking to expand your skills, mastering PWM signal generation is essential for precision control in embedded applications.
🔧 What You’ll Learn:
Setting up STM32 Timers for PWM Generation
Configuring PWM Signal Characteristics
Programming STM32 GPIO for PWM Output
Applications of PWM in Embedded Systems
📌 Key Topics Covered:
Overview of STM32 Timer and PWM Concepts
Step-by-Step Configuration Guide
Real-World Examples and Use Cases
Tips for Optimizing PWM Signal Performance
📢 Join Our Community:
Like, share, and subscribe for more tutorials on STM32 microcontroller development, PWM signal generation, and embedded systems. Stay updated with our latest videos by clicking the notification bell!
Get the Nucleo board: amzn.to/3OzwaRb
Source Code:
drive.google.com/file/d/1uKp5...
Installing stm32cubebeIDE - • 0. Installing stm32Cub...
Join this channel to get access to perks:
/ @cmteq
Visit #cmteq website/blog for latest trending technology on power system, electronics and embedded system. cmteqpower.com/
🔗 Related Videos:
Introduction to STM32 Microcontrollers
Advanced Techniques in PWM Signal Control
Motor Speed Control with STM32 PWM
📞 Contact Us:
Questions or feedback? Drop a comment below or connect with us on social media. We're here to support your journey into STM32 development and embedded systems!
#STM32PWM #PWMGeneration #STM32Microcontroller #EmbeddedSystems #MotorControl
#stm32 #Nucleo #pwm #embeddedprojects
If you LIKE this Please HIT the LIKE 👍👍 Button, Subscribe and hit the Bell 🔔🔔
👇 SUBSCRIBE TO CMTEQ CHANNEL NOW 👇
kzread.info?sub_c...
More ways to Support CMTEQ Channel.
Buy me a cup of coffee: www.buymeacoffee.com/cmteq
Donate on Paypal: www.paypal.com/donate/?hosted...
Become a Patreon: / cmteq

Пікірлер: 39

  • @CMTEQ
    @CMTEQ Жыл бұрын

    If you ❤ my content and find it helpful, please Subscribe and hit the Bell 🔔 👇 SUBSCRIBE TO CMTEQ CHANNEL NOW 👇 kzread.info

  • @botak333

    @botak333

    3 ай бұрын

    Hi mate, can wi fix the pwm duty cycle is 50% or 70%?? Or if we leaf the pulse to 0 is what happen???

  • @CMTEQ

    @CMTEQ

    3 ай бұрын

    Yes, you can fix the duty cycle at any value you want between 0 and 100%. If you leave the duty cycle at 0, the signal will be off, zero. If you leave it at 100% , the signal will be 5V continuous

  • @botak333

    @botak333

    3 ай бұрын

    @@CMTEQ no, i see on the mc workbench is pulse=0 sir. What is that mean?? Because i used for motor control, and i want to fix the pwm on 50 or 70% sir.

  • @CMTEQ

    @CMTEQ

    3 ай бұрын

    @@botak333 Hi, did you come right with your test for 50% PWM Duty cycle?

  • @botak333

    @botak333

    3 ай бұрын

    @@CMTEQ i dont know, because the code from x cube mcsdk, that is deferent with code from cube mx sir. In cube mx i can set the ccr, but on mc sdk i see on the code is (pwm_duty) / 2; like that sir. Not the fix number like 1000 or semilar

  • @tomas_soeterik
    @tomas_soeterik6 ай бұрын

    Very good video, underrated in every way, ai needed some explanation on pwm

  • @CMTEQ

    @CMTEQ

    6 ай бұрын

    Thank you for your feedback. Please support by sharing, much appreciated 🙏.

  • @richardprogramming9402
    @richardprogramming94027 ай бұрын

    This video was very useful!! Thanks!!

  • @CMTEQ

    @CMTEQ

    7 ай бұрын

    You are most welcome !

  • @user-lg4jh3ov3q
    @user-lg4jh3ov3q4 ай бұрын

    Your content is great, but just ONE reminder about like/subscribe somewhere in your video is all you need. Having random animations appear over your video with tones takes away from your content! Anyways, your work here has saved me many hours of research, and I am a happy subscriber!

  • @CMTEQ

    @CMTEQ

    4 ай бұрын

    Hi William, Thank you for the feedback, well Noted.

  • @lenzneethling3164
    @lenzneethling31643 ай бұрын

    Very helpful !!

  • @CMTEQ

    @CMTEQ

    3 ай бұрын

    Great 👍, I'm glad it was helpful

  • @CMTEQ
    @CMTEQ8 ай бұрын

    Analyze PWM signal using SIGLENT SDS 1104X-E Digital Storage Oscilloscope kzread.info/dash/bejne/X4R1ks6rY6rfcbQ.html

  • @johnfrancis923
    @johnfrancis9233 ай бұрын

    In my case, I am using an external oscillator to generate the system clock. However, I'm not finding an option to select the external clock as the source. What should I do? i am using cubeMX tool to configure?

  • @CMTEQ

    @CMTEQ

    3 ай бұрын

    Hi, I will have a look later. Please check my video on clock configuration. kzread.info/dash/bejne/dYmbsrqtZK2rj8Y.html

  • @ashleed6800
    @ashleed68005 ай бұрын

    Are the terminals from GND (black wire) and PWM/D11 (red wire) both directly connected to the oscilloscope? What is your wiring set up?

  • @CMTEQ

    @CMTEQ

    5 ай бұрын

    Yes that is correct. I'm doing a simple GND reference measurement. Scope croc clip connected to GND(Black Wire) and Scope Channel 1 (Yellow) probe connected to Red wire D11.

  • @ashleed6800

    @ashleed6800

    5 ай бұрын

    @@CMTEQThank you so much! I am currently using PWM for this STM (and this code) and with Escon 50/5 motor driver. What wiring set up would you recommend? I connected PWM/D11 to the Input PWM pin on Escon. What about the ground & power supply connections?

  • @CMTEQ

    @CMTEQ

    5 ай бұрын

    Hi Ashlee, if your Escon 50/5 motor driver and stm32 board are sharing the same power supply then you can connect your Escon 50/5 motor driver GND to the same GND black wire on your stm32 or on your power supply, while keeping the PWM Pin connected on the Escon PWM input. You should be able to control your motor. If you need more assistance, like schematic and hardware connection, you can consider joining my low voltage membership, I will provide you technical assistance.

  • @ashleed6800

    @ashleed6800

    5 ай бұрын

    @@CMTEQ I will look into your membership! Thanks again. :)

  • @botak333

    @botak333

    3 ай бұрын

    hi mate how about like this??? Code: htim1.Init.Period = ((PWM_PERIOD_CYCLES) / 2); Code: sConfigOC.Pulse = (uint32_t)(((PWM_PERIOD_CYCLES) / 2) * 0.6); It will working?? So no need set pwmc setphasavoltage, because global pwm duty (pulse) already set max 60%?? Or this will set all tim for 60% sir?? Any idea?? Thank u@@CMTEQ

  • @mohamedansari_stm
    @mohamedansari_stm4 ай бұрын

    Fantastic video mate !! . What should be the prescaler and period value if i want to have a frequency of 400khz?

  • @CMTEQ

    @CMTEQ

    4 ай бұрын

    Hi thank you for your feedback. If you want to generate a 400kHz frequency you just need to play with the Prescaler and period value, I mentioned it in the video. So for 400kHz you can setup your values as follow prescaler = 20 and period = 7. depending on measuring equipment you might not get the exact 400kHz, if thats the case you can decrease the prescaler = 19. Please note that this is based on the 64MHz clock frequency if your frequency is higher or less than you just need to play with the period and prescaler value until you get your desired frequency,.

  • @mohamedansari_stm

    @mohamedansari_stm

    4 ай бұрын

    Mate.. You are the best, This is the most underrated channel ever@@CMTEQ . I have achieved 400khz freq. THanks to you. Now i am trying to create a function that gets uint32_t input data from user and converts into pwm signals with logical 1 having 70% high and 30% low and logical 0 -vice versa. Can you help me?

  • @CMTEQ

    @CMTEQ

    4 ай бұрын

    That sound very easy to implement. I'm not sure which method you gonna use to get user input, buttons/keyboard etc... But you can first create a function that increment your uint32_t var locally and pass it into your Timer Init function to change the duty cycle value. Once you have that working you should see your pwm duty cycle change automatically as the code runs. Once you are satisfied you can then get the value externally by a user, sound like a nice project, an LCD would be a great addidtion to see whats going on. Time is always an issue, the best way to get assitance fast is by become the channel member.

  • @shamilsha7618
    @shamilsha76183 ай бұрын

    Can we shift the pwm sideways by 50% of the counter period?

  • @CMTEQ

    @CMTEQ

    3 ай бұрын

    Hi, by sideway I believe you mean shifting left or right, leaving the Frequency and period fixed, you can probably achieve that by playing with the Duty Cycle, you can either halve or double the high time. Try playing with those values and see what you get.

  • @STrAnGeR785
    @STrAnGeR7856 ай бұрын

    can you please share the code

  • @CMTEQ

    @CMTEQ

    6 ай бұрын

    Hi, I have attached the main.c file under the video description. Try to follow the tutorial you should be able to produce the same PWM signal.

  • @kylekingsberry5680
    @kylekingsberry56809 ай бұрын

    The pulse width wasn't being modulated here lol you just showed how to generate a square wave.

  • @CMTEQ

    @CMTEQ

    9 ай бұрын

    Hi, Thank you for your humorous comment. A square wave is a PWM signal with a constant duty cycle and amplitude. More control can be introduced, like changing the duty cycle periodically in the code to achieve the desired modulation.

Келесі