How to generate a PWM Signal with STM32

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ก.พ. 2025

ความคิดเห็น •

  • @CMTEQ
    @CMTEQ  ปีที่แล้ว +3

    If you ❤ my content and find it helpful, please Subscribe and hit the Bell 🔔
    👇 SUBSCRIBE TO CMTEQ CHANNEL NOW 👇
    th-cam.com/users/CMTEQ

    • @botak333
      @botak333 10 หลายเดือนก่อน +1

      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  10 หลายเดือนก่อน

      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 10 หลายเดือนก่อน

      @@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  10 หลายเดือนก่อน

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

    • @botak333
      @botak333 10 หลายเดือนก่อน

      @@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

  • @iliketrainsguy5918
    @iliketrainsguy5918 6 หลายเดือนก่อน

    I just saw 1/4 video and I'm already serious thinking about subscribing rn, what a nice and useful video, right what I needed

    • @CMTEQ
      @CMTEQ  6 หลายเดือนก่อน +1

      Thank you, I'm glad it was useful

  • @tomas_soeterik
    @tomas_soeterik ปีที่แล้ว

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

    • @CMTEQ
      @CMTEQ  ปีที่แล้ว

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

  • @richardprogramming9402
    @richardprogramming9402 ปีที่แล้ว +2

    This video was very useful!! Thanks!!

    • @CMTEQ
      @CMTEQ  ปีที่แล้ว

      You are most welcome !

  • @BillyChrist-r2k
    @BillyChrist-r2k 10 หลายเดือนก่อน

    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  10 หลายเดือนก่อน

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

  • @ashleed6800
    @ashleed6800 ปีที่แล้ว +2

    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  ปีที่แล้ว +1

      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 ปีที่แล้ว +1

      @@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  ปีที่แล้ว +1

      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 ปีที่แล้ว +1

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

    • @botak333
      @botak333 9 หลายเดือนก่อน

      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

  • @lenzneethling3164
    @lenzneethling3164 9 หลายเดือนก่อน

    Very helpful !!

    • @CMTEQ
      @CMTEQ  9 หลายเดือนก่อน

      Great 👍, I'm glad it was helpful

  • @johnfrancis923
    @johnfrancis923 9 หลายเดือนก่อน +1

    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  9 หลายเดือนก่อน

      Hi, I will have a look later. Please check my video on clock configuration. th-cam.com/video/CUgPXt4JE_c/w-d-xo.html

  • @mohamedansari_stm
    @mohamedansari_stm 10 หลายเดือนก่อน +1

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

    • @CMTEQ
      @CMTEQ  10 หลายเดือนก่อน

      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 10 หลายเดือนก่อน +1

      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  10 หลายเดือนก่อน

      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
    @shamilsha7618 10 หลายเดือนก่อน

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

    • @CMTEQ
      @CMTEQ  10 หลายเดือนก่อน

      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
    @STrAnGeR785 ปีที่แล้ว

    can you please share the code

    • @CMTEQ
      @CMTEQ  ปีที่แล้ว

      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.

  • @CMTEQ
    @CMTEQ  ปีที่แล้ว +1

    Analyze PWM signal using SIGLENT SDS 1104X-E Digital Storage Oscilloscope
    th-cam.com/video/-PA0lr3GyAQ/w-d-xo.html

  • @kylekingsberry5680
    @kylekingsberry5680 ปีที่แล้ว

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

    • @CMTEQ
      @CMTEQ  ปีที่แล้ว +1

      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.

  • @SHULIN-rf6tr
    @SHULIN-rf6tr 24 วันที่ผ่านมา

    thank you,your teaching is right.vs this guy has wrong! bad.)th-cam.com/video/92_CWBWXPw0/w-d-xo.html)

    • @CMTEQ
      @CMTEQ  23 วันที่ผ่านมา

      Thank you for the feedback, make sure you subscribe and give a thumbs up, in the coming days I make an LED fader video with PWM.
      But I'm sure the orther video is also fine.