HAL #8: HowTo - Timer PWM

  Рет қаралды 67,607

Web learning

Web learning

Күн бұрын

In this Tutorial im showing how and STM32 Timer ( TIM ) works, and how to use it.
My social accounts :
/ weblearning1
/ weblearning1
/ weblearning1
Thanks.
/ weblearning

Пікірлер: 67
@borakavaklioglu4258
@borakavaklioglu4258 4 жыл бұрын
This is the first tutorial that actually worked for me. You are amazing!
@Weblearning1
@Weblearning1 4 жыл бұрын
Yay! Thank you!
@slip0n0fall
@slip0n0fall 3 жыл бұрын
Important to note that the Prescaler (and Period) get a '1' added to them (so a setting of 0 means a prescaler of 1, or no scaling)
@ahmedladhibi6893
@ahmedladhibi6893 Жыл бұрын
Simple and clear ! best explaining so far ! thank you ! now a question how do we change the duty cycle and the frequency from the code
@naasikhendricks1501
@naasikhendricks1501 5 жыл бұрын
I think a Free RTOS training module will be cool as you explain the essential details well.
@Weblearning1
@Weblearning1 5 жыл бұрын
It's also on the To Do list...
@burhanmuhyiddin4372
@burhanmuhyiddin4372 5 жыл бұрын
Your tutorials are just perfect. Thank you very much :)
@Weblearning1
@Weblearning1 5 жыл бұрын
Thanks for this
@offensivebias3965
@offensivebias3965 Жыл бұрын
Thank you for sharing your knowledge
@englishman_i
@englishman_i 5 жыл бұрын
Everyone is looking forward to the next video!
@Weblearning1
@Weblearning1 5 жыл бұрын
Thanks.
@alexandern8671
@alexandern8671 5 жыл бұрын
Good video, thanks. I have not used Cube5 for timers yet but in Cube4 the prescaler and period values equated to the set value +1. I.e. to divide input frequency by 1000, one needed to set the register value to 999. Did Cube5 change this to be more intuitive?
@filipenicoli_
@filipenicoli_ 5 жыл бұрын
This behaviour is not due to CubeMX, but rather internal implementation details. You can find the Prescaler equation on the Timer Cookbook PDF from ST. There's also an image explaining the reason for the adjustment on auto reload register. Basically, when the timer reaches the "Pulse" value (CCRx), it immediately changes the output, but it waits one timer counting cycle to reset once reaching the auto-reload value (ARR). Thus, you should subtract 1 from ARR and from the Prescaler value, but not from Pulse.
@sudhansumtripathy
@sudhansumtripathy 9 ай бұрын
sir needs some clarification at 2:03 s of video, in 1 sec we get 1000 pulse , do you want to say that the pulse is high for 500 and low for 500, or for 1 complete cycle is 1/1000 =0.001
@trinendragade7640
@trinendragade7640 4 жыл бұрын
This tutorial helps me a lot Thank you so much brother
@Weblearning1
@Weblearning1 4 жыл бұрын
Happy to help
@stm32user
@stm32user 4 жыл бұрын
Nice, but how to change the duty cycle ?. shall we increase the 500 while running ?
@Weblearning1
@Weblearning1 4 жыл бұрын
Yes. The best way is to play with these parameters and see what happens.
@LoveTheFactory
@LoveTheFactory 5 жыл бұрын
I wish BlueNRG-2 was STM32 so CubeMX could be used. Is there any way to leverage PWM on STEVAL-BCN002V1's RGB LED(s) ? Maybe with MFT2_TON & TOFF in PWM_config.h that includes BlueNRG1_mft.h in Micro_Hello_World project of DK 1.0.9 ? Or, software ones on PWM2-4_PIN defines ? Thanks for your awesome videos... They are VERY well done and we are very appreciative. :-)
@mohamedfaroukbouklihacene819
@mohamedfaroukbouklihacene819 3 жыл бұрын
hi! thank you for the video! i want a 200khz pwm output and a i have set the internal clock to 8Mhz so i set the prescalar to 40 to have a prescalar output 200khz and when i put 200000 in the ARR(counter period) box it is impossible and the same thing with the CCR(pulse) box please help!
@abdelazeemhassan3701
@abdelazeemhassan3701 Жыл бұрын
AMAZING
@ESEben10
@ESEben10 4 жыл бұрын
is there a formula that links the system's clock, presclaer,counter period and the required time in seconds? How should I obtain a period of 0,2s? Thanks for the video.
@Weblearning1
@Weblearning1 4 жыл бұрын
Have a look at this: www.emcu.eu/stm32-measure-time-period-and-frequency-of-a-signal-using-the-timer/
@dimitris_g5651
@dimitris_g5651 5 жыл бұрын
Hi can you tell me how what usb osciloscope are you using and how to set it up?
@Weblearning1
@Weblearning1 5 жыл бұрын
Have a look at one of my older videos that I do a review on the USB oscilloscope.
@Guty28
@Guty28 4 жыл бұрын
@@Weblearning1 Cant you just put the link?
@MultiPantero
@MultiPantero 4 жыл бұрын
Hi, probably its very basic stuff, but if I wanna generate a Burst Signal, will be posible using that timer?
@Weblearning1
@Weblearning1 4 жыл бұрын
Yes you can. Have a look at examples with STM32 IR, its the same thing.
@TheRainHarvester
@TheRainHarvester 5 жыл бұрын
How does one edit code using this method? Do you get to save all your menu settings for each timer you setup? (Ex. What if a year from now, I have my code but want to change the pin#/timing etc. But I don't remember the cube Mx stuff I setup that generated the code. ) Just curious. Thanks for the video.
@Weblearning1
@Weblearning1 5 жыл бұрын
Well, first it's best to save all you project in one place and the cube IOC file in the same place. if you still can't find the file, the you can read and see all your settings in the main.c file or peripheral files depends how you set it. See the movie that I made on who the cube generate the code.
@luizazeredo5197
@luizazeredo5197 4 жыл бұрын
Traduzindo e entendendo o código, obrigado por compartilhar conhecimento (Brasil)
@НиколайКрасиков-ы8й
@НиколайКрасиков-ы8й 4 жыл бұрын
Hello, which USB Oscilloscope do you use, please link ali and other? Where can I get such an Oscilloscope/Spectrum link for it?
@Weblearning1
@Weblearning1 4 жыл бұрын
I have 2: 1. Rigol 4 ch color scope that i have. I made a video on how to fix it. kzbin.info/www/bejne/kGOxeoyFZsyIgJI 2. A smaller and simpler one that I use for my videos: kzbin.info/www/bejne/qp6pZnVsosmlgrs
@MrRonychakraborty
@MrRonychakraborty 3 жыл бұрын
you should also tell how to change duty
@noithugian494
@noithugian494 3 жыл бұрын
can you use PWM + timer + DMA to generate DAC at STM32f103c8 ?
@Weblearning1
@Weblearning1 3 жыл бұрын
Yes you can. You use a block of data and you set the DMA to push every x time to the PWM. May be you can considerer subscribing to the channel?
@cronnosli
@cronnosli 4 жыл бұрын
Hi, What I have understood from your example is that you set the frequency in CubeMX. There is a way to change the frequency while running. Let say that I want to modulate several frequencies from 30HZ up to 32MHZ, it is possible?
@Weblearning1
@Weblearning1 4 жыл бұрын
Yes. With the STM32 you can change almost everything from the code without resting the device. Just write to the registers again and that's it.
@cronnosli
@cronnosli 4 жыл бұрын
@@Weblearning1 I'm still a newbie at STM32, there is any howto about writing to registers ?
@poonamjangid01
@poonamjangid01 5 жыл бұрын
@3.41 in channel 1, no pwm option is available. I am using stm32f103c8t6.
@Weblearning1
@Weblearning1 5 жыл бұрын
Try a different channel, it should all work the same way.
@MichasRichter
@MichasRichter 5 жыл бұрын
Will this be applicable to the proposed 7S battery holder PCB with stm32 as BMS?
@Weblearning1
@Weblearning1 5 жыл бұрын
Yes, it can. But I didn't get almost anyone that what's to contribute to do this, so it looks like I will drop it for now.
@baslinjames7714
@baslinjames7714 4 жыл бұрын
In the end of the video, the waveform was displayed and max voltage was around 3..can i increase or decrease that voltage level with the settings in cubemx?
@Weblearning1
@Weblearning1 4 жыл бұрын
No, the PWM is only 1 and a 0 of your voltage. You can use a Low pass filter and depending on the frequency, you can make it as a DAC. There are also other ways, with more GPIO and resistors as voltage dividers.
@vladik8843
@vladik8843 3 жыл бұрын
increase and decrease voltage ? Man you need to start learning some basics. First step is to find out what PWM is..
@abdelhakimazzouzi3371
@abdelhakimazzouzi3371 3 жыл бұрын
Thank you very much!
@Weblearning1
@Weblearning1 3 жыл бұрын
You're welcome!
@leezanvlog8548
@leezanvlog8548 4 жыл бұрын
hi, it's very usefull i see you use oscilloscope/spectrum analyzer software, can you give me link to download ?
@Weblearning1
@Weblearning1 4 жыл бұрын
I use a low cost one, see my video: kzbin.info/www/bejne/qp6pZnVsosmlgrs
@abutaymiyyahlectures
@abutaymiyyahlectures 3 жыл бұрын
i want to buy an oscilloscope but its too expensive, i could buy a usb oscilloscope instead, but i dont know which to buy, any recommandations?
@Weblearning1
@Weblearning1 3 жыл бұрын
Did you end up buying one? Have a look at the video I made on the USB OSC that I have.
@abutaymiyyahlectures
@abutaymiyyahlectures 3 жыл бұрын
@@Weblearning1 nope i did not buy but i am still planning to, thank you, yes i will watch it during my holidays which is coming up in less than a week, anyways also, thank you for your videos!
@DarkWolf887
@DarkWolf887 3 жыл бұрын
would it be possible to use a function generator insteat of the internal clock? I am connecting a function generator (1000KHz, 3V, 1.5 Offset) to the positive pin of the comparator and in the negative I am using the VRefInt. However I just get a HIGH in the output of the comparator. :(
@Weblearning1
@Weblearning1 3 жыл бұрын
What do you want to achieve? Counting pulses? Something else?
@DarkWolf887
@DarkWolf887 3 жыл бұрын
@@Weblearning1 yes. But I don’t know what is the best option for this. I’m afraid that connection a 3.3V, 1KHz signal is gonna be a too high frequency to get to trigger at the voltage reference (1.2V).
@tomhyhlik1788
@tomhyhlik1788 5 жыл бұрын
thanks
@gikusa2063
@gikusa2063 4 жыл бұрын
hello, i try to make pwm in TIM2 as you made but it doesn't work, may i make somethings wrong?
@Weblearning1
@Weblearning1 4 жыл бұрын
There are different settings to play with till you get it to work correctly. I cant tell what you made wrong.
@kameleln1617
@kameleln1617 3 жыл бұрын
I am beginner in stm32, how you can log PA5 to LD2 and to swtich after that with Tim2_CH1, thank's in advance.
@Weblearning1
@Weblearning1 3 жыл бұрын
Sorry, didn't understand your question. Try to elaborate.
@naasikhendricks1501
@naasikhendricks1501 5 жыл бұрын
Cool
@aitrile7708
@aitrile7708 4 жыл бұрын
thank you
@Weblearning1
@Weblearning1 4 жыл бұрын
You're welcome
@srishtisingh1688
@srishtisingh1688 2 жыл бұрын
The following code is showing errors in my PC please help and inform why an error is occurring.
@Weblearning1
@Weblearning1 2 жыл бұрын
What type or error?
@Homo_neanderthal
@Homo_neanderthal 2 жыл бұрын
Go study units. You cannot compare sec and hz, they are different units
HAL #9: HowTo Low power  STOP
4:58
Web learning
Рет қаралды 7 М.
STM32 Guide #3: PWM + Timers
20:24
Mitch Davis
Рет қаралды 145 М.
когда не обедаешь в школе // EVA mash
00:51
EVA mash
Рет қаралды 4,3 МЛН
Help Me Celebrate! 😍🙏
00:35
Alan Chikin Chow
Рет қаралды 81 МЛН
STM32 PWM basics
18:31
Random Rick
Рет қаралды 20 М.
Lecture 13: Timer PWM Output
16:47
Embedded Systems and Deep Learning
Рет қаралды 105 М.
Tutorial STM32 DAC Timer Triggered DMA
34:08
PR TechTalk
Рет қаралды 4 М.
Tutorial on STM32 External Interrupts and callback funktions
24:31
Stm32 Timers in PWM mode
37:44
Eddie Amaya
Рет қаралды 48 М.
STM32 TIMERS #3. ENCODER MODE || F103C8
15:41
ControllersTech
Рет қаралды 58 М.
STM32 Multi ADC DMA method
29:42
PR TechTalk
Рет қаралды 7 М.
W25Q FLASH Memory || Part 1 || How to connect Device and Read ID
17:04
ControllersTech
Рет қаралды 19 М.
Stm32 Intro To timers
24:34
Eddie Amaya
Рет қаралды 54 М.
HAL #10: HowTo Timer with Interrupt
5:18
Web learning
Рет қаралды 49 М.