STM32 TIMERS #6. Timer Synchronization || 3 Phase PWM

Sdílet
Vložit
  • čas přidán 8. 09. 2024

Komentáře • 32

  • @shahidalikhan7894
    @shahidalikhan7894 Před 11 měsíci +1

    Thank you for your tutorial. I am new to STM controllers and have been following your tutorials to generate PWM signals using STM32.
    I'm using an STM32F407 board to generate two PWM signals, and from what I've gathered through online research, I need to use two timers, one in master and another in slave configuration. For the master Timer (Timer 1), I've set up two PWM channels. Channel 1 of Timer 1 is for PWM generation, and Channel 2 of Timer 1 is for triggering Timer 2, which is set to 'output compare no output' mode. I followed your tutorial to configure these channels.
    What i actually want is to change the phase shift between two these two PWM signals in run time by modifying the CCR registers in the main. The pulse value set in TIM1 CH2 is supposed to change the phase of the PWM generated by Timer 2. However, I'm unable to change the phase at runtime. I've tried changing the value of the CCR2 register in the main code, but it doesn't affect the phase despite updating CCR2. The phase of TIM2's PWM1 is delayed if I set the pulse of TIM1's CH2 in the Pinout and Configuration section of STM32CubeIDE. However, the phase does not change if I modify "htim1.Instance->CCR2" in the main function. This is the problem I am facing. I want to update "htim1.Instance->CCR2" during runtime.
    Could you please point out my mistake and provide the correct syntax? And if possible, could you explain it in simpler terms, as I'm relatively new to this?

  • @dmytrokorseko518
    @dmytrokorseko518 Před rokem +1

    Thank you so much! Little remark. It needs to pay attention to the order of initialization of the master-slave timers in the code. For example, when timer 3 is the master and timer 1 is the slave, when generating the code CubeMX initializes timer 1 first by default. In this case, timer 1 is may starte by itself, asynchronously with the master (timer 3). That is, after the generation of the code, the sequence of initialization of synchronous timers should be adjusted.

    • @bobshiskabob
      @bobshiskabob Před 7 měsíci +2

      THANK YOU SO MUCH!!!!! This drove me crazy for two days until I found this comment. Tim2 initialized before Tim1

  • @TheEmbeddedHobbyist
    @TheEmbeddedHobbyist Před rokem

    Nice video, well explained in that great disjointed voice. May have to find a controller to play with.

  • @tisserandstephane7845

    Thanks for this great tutorial : all is clear with good explanation !

  • @singhman1026
    @singhman1026 Před 7 měsíci

    Really good tutorial.... 👍

  • @siddharthmali5841
    @siddharthmali5841 Před rokem +1

    Great tutorial.

  • @dingkuncai4004
    @dingkuncai4004 Před rokem

    Thank you and happy new year!

  • @Zurenio
    @Zurenio Před 7 měsíci

    You are the best...!!!

  • @ahmadsayuti7937
    @ahmadsayuti7937 Před 7 měsíci +1

    Thank you for the tutorial, Can you measure time difference phase shift between TIM1 and TIM2 with stm32?

    • @ControllersTech
      @ControllersTech  Před 7 měsíci +1

      I am not sure but I think there is no dedicated feature for it.
      You can manually do it by using 2 input pins with external interrupt on rising edge. Then start the timer once you get the first trigger and stop the timer on second trigger.

    • @botak333
      @botak333 Před 5 měsíci

      ​​@@ControllersTechhi sir i have question, i used acin 220v for ipm igbt module ( after rectifier i get 310v dc) the ipm can handle till 600v, but my motor only acept 200v. Now how ti reduce duty cycle for HIN and lin input sir?? If i used 50%duty cycle i will get 155v out from ipm right sir??? I used stm32 g431 and st mc worckbench motor control sir

  • @egar1956
    @egar1956 Před měsícem

    It is not possible to control the phase between the timers in runtime. Is there some mthod for this ? Thanks

  • @abdoulayebodian3583
    @abdoulayebodian3583 Před rokem

    thank you for this work is it possible to vary the phase shift between the two timer in real time by a potentiometer for example. keeping the same frequency.

  • @chinmaykulkarni7835
    @chinmaykulkarni7835 Před rokem

    Very good explanation.
    One question i have can we convert the 3 phase pwm to 3 phase spwm by CCP register

  • @prabuddhajadhav2933
    @prabuddhajadhav2933 Před 6 měsíci

    what if i want to read these three signals, these signals are similar to hall sensor data(120 phase shifted). how will i able to read these signals like 011 , 101, 110 etc

  • @mmt1024
    @mmt1024 Před rokem

    Great video

  • @iliasmatz3922
    @iliasmatz3922 Před rokem

    Hello, thank you for your valuable lessons! Is a possible way to implement phase shift between complementary pairs of different channels at the same timer?

    • @ControllersTech
      @ControllersTech  Před rokem

      Isn't it shown in the video ?

    • @iliasmatz3922
      @iliasmatz3922 Před rokem

      As I can see the application of this video is generating phase shifted signals between different timers using master/slave configuration (timer synchronization). I am trying to achieve phase shifted signals at a single timer but different channels. I can see that TIM1 OC2 is used to trigger the TIM2. Mby if I choose Output Compare CH2 (instead of output compare no output) and Toggle on match mode (instead of Active level), will it make it possible?

    • @iliasmatz3922
      @iliasmatz3922 Před rokem

      I am sorry if something doesn't makes sense, I am a beginner to STM32. Thank you very much for your immediate response!!!

    • @ControllersTech
      @ControllersTech  Před rokem

      I don't thik it works like that. The second timer needs to be in slave mode for the synchronization to work.
      Individual channels can't be configured i. Slave mode.
      You can try manually though.
      Start the different channels after some delay. It won't be precise, but if you adjust things properly you might be able to achieve it.

  • @davidm6967
    @davidm6967 Před rokem

    Thank you so much for yor video, i have a question, i did it for 2 Phase, it works great, but after i stop my Timer Master and Slave in order to have Delay, i mean with HAL_ TIM_PWM_STOP, doesn't work my timer slave any more, can you help me about that?
    Here is my code, and my Tim3 works only one time and not permanently
    HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_3)
    HAL_TIM_OC_Start(&htim2, TIM_CHANNEL_4)
    HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_2)
    HAL_Delay(200)
    HAL_TIM_PWM_Stop(&htim2, TIM_CHANNEL_3)
    HAL_TIM_OC_Stop(&htim2, TIM_CHANNEL_4)
    HAL_TIM_PWM_Stop(&htim3, TIM_CHANNEL_2)
    HAL_Delay(200)

  • @alexandrev.3332
    @alexandrev.3332 Před rokem

    Hello! How can I change in main.c the value of OC2REF in TIM1. I tried to put in while TIM1 -> CCR2 = 3000; but this not change anything. Can you help me?

    • @alexandrev.3332
      @alexandrev.3332 Před rokem

      Anybody can help me? I tryed everything but only way to change is in the beggining on the boxes, I want to phase shift in a while the value that i want to put and change again and so on

    • @andrerodrigues4318
      @andrerodrigues4318 Před rokem

      @@alexandrev.3332 Were you able to do so? I am also having that problem and need to phase sift from one value to another at a certain time while code is running

  • @osenson98
    @osenson98 Před rokem

    How can get these 3 pwms with just one tim1?

    • @ControllersTech
      @ControllersTech  Před rokem

      You can use 3 channels of tim1 but you have to manually sync them..

    • @deveshshevde-cp8xq
      @deveshshevde-cp8xq Před 3 měsíci

      @@ControllersTech how to mannually sync them?

  • @alirezam1
    @alirezam1 Před rokem

    Thanks. but with Subtitle would be perfect...........

    • @ControllersTech
      @ControllersTech  Před rokem

      Generally youtube generates the cc. I don't know why it's not doing for this video yet.

  • @ahmedrefaie8671
    @ahmedrefaie8671 Před rokem

    Good morning, sir. Where is the translation in Arabic and is it possible to make an explanatory video to make a motor with a pid system