for me this method in cube ide so complicated compare to arduino ide. but slowly will follow in step by step. anyway thnk you for this video. really appreciated.
Thankyou for the code and video, but fundamentals are not clear yet. Please guide. 1. Turning on the timer with Prescalar value 65535 = OK 2. Turn on edge triggered (Falling edge) interrupt on the IR remote signal pin (B11) = OK 3. Now when an falling edge triggered interrupt is initiated, since timer is already ON, how and where are we turning on the timer to measure the pulse width??
Dear Mr. Nizar. I would like to add one dc motor, one rc-servo , and one stepper motor then control speed, direction using irremote setting in this video. the question are: 1. it is necessary to set the hardware configuration from beginning? if necessary how to do that? 2. It is possible just add the instruction for all the motor inside the "SWITCH-CASE" only? thank you.
You can open the ioc file and add the settings for any new devices and save, it will generate new codes. Or, you can create new project and do the settings for all devices. Setting for servo is here ruclips.net/video/h54DEslq-GI/видео.html Setting for DC motor is here ruclips.net/video/0rbKmkNEdAU/видео.html Setting for stepper motor is here ruclips.net/video/Mh-itQEaeyM/видео.html It is possible just add the instruction for all the motor inside the "SWITCH-CASE" if the code doesn’t involves many lines/calculation. Otherwise keep the instruction for all the motor inside the main while loop.
@@NizarMohideen Hai again Mr. Nizar. I am just trying to set rcservo and dc motor. they speed and direction are controlling by irremote . what i need is pwm output for controlling mosfet gate because i need higher voltage and amperes later on. i have difficulties to set "Prescaler value and CounterPeriod value for rcservo and dc motor because both value are different. Are they setting have to use different timer setting?
Servo and DC motor works differently. As for DC motor, it is simple. You can just change the voltage level. In video-20, I have created 100Hz pwm (pwm frequency here can be any value) Since my timer clock was 8MHz, I divided first by prescalor of 128-1 and then counter period of 625, As for the servo, the pwm frequency has to be 50Hz. Since my timer clock was 8MHz, I divided first by prescalor of 16-1 and then counter period of 1000-1. If you see my simple servo video-27 and see the explanation below Since I set Counter Period 9999 for PWM, I can change Pulse from 0 to 9999. 0 being 0% and 9999 being 100% pulse width. __HAL_TIM_SET_COMPARE() is a macro to set the pulse on the fly. For the servo motor, I need 50 Hz signal Clock frequency = 8 000 000 Hz If I divide by Prescalor 16 Frequency = 8000000/16 = 500000Hz If I divide again by Counter period 10000 Frequency = 500000/10000 = 50Hz If it is 50Hz, The full pulse with time is = 1/50 seconds = 20 milli seconds For the servo motor, I need to change the pulse from 0.5 ms to 2.5ms Full 100% pulse is 10000 according to counter period 10000 0 → 0 20 milli seconds → 10000 So, 0.5 milli seconds → 250 and 2.5 milli seconds → 1250 So I can set __HAL_TIM_SET_COMPARE() from 250 to 1250
@@NizarMohideen Thank you for the explanation. actually i knew where you got the value. what i asked are they (servo and dc motor) put on different timer setting. in my case can i put on timer 2 for dc motor, and timer 3 for servo motor. so i can set each of prescaler value of them.
The purpose of this timer is to create 1MHz (1 microseconds) counter. As I have shown in this video, CubeIDE can be used to create these codes. These are auto generated codes. Thanks
Thank you so much.It did not work with 3.3v for me it worked with 5v.I have question. there is timer formula =timer mhz / (psc+1) * (arr+1) ;this why psc =71 but why arr is =65535 ? 72 000 000 / (71+1) * (65535 +1) it does not make any sense to me .i think it sould be 0 . therefore 72 000 000 /(71+1)* (0+1) ==> means 1 us.
Thanks for letting me know that it works with 5V As for the timer, I am using it to measure microsecond delay. Since the clock speed is 72MHz, I used 72-1 as prescalor to get one microsecond 1 microsecond = 1 / 1000000 Hz
Congratulations. As for the serial monitor equivalent, there are few ways you can achieve it. 1. You can use usb virtual com port to write messages as shown in video-64. Instead of using nodejs, you can use a serial monitor to view it 2. You can also use an uart to write serial messages. Use an ftdi and a serial monitor to view it 3. A simple and easy way is by declaring few variables and running in debug mode and then watching in the live expression as sown in video-16
This is by far the best tutorial on microcontrollers until now here in You Tube. Thanks a lot
You're very welcome!
can you also make video on how to transmit IR using STM32CubeIDE?
for me this method in cube ide so complicated compare to arduino ide. but slowly will follow in step by step. anyway thnk you for this video. really appreciated.
You are most welcome
Hi Sir,
I followed the similar steps with my nucleo G070 board but I couldn't get any results. Can you please suggest some required modifications.
Thankyou for the code and video, but fundamentals are not clear yet. Please guide.
1. Turning on the timer with Prescalar value 65535 = OK
2. Turn on edge triggered (Falling edge) interrupt on the IR remote signal pin (B11) = OK
3. Now when an falling edge triggered interrupt is initiated, since timer is already ON, how and where are we turning on the timer to measure the pulse width??
same query
Thanks for sharing your knowledge, very useful video, thanks a lot.
can you show how to install/setup STLINK OpenOCD, please....
regards
Alfredo
sir i didn't get the value ! where the function HAL_GPIO_EXTI_Callback calls ?
HAL_GPIO_EXTI_Callback does not calls any function.
Whenever pin PB11 goes from high to low, the function HAL_GPIO_EXTI_Callback is executed
Dear Mr. Nizar. I would like to add one dc motor, one rc-servo , and one stepper motor then control speed, direction using irremote setting in this video. the question are:
1. it is necessary to set the hardware configuration from beginning? if necessary how to do that?
2. It is possible just add the instruction for all the motor inside the "SWITCH-CASE" only?
thank you.
You can open the ioc file and add the settings for any new devices and save, it will generate new codes. Or, you can create new project and do the settings for all devices.
Setting for servo is here ruclips.net/video/h54DEslq-GI/видео.html
Setting for DC motor is here ruclips.net/video/0rbKmkNEdAU/видео.html
Setting for stepper motor is here ruclips.net/video/Mh-itQEaeyM/видео.html
It is possible just add the instruction for all the motor inside the "SWITCH-CASE" if the code doesn’t involves many lines/calculation. Otherwise keep the instruction for all the motor inside the main while loop.
@@NizarMohideen thank you sir.
@@NizarMohideen Hai again Mr. Nizar. I am just trying to set rcservo and dc motor. they speed and direction are controlling by irremote . what i need is pwm output for controlling mosfet gate because i need higher voltage and amperes later on. i have difficulties to set "Prescaler value and CounterPeriod value for rcservo and dc motor because both value are different. Are they setting have to use different timer setting?
Servo and DC motor works differently.
As for DC motor, it is simple. You can just change the voltage level. In video-20, I have created 100Hz pwm (pwm frequency here can be any value)
Since my timer clock was 8MHz, I divided first by prescalor of 128-1 and then counter period of 625,
As for the servo, the pwm frequency has to be 50Hz.
Since my timer clock was 8MHz, I divided first by prescalor of 16-1 and then counter period of 1000-1. If you see my simple servo video-27 and see the explanation below
Since I set Counter Period 9999 for PWM, I can change Pulse from 0 to 9999. 0 being 0% and 9999 being 100% pulse width. __HAL_TIM_SET_COMPARE() is a macro to set the pulse on the fly.
For the servo motor, I need 50 Hz signal
Clock frequency = 8 000 000 Hz
If I divide by Prescalor 16
Frequency = 8000000/16 = 500000Hz
If I divide again by Counter period 10000
Frequency = 500000/10000 = 50Hz
If it is 50Hz,
The full pulse with time is = 1/50 seconds = 20 milli seconds
For the servo motor, I need to change the pulse from 0.5 ms to 2.5ms
Full 100% pulse is 10000 according to counter period 10000
0 → 0
20 milli seconds → 10000
So, 0.5 milli seconds → 250
and 2.5 milli seconds → 1250
So I can set __HAL_TIM_SET_COMPARE() from 250 to 1250
@@NizarMohideen Thank you for the explanation. actually i knew where you got the value. what i asked are they (servo and dc motor) put on different timer setting. in my case can i put on timer 2 for dc motor, and timer 3 for servo motor. so i can set each of prescaler value of them.
Could you share the setting of this parameters ?
__HAL_RCC_GPIOA_CLK_ENABLE();
gpio_init_structure.Pin = GPIO_PIN_2;
gpio_init_structure.Mode = GPIO_MODE_IT_FALLING;
gpio_init_structure.Pull = GPIO_NOPULL;
gpio_init_structure.Speed = GPIO_SPEED_LOW;
HAL_GPIO_Init(GPIOA, &gpio_init_structure);
htim15.Init.Prescaler = 71;
htim15.Init.CounterMode = ?;
htim15.Init.Period = ?;
htim15.Init.ClockDivision = ?;
htim15.Init.RepetitionCounter = 0;
HAL_TIM_Base_Start(&htim15);
__HAL_TIM_SET_COUNTER(&htim15, 0);
The purpose of this timer is to create 1MHz (1 microseconds) counter.
As I have shown in this video, CubeIDE can be used to create these codes.
These are auto generated codes. Thanks
Thank you so much.It did not work with 3.3v for me it worked with 5v.I have question. there is timer formula =timer mhz / (psc+1) * (arr+1) ;this why psc =71 but why arr is =65535 ? 72 000 000 / (71+1) * (65535 +1) it does not make any sense to me .i think it sould be 0 . therefore 72 000 000 /(71+1)* (0+1) ==> means 1 us.
Thanks for letting me know that it works with 5V
As for the timer, I am using it to measure microsecond delay. Since the clock speed is 72MHz, I used 72-1 as prescalor to get one microsecond
1 microsecond = 1 / 1000000 Hz
@@NizarMohideen yes i got that part but why 65535 ?
Counter Period can be any large number. 65535 was the prefilled value from CubeIDE so I just left as it is.
The error message has gone, i follow and go through step by step then it was succed. Is there serial monitor in cubeide? thank you
Congratulations.
As for the serial monitor equivalent, there are few ways you can achieve it.
1. You can use usb virtual com port to write messages as shown in video-64. Instead of using nodejs, you can use a serial monitor to view it
2. You can also use an uart to write serial messages. Use an ftdi and a serial monitor to view it
3. A simple and easy way is by declaring few variables and running in debug mode and then watching in the live expression as sown in video-16
can Make video for decoding RC5 protocol ?
Tanke you
You are welcome
nice one
Thanks