STM32 TIMERS #4. INPUT CAPTURE || Frequency and Width

  Рет қаралды 51,696

ControllersTech

ControllersTech

Күн бұрын

Пікірлер
@Engrbilal143
@Engrbilal143 3 жыл бұрын
Appreciate your effort for providing such high quality tutorials for free
@PaulSanders-n5o
@PaulSanders-n5o 5 ай бұрын
Thanks for a great video, I added an overflow IRQ to sample very slow frequencies on the same counter. Also I added a flag once a conversion is ready to calculate and stopped the edge IRQ, so this lets you push the measurement range a bit high if you are looking at constant frequencies.
@sarathm3972
@sarathm3972 2 жыл бұрын
I am using the stm32h745-nucleo board. Currently I am Working with the timers. As I am working with the timers I need one timer in the cm4 and another timer in the cm7. I need to capture the falling edge of timer cm7 and need to give input for cm4 timer. Could you please help me out to find the falling edge for cm7 timer pulse to achieve this.
@bobby9568
@bobby9568 3 жыл бұрын
This guy is smarter than my professor!
@LinusLee-pg1uu
@LinusLee-pg1uu Жыл бұрын
Thank you for the video! But I have a question: is timer 1 and timer 2 physically connected? How can timer2 receive the pwm input from timer1? and why would HAL_TIM_IC_CaptureCallback trigged by timer1? I thought AL_TIM_IC_CaptureCallback is triggered by input, but timer1 is output. Thank you very much again!
@ControllersTech
@ControllersTech Жыл бұрын
Yes timer1's output is connected to the timer2's pin. Ic capture callback is not triggered by tim1, its triggered by tim2
@LinusLee-pg1uu
@LinusLee-pg1uu Жыл бұрын
@@ControllersTech Thank you, now I understand!
@roy_hawk
@roy_hawk 4 ай бұрын
Hello friend! I wanted to ask you a question. You know that IC (Input Capture) function that we use in timers? I generally saw that it is used to read frequency, I have already tested it for this purpose too and it works well. But one thing that I was never able to do using the IC in that mode that activates the interrupt by rising and falling edges, was to have information whether the interrupt was activated by a rising edge or a falling edge. And a while ago I searched everywhere, I did a lot of tests, apparently a flag was supposed to be set according to the edge that activated it, but it was never set. In fact, I tested this a lot and ended up thinking that it is impossible, which for me is absurd, considering that the information is there, but it seems inaccessible. Having said that, please, is it possible to use the IC with interruption on both edges (rising and falling) and be able to identify the edge? For example, if it was a rising edge, I want to enter an if, if it was a falling edge, I want to enter another if (or else). I really wanted it to be possible, thinking about an application to check synchrony between square waves and the difference in angle between them. If it's not possible, then I'll do it with a timer and perhaps external interruption, but I wanted to use the IC for precision. I would be very grateful if you could clarify whether it is possible or not. Thanks!
@martinchristiansson658
@martinchristiansson658 3 жыл бұрын
Plaese do a video on i2c with dma..trying this with mpu6050 and no succes at the moment
@yasinbyker
@yasinbyker 2 жыл бұрын
I want to measure the rpm of an engine. Using the information in this video, can the rpm of an engine be measured with the help of a sensor(like fc-33)? If it can be measured, how should I proceed?
@UTubeJamesChou
@UTubeJamesChou 7 ай бұрын
Thank you so much. I have a question, how can I confirm that the first incoming interrupt is triggered by a rising edge and the second interrupt is generated by a falling edge? From what I see here, the entire period is 100 clocks, and the pulse width is 30. Most of the time, I get a difference result of 70, but sometimes after a while it becomes 30. It looks like the first interrupt is generated by a falling edge, while the second interrupt is generated by a rising edge.
@ControllersTech
@ControllersTech 7 ай бұрын
You can first only enable the rising edge interrupt. Once it is detected and callback is called, enable falling edge also.
@MrItsfitz
@MrItsfitz 2 жыл бұрын
Thanks for the really informative and clear set of STM32 timer tutorials. However, I just cannot get this IC set up working. I'm using a Blue Pill board in the STM32CubeIDE and the debugger message "(Suspended : Signal ; SIGTRAP/Trace/breakpoint trap)" is displayed. The PWM is being generated and there are no breakpoints set. Can you help?
@ControllersTech
@ControllersTech 2 жыл бұрын
I don't know about this. Never faced such issue
@himjan929
@himjan929 Жыл бұрын
Faced similar problem, My error was divide by zero. I was dividing a number by zero due to poor initialization.
@incxxxx
@incxxxx 5 ай бұрын
You should connect PA8 and PA0, to provide signał which makes interupt. That important fact is not mentioned in the film.
@incxxxx
@incxxxx 5 ай бұрын
You should connect PA8 and PA0, to provide signał which makes interupt. That important fact is not mentioned in the film.
@afiziadebisi7909
@afiziadebisi7909 2 жыл бұрын
If I’m taking input from an external wave generator do I just connect it to one of the timers
@ControllersTech
@ControllersTech 2 жыл бұрын
Yes ofcourse
@najidjalees4321
@najidjalees4321 Жыл бұрын
can we get any frequency value if we dont give any input signal to the microcontroller?
@mrdoo201
@mrdoo201 Жыл бұрын
Hi sir, thanks for your video. But I have some confusing in this video and can you help me to explain one thing ? In your video, you configed Timer 1 is PWM output and Timer 2 is Input Capture. But when you caculate refClock at 6:42, why you use TIMECLOCK and PRESCALAR of Timer 2 ? The Frequency after that is the frequency of PWM Timer 1 so I think the TIMECLOCK and PRESCALAR is Timer 1 too. I'm just a newbie and thank you so much.
@ControllersTech
@ControllersTech Жыл бұрын
The TIMCLOCK and PRESCALAR is used for calculating the input frequency. Basically we capture the counter value of timer2 for 2 triigers. Then we find the difference in the counter values and this difference is equivalent to the input frequency. But here we need to convert the difference we got, to the frequency or time equivalent. To do so, we need to know at what rate our counter is running. That's why we use the clock of tim2. For eg- if counter is running at 1000hz, then the difference of 10 means the frequency is 100hz. And if the counter is running at 1MHz, then the same difference of 10 means the freq is 100khz. So it depends on the counter rate and hence we use the values of the timer, which is actually capturing.
@bennguyen1313
@bennguyen1313 2 жыл бұрын
At the 1m45s mark that shows the block diagram.. where does it say that Timer1 PWM Output can be used as the input to Timer2 Input-Capture? For example, in the RM it says the input signal to measure (IC4) via Input-Capture reg is selected (ICSELECTION) in TIM2_CCMR2 as : TI4 (b01-Direct), TI3 (b10-Other Channel3), or TRC(b11) Where does it say that TI4 is not the input pin, but rather Timer 1's Output PWM?
@ControllersTech
@ControllersTech 2 жыл бұрын
I am feeding it manually. We need some signal to test the IC right, the signal come from the output of another timer.
@ulisesferreira4862
@ulisesferreira4862 Жыл бұрын
Thank you so much for the help. I understood a lot of things and configurations that i didn't in class. However im having trouble with the measurement of frequency, i do have the pins A0 and A8 connected but the live expression frequency stays at cero.
@berlinraj8149
@berlinraj8149 6 ай бұрын
bro same issues bro.. can you solve this ?
@medraouf819
@medraouf819 9 ай бұрын
does this code work if i wanted to count the number of pulses of a high speed rolling theeth gear? (every tooth gives a pulse)
@labamichnetvoll5911
@labamichnetvoll5911 Ай бұрын
hi, nice videos, could you make a tutorial about dmx timing via uart for stm32 ?
@mmt1024
@mmt1024 3 жыл бұрын
What if falling edge will appear first, then you will measure width between falling and rising, so 80% ?
@ControllersTech
@ControllersTech 3 жыл бұрын
Haha right. Actually we can do something about it, but i didn't included that part. Or else the code would be a bit complicated.. Anyway like i said i will release another video using DMA, and such things are taken care in it..
@ramzibrik6845
@ramzibrik6845 2 жыл бұрын
Hi. How i can measure the frequency of sine wave ?
@andreichichak5242
@andreichichak5242 2 жыл бұрын
A sine wave will be squared up by the schmidt-trigger input of the processor. Externally it will be a sine wave, but the processor will see a square wave.
@YogeshJagtap-f1z
@YogeshJagtap-f1z Жыл бұрын
My board is STM32 Discovery board so in that case what settings I should do to get output . I have done all settings according to your video but still I am not getting the output frequency.Kindly tell me the hardware settings also
@incxxxx
@incxxxx 5 ай бұрын
You should connect PA8 and PA0, to provide signał which makes interupt. That important fact is not mentioned in the film.
@Shet_does
@Shet_does Жыл бұрын
Hello If i need to use timer input capture for capturing both rising and falling of a tounch sensor And i need to check whether the difference is equal or greater than 5sec if so i need to execute respective tasks how can i do that for 16 bit timer I configured for 1ms configuration It will be long pulse where several counter roll out would happen how to do this basically how can we have condition to check for whether greater than 5sec at the moment i release
@ControllersTech
@ControllersTech Жыл бұрын
You should use external interrupt for this. Set the interrupt to both rising and falling edges. Define a 32 bit variable in the main file and desfine it as an external variable in the interrupt.c file. Increment the variable in the systick handler. When the interrupt is triggerd due to rising edge, reset the varibale. And when it is triggered due to falling edge, measure its value.
@Shet_does
@Shet_does Жыл бұрын
Can you please give some more insight currently interrupt for rising and falling edge is configured.
@truongho2771
@truongho2771 2 жыл бұрын
Hi , mFactor = 1000000/refClock I dont understand , can you help me ?
@furkanyaprakcer844
@furkanyaprakcer844 Жыл бұрын
what we can do for 100% duty cycle situations?
@ControllersTech
@ControllersTech Жыл бұрын
Nothing
@dimaabualfoul9281
@dimaabualfoul9281 Жыл бұрын
TYSM ! CRYSTAL CLEAR
@mohamedalikhlifi9045
@mohamedalikhlifi9045 Жыл бұрын
sir i tried to measure the frequency but Always the live expression show 50, can you help me
@Red_Fang.
@Red_Fang. Жыл бұрын
i want to ask, how to use this feature for applying long pressed push button ? anyone have the source code or any references ? thank you
@ControllersTech
@ControllersTech Жыл бұрын
Lets assume the pulse goes high when you press the button and low when you release it. Just measure the width between the high and low pulse. Then program your controller as per that width. If (width > 300ms) then long press triggered.
@ARM_TECH
@ARM_TECH 3 жыл бұрын
Project with low pass filter witch agian
@ARM_TECH
@ARM_TECH 3 жыл бұрын
Thanks
@harishkumar-sf9km
@harishkumar-sf9km 11 ай бұрын
I want configuration and code using input capture for hc-sr04 sensor with stm32f446re mcu
@ControllersTech
@ControllersTech 11 ай бұрын
Its already present on the channel. Atleast search for things before asking about it. kzbin.info/www/bejne/qprCYo2th9Sfi5Y
@sugiyartosugiyarto1587
@sugiyartosugiyarto1587 3 жыл бұрын
Thank sir
@akashv5622
@akashv5622 3 ай бұрын
This seems quite absurd, how can we actually infer that timer 1 and 2 are connected.. There has to be some setting to explain this right? What if there are a lot of timers enabled how will that timer get to know to capture which timer signal
@akashv5622
@akashv5622 3 ай бұрын
I don't think so the timers are connected internally by default.. I used a jumper to connect both the pins and now the interuppt started triggering. I'm using a stm32g474-dpow board
@alexandrev.3332
@alexandrev.3332 2 жыл бұрын
Very nice, this worked very well
@Embedded_Developer
@Embedded_Developer 3 жыл бұрын
wonderfull!
@zainalishammat2866
@zainalishammat2866 3 ай бұрын
thank you very much :)
@truongho2771
@truongho2771 2 жыл бұрын
why did you use CLOCK SOURE : INTERNAL CLOCK , because you use RCC: CRYSTAL and Config you use HSE
@ControllersTech
@ControllersTech 2 жыл бұрын
What time ? Point the timeline
@truongho2771
@truongho2771 2 жыл бұрын
@@ControllersTech it 2:57 you choose INTERNAL CLOCK, but CLOCK CONFIG you use HSE
@ControllersTech
@ControllersTech 2 жыл бұрын
Thats the clock for the timer. It is clocked by the APB clock.
@truongho2771
@truongho2771 2 жыл бұрын
@@ControllersTech i know , but when we use Timer always choose INTERNAL CLOCK ? , beacause i dont use INTERNAL CLOCK it no problem
@ControllersTech
@ControllersTech 2 жыл бұрын
Vhoosing the type of clock changes the timer operation mode. You can read more about it in the reference manual of your controller
@ferdinvivian9336
@ferdinvivian9336 3 жыл бұрын
Is this live class sir
@ControllersTech
@ControllersTech 3 жыл бұрын
No. It's just premiere..
@ferdinvivian9336
@ferdinvivian9336 3 жыл бұрын
@@ControllersTech thanks a lot for your valuable videos sir. Thanks for your efforts
STM32 ETHERNET #5. TCP CLIENT || RAW API
10:57
ControllersTech
Рет қаралды 14 М.
STM32 TIMERS #2. PWM Input
16:23
ControllersTech
Рет қаралды 34 М.
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 62 МЛН
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 7 МЛН
INPUT CAPTURE using DMA || Measure High Frequencies and Low Width
11:01
Lecture 14. Timer Input Capture
8:48
Embedded Systems and Deep Learning
Рет қаралды 39 М.
STM32 TIMERS #5. Master Slave Synchronization using the TRIGGER MODE
15:38
STM32 TIMERS #3. ENCODER MODE || F103C8
15:41
ControllersTech
Рет қаралды 61 М.
STM32 TIMERS #1. PWM Output || DMA
12:36
ControllersTech
Рет қаралды 137 М.
STM32 General Purpose Timer : Understanding Input Capture (IC) Mode -2
4:17
Fastbit Embedded Brain Academy
Рет қаралды 31 М.
Receive data using UART in STM32 || Poll || Interrupt || DMA
14:07
ControllersTech
Рет қаралды 127 М.