Servo motor control using STM32 and PWM || HAL || CubeMx || Keil

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

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

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

    To download code and for more explanation, visit the link in the description

    • @greenysan5265
      @greenysan5265 4 ปีที่แล้ว

      There is no code in the given link

    • @ControllersTech
      @ControllersTech  4 ปีที่แล้ว

      @@greenysan5265 It's at the end of the post...

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

    Thank you, I followed your instructions to program a F103C8.

    • @caffeinatedinsanity2324
      @caffeinatedinsanity2324 4 ปีที่แล้ว

      The fun thing with STM boards and community in general is that knowledge and stuff used with one board can possibly be applied to another board.
      Someone could easily use this for its nucleo board

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

    Great video, but how did you get ARR value (1000)

  • @lilposte6970
    @lilposte6970 3 ปีที่แล้ว

    Great channel . Big thanks bro you really help us

  • @Basti1987chiller
    @Basti1987chiller 2 ปีที่แล้ว

    Great video, thank you very much :)

  • @samsonk2400
    @samsonk2400 5 ปีที่แล้ว

    I will start using this for my robotics project

  • @sivapraveens9643
    @sivapraveens9643 3 ปีที่แล้ว

    Thanks for sharing, can u please share the details of that digital oscilloscope compact?

  • @recback3357
    @recback3357 4 หลายเดือนก่อน

    big thanx bro i love u

  • @encryptedchannel213
    @encryptedchannel213 3 ปีที่แล้ว

    3:27 you calculate the 45*10^6/50 = 900khz you get but your not written in the psc you just writing 900 but why , any formula is there for find out the timer frequncy

  • @Abdulnur55
    @Abdulnur55 6 ปีที่แล้ว

    90 prescaler and 20000 ARR would also work. Is also 50hz

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

      This depends on your TIMER frequency. Any combination can work.. Visit the link in the description, It's explained there

  • @aura100500
    @aura100500 2 ปีที่แล้ว

    Thank you!

  • @nhatduyhuynh5097
    @nhatduyhuynh5097 4 ปีที่แล้ว

    i follow your instruction but servo not run. how you config analog pin ? show help me

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

    how make the servo motor spin reversely?

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

      check the properties of the servo you are using. There are 2 types, one which rotate only 180, and another rotates throughout.

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

    Can you tell me on which PWM pin of STM is the signal pin for servo attached??
    How are pins connected to the servo with stm pins?

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

      I ASK TOO

  • @thanhtaiphan2651
    @thanhtaiphan2651 4 ปีที่แล้ว

    can you control the motor by using potentiometer

  • @alfian4553
    @alfian4553 3 ปีที่แล้ว

    Could you give explanation for the schematic part (between mcu and motor)? i really need this

    • @ControllersTech
      @ControllersTech  3 ปีที่แล้ว

      There are 3 pins vcc, gnd and signal. What explanation you want for that ?

    • @alfian4553
      @alfian4553 3 ปีที่แล้ว

      @@ControllersTech i dont know how to connect them

    • @ControllersTech
      @ControllersTech  3 ปีที่แล้ว

      Vcc to 5V
      gnd to gnd
      signal to PWM pin

  • @Akash-m2c
    @Akash-m2c 10 หลายเดือนก่อน

    Sir, i am using f411re and i have set it to it's max clock frequency of 100 Mhz. What values should i give to the prescalor and counter period ?

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

      2:35

    • @Akash-m2c
      @Akash-m2c 10 หลายเดือนก่อน

      @@ControllersTech Ok, I set the APB1 Prescaler value as /8 and and HCLK (MHz) to it's max frequency of 100 MHz in clock configuration. I got the APB1 Timer clock value as 25 Mhz. So, does it mean that i should enter 500-1 in prescaler of timer 2 channel 1 parameter settings because 25 MHz/50Hz is 500000? And is ARR value constant? Shall I put ARR value as 1000-1?

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

      Yes. But the ARR is not constant. You have to divide 500000 between psc & ARR. You can also choose the psc to be 5000 & ARR 100, or psc 50 & ARR 10000. Just remember tgat ARR represents 100% duty cycle, so for small duty percentages it is easier if we keep the ARR high.

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

    PLEASE CONTINUE

  • @parameswaranramesh
    @parameswaranramesh 6 ปีที่แล้ว

    please add for making automatic light system using nucleo board

    • @ControllersTech
      @ControllersTech  6 ปีที่แล้ว

      Can u elaborate ??

    • @parameswaranramesh
      @parameswaranramesh 6 ปีที่แล้ว

      i am doing my projects as automatic streetlight system using lora.
      nucleo board-L073rz
      LoRa module-sx1272
      as l073rz pin configurations are done by suing cube mx software nad keil mdk 5 as a programming language i have chosen.
      i am having the difficulties of pin configuration and code for street light....
      other components i am using ldr and relay and some sensors to detect environmental illumination.so could you please tell me the connections with the nucleo board how to interface lora with that also...

    • @ControllersTech
      @ControllersTech  6 ปีที่แล้ว

      Mail me the details at help@controllerstech.com

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

    PWM video in desc is unavailable

  • @The2Coolest2
    @The2Coolest2 3 ปีที่แล้ว

    Is there anyway to control the speed of rotation of the servo?

    • @ControllersTech
      @ControllersTech  3 ปีที่แล้ว

      I don't think so

    • @The2Coolest2
      @The2Coolest2 3 ปีที่แล้ว

      @@ControllersTech Thanks. Need to find a motor I can adjust both position and speed.

    • @ControllersTech
      @ControllersTech  3 ปีที่แล้ว

      Go for stepper motor

    • @The2Coolest2
      @The2Coolest2 3 ปีที่แล้ว

      @@ControllersTech Was thinking that. Is it like I can adjust speed using PWM?

    • @The2Coolest2
      @The2Coolest2 3 ปีที่แล้ว

      @@ControllersTech I found your other video. Thanks!

  • @mehmetdemir5655
    @mehmetdemir5655 2 ปีที่แล้ว

    Hello, i cant use htim2.Instance->CCR in a for loop i dont know why help me pls

    • @LaydleBagel
      @LaydleBagel 8 หลายเดือนก่อน

      don't forget the channel number at the Capture Compare Register (CCR). if you are using channel 1, it would be CCR1, so htim2.Instance->CCR1 = foo;

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

    YOU SAVE MY LIFE thanks. n_n

  • @kostaveselic7561
    @kostaveselic7561 2 ปีที่แล้ว

    If i am using a chanell 2 will i be using ccr 2 ?

  • @last333
    @last333 6 ปีที่แล้ว

    Do you have a video explaining the configuration for the comunication trow the RX and TX? Sorry for my bad English.

  • @eatableice
    @eatableice 4 ปีที่แล้ว

    how to program STM32 from MATAB

  • @electronlab5551
    @electronlab5551 4 ปีที่แล้ว

    Good video

  • @kpsplash
    @kpsplash 4 ปีที่แล้ว

    Thanks for your video!
    I have a question.
    What do I have to do if I use a sensor from which get the angle of rotation of the servo motor?

    • @ControllersTech
      @ControllersTech  4 ปีที่แล้ว

      What sensor ?

    • @kpsplash
      @kpsplash 4 ปีที่แล้ว

      @@ControllersTech MPU6050 GY521
      I've seen your video about this ^ sensor and the lcd but I don't understand how to use the values of the MPU6050 GY521 as input for the servo motor.
      I want to use the sensor like a Wii Mote for the servo motor.

  • @damnemo
    @damnemo 4 ปีที่แล้ว

    Hi, thanks for the video. One question, from datasheet this servo SG90 has operating voltage at 4.8-6V but you link directly to the pin of the stm32, How?

    • @ControllersTech
      @ControllersTech  4 ปีที่แล้ว

      Stm32 have 5V output. Just connect there

    • @damnemo
      @damnemo 4 ปีที่แล้ว

      PA0 is 3.3V in oscilloscope, so signal at 3.3V and power at 5V, i'm right?

    • @ControllersTech
      @ControllersTech  4 ปีที่แล้ว

      Yeah but as we are using PWM, signal is not exactly 3.3v. it's changing and based on that servo rotates

  • @Abdulnur55
    @Abdulnur55 6 ปีที่แล้ว

    dou you use the 5v output from den nucleo board?

    • @ControllersTech
      @ControllersTech  6 ปีที่แล้ว

      Yes

    • @damianruszaa1553
      @damianruszaa1553 5 ปีที่แล้ว

      @@ControllersTech Isn't dangerous plugging Vcc from servo to 5V on nucleo boar? Can it harm the board? Or it depends from board itself (for example: on STM32F103RB it is harmfull, and on STM32F411RE it's not)?

  • @siddhiparab6879
    @siddhiparab6879 2 ปีที่แล้ว

    Hii I have a question, do you have any idea how we can do servo motor on and off using uart protocol and USB to TTL converter??

  • @peaba
    @peaba 5 ปีที่แล้ว

    Why the position at 0.5ms is 0, and at 1.5ms is 90?

    • @ControllersTech
      @ControllersTech  5 ปีที่แล้ว

      That's how the servo motor works.the rotation is based on the width of the pulse you provide

  • @AMNAT.T
    @AMNAT.T 4 ปีที่แล้ว

    How to Circuit Servo and STM32 ??

    • @ControllersTech
      @ControllersTech  4 ปีที่แล้ว

      Do u mean how to connect ?
      There is only one data pin in servo, just connect it to the PWM channel of the timer, that you are using..

    • @AMNAT.T
      @AMNAT.T 4 ปีที่แล้ว

      @@ControllersTech I connect :
      RED --> (+5V)
      PA0 --> ORANGE (PWM pin)
      GND --> BROWN (GND)
      and I create code like you But my servo doesn't spin.

    • @ControllersTech
      @ControllersTech  4 ปีที่แล้ว

      What controller ?
      What timer you are using ?
      What's the apb1 and apb2 clocks ?
      Whats the prescalar and arr values ?

  • @luizazeredo5197
    @luizazeredo5197 4 ปีที่แล้ว

    Aprendendo muito com suas aulas, Muito obrigado (BR). /*End*/

  • @fabianhochstrasser4736
    @fabianhochstrasser4736 5 ปีที่แล้ว

    Which Pin you use on the Nucleo Bord for PWM output?

    • @ControllersTech
      @ControllersTech  5 ปีที่แล้ว

      It depends on which pwm you use. For pwm1 its A1

  • @ashwin372
    @ashwin372 6 ปีที่แล้ว

    what to do if i need to control 4 servos separately??

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

      You configure all channels of TIM2 as PWM outputs. Then when you want to write duty cycle of channel_x you replace CCR1 with CCRx;
      for channel2 CCR2,
      for channel3 CCR3 and
      for channel4 CCR4.

  • @VamsiKrishna-ep1iu
    @VamsiKrishna-ep1iu 6 ปีที่แล้ว

    hello i need program about pwm phase shift in STM32

  • @karolus1511
    @karolus1511 6 ปีที่แล้ว

    Hello, How can I change speed of servos moves ?

    • @ControllersTech
      @ControllersTech  6 ปีที่แล้ว

      We can't change the speed. All we can do is change the time for which the motor rotates..

  • @anjank26
    @anjank26 6 ปีที่แล้ว

    Thank you for such Osm video, How you Displayed on LCD-TFT display.? You not used with your code explanation? How do you displayed on it? If now I kindly request you to make make LCD-TFT display to display "hello world" example. Thank you in advance!!!!

    • @ControllersTech
      @ControllersTech  6 ปีที่แล้ว

      I am not using this TFT as a display. It is dso138 and it is already programmed to work as an oscilloscope.
      I'll make a video on TFT soon.

  • @Abdulnur55
    @Abdulnur55 6 ปีที่แล้ว

    why Input frequency 8Mhz?
    why Counter period 1000?
    why prescaler 900?
    why-1?

    • @ControllersTech
      @ControllersTech  6 ปีที่แล้ว

      ALL explained in the link in the description

    • @jtauscher
      @jtauscher 6 ปีที่แล้ว

      "why-1" - not explained

    • @ControllersTech
      @ControllersTech  6 ปีที่แล้ว

      Because the mcu adds 1 to the value. It's given in the datasheet..
      That's why by default its 0 while actually it is applied as 1

    • @jtauscher
      @jtauscher 6 ปีที่แล้ว

      Thanks, somehow it doesn't work - I've got no output at PA0 at all. I've got a L476RG - what could be the difference? Is it correct that most important is to have 45MHz/22.5MHz at APB1? Because I have 80MHz max. at HCLK, not 180. So I have 45MHz at HCLK which again leads to 45/22.5 at APB1.

    • @ControllersTech
      @ControllersTech  6 ปีที่แล้ว

      In the tutorial, I am using TIM3 which is connected to APB1 bus, you should find out yours, if u don't get the output contact me in person at help@controllerstech.com

  • @wilfriedlinn223
    @wilfriedlinn223 5 ปีที่แล้ว

    Did not work at all. It says "could not connect to J-Link".

    • @ControllersTech
      @ControllersTech  5 ปีที่แล้ว

      Do you have a j link ? What controller are u using ?

  • @abdullahkapadia7915
    @abdullahkapadia7915 5 ปีที่แล้ว

    thanks/