Yes, you can fix the duty cycle at any value you want between 0 and 100%. If you leave the duty cycle at 0, the signal will be off, zero. If you leave it at 100% , the signal will be 5V continuous
@@CMTEQ no, i see on the mc workbench is pulse=0 sir. What is that mean?? Because i used for motor control, and i want to fix the pwm on 50 or 70% sir.
@@CMTEQ i dont know, because the code from x cube mcsdk, that is deferent with code from cube mx sir. In cube mx i can set the ccr, but on mc sdk i see on the code is (pwm_duty) / 2; like that sir. Not the fix number like 1000 or semilar
Your content is great, but just ONE reminder about like/subscribe somewhere in your video is all you need. Having random animations appear over your video with tones takes away from your content! Anyways, your work here has saved me many hours of research, and I am a happy subscriber!
In my case, I am using an external oscillator to generate the system clock. However, I'm not finding an option to select the external clock as the source. What should I do? i am using cubeMX tool to configure?
Yes that is correct. I'm doing a simple GND reference measurement. Scope croc clip connected to GND(Black Wire) and Scope Channel 1 (Yellow) probe connected to Red wire D11.
@@CMTEQThank you so much! I am currently using PWM for this STM (and this code) and with Escon 50/5 motor driver. What wiring set up would you recommend? I connected PWM/D11 to the Input PWM pin on Escon. What about the ground & power supply connections?
Hi Ashlee, if your Escon 50/5 motor driver and stm32 board are sharing the same power supply then you can connect your Escon 50/5 motor driver GND to the same GND black wire on your stm32 or on your power supply, while keeping the PWM Pin connected on the Escon PWM input. You should be able to control your motor. If you need more assistance, like schematic and hardware connection, you can consider joining my low voltage membership, I will provide you technical assistance.
hi mate how about like this??? Code: htim1.Init.Period = ((PWM_PERIOD_CYCLES) / 2); Code: sConfigOC.Pulse = (uint32_t)(((PWM_PERIOD_CYCLES) / 2) * 0.6); It will working?? So no need set pwmc setphasavoltage, because global pwm duty (pulse) already set max 60%?? Or this will set all tim for 60% sir?? Any idea?? Thank u@@CMTEQ
Hi thank you for your feedback. If you want to generate a 400kHz frequency you just need to play with the Prescaler and period value, I mentioned it in the video. So for 400kHz you can setup your values as follow prescaler = 20 and period = 7. depending on measuring equipment you might not get the exact 400kHz, if thats the case you can decrease the prescaler = 19. Please note that this is based on the 64MHz clock frequency if your frequency is higher or less than you just need to play with the period and prescaler value until you get your desired frequency,.
Mate.. You are the best, This is the most underrated channel ever@@CMTEQ . I have achieved 400khz freq. THanks to you. Now i am trying to create a function that gets uint32_t input data from user and converts into pwm signals with logical 1 having 70% high and 30% low and logical 0 -vice versa. Can you help me?
That sound very easy to implement. I'm not sure which method you gonna use to get user input, buttons/keyboard etc... But you can first create a function that increment your uint32_t var locally and pass it into your Timer Init function to change the duty cycle value. Once you have that working you should see your pwm duty cycle change automatically as the code runs. Once you are satisfied you can then get the value externally by a user, sound like a nice project, an LCD would be a great addidtion to see whats going on. Time is always an issue, the best way to get assitance fast is by become the channel member.
Hi, by sideway I believe you mean shifting left or right, leaving the Frequency and period fixed, you can probably achieve that by playing with the Duty Cycle, you can either halve or double the high time. Try playing with those values and see what you get.
Hi, Thank you for your humorous comment. A square wave is a PWM signal with a constant duty cycle and amplitude. More control can be introduced, like changing the duty cycle periodically in the code to achieve the desired modulation.
If you ❤ my content and find it helpful, please Subscribe and hit the Bell 🔔
👇 SUBSCRIBE TO CMTEQ CHANNEL NOW 👇
th-cam.com/users/CMTEQ
Hi mate, can wi fix the pwm duty cycle is 50% or 70%??
Or if we leaf the pulse to 0 is what happen???
Yes, you can fix the duty cycle at any value you want between 0 and 100%.
If you leave the duty cycle at 0, the signal will be off, zero. If you leave it at 100% , the signal will be 5V continuous
@@CMTEQ no, i see on the mc workbench is pulse=0 sir. What is that mean?? Because i used for motor control, and i want to fix the pwm on 50 or 70% sir.
@@botak333 Hi, did you come right with your test for 50% PWM Duty cycle?
@@CMTEQ i dont know, because the code from x cube mcsdk, that is deferent with code from cube mx sir. In cube mx i can set the ccr, but on mc sdk i see on the code is (pwm_duty) / 2; like that sir. Not the fix number like 1000 or semilar
I just saw 1/4 video and I'm already serious thinking about subscribing rn, what a nice and useful video, right what I needed
Thank you, I'm glad it was useful
Very good video, underrated in every way, ai needed some explanation on pwm
Thank you for your feedback. Please support by sharing, much appreciated 🙏.
Your content is great, but just ONE reminder about like/subscribe somewhere in your video is all you need. Having random animations appear over your video with tones takes away from your content!
Anyways, your work here has saved me many hours of research, and I am a happy subscriber!
Hi William, Thank you for the feedback, well Noted.
This video was very useful!! Thanks!!
You are most welcome !
In my case, I am using an external oscillator to generate the system clock. However, I'm not finding an option to select the external clock as the source. What should I do? i am using cubeMX tool to configure?
Hi, I will have a look later. Please check my video on clock configuration. th-cam.com/video/CUgPXt4JE_c/w-d-xo.html
Are the terminals from GND (black wire) and PWM/D11 (red wire) both directly connected to the oscilloscope? What is your wiring set up?
Yes that is correct. I'm doing a simple GND reference measurement. Scope croc clip connected to GND(Black Wire) and Scope Channel 1 (Yellow) probe connected to Red wire D11.
@@CMTEQThank you so much! I am currently using PWM for this STM (and this code) and with Escon 50/5 motor driver. What wiring set up would you recommend? I connected PWM/D11 to the Input PWM pin on Escon. What about the ground & power supply connections?
Hi Ashlee, if your Escon 50/5 motor driver and stm32 board are sharing the same power supply then you can connect your Escon 50/5 motor driver GND to the same GND black wire on your stm32 or on your power supply, while keeping the PWM Pin connected on the Escon PWM input. You should be able to control your motor.
If you need more assistance, like schematic and hardware connection, you can consider joining my low voltage membership, I will provide you technical assistance.
@@CMTEQ I will look into your membership! Thanks again. :)
hi mate how about like this???
Code:
htim1.Init.Period = ((PWM_PERIOD_CYCLES) / 2);
Code:
sConfigOC.Pulse = (uint32_t)(((PWM_PERIOD_CYCLES) / 2) * 0.6);
It will working?? So no need set pwmc setphasavoltage, because global pwm duty (pulse) already set max 60%??
Or this will set all tim for 60% sir??
Any idea?? Thank u@@CMTEQ
Very helpful !!
Great 👍, I'm glad it was helpful
Fantastic video mate !! . What should be the prescaler and period value if i want to have a frequency of 400khz?
Hi thank you for your feedback.
If you want to generate a 400kHz frequency you just need to play with the Prescaler and period value, I mentioned it in the video.
So for 400kHz you can setup your values as follow prescaler = 20 and period = 7. depending on measuring equipment you might not get the exact 400kHz, if thats the case you can decrease the prescaler = 19.
Please note that this is based on the 64MHz clock frequency if your frequency is higher or less than you just need to play with the period and prescaler value until you get your desired frequency,.
Mate.. You are the best, This is the most underrated channel ever@@CMTEQ . I have achieved 400khz freq. THanks to you. Now i am trying to create a function that gets uint32_t input data from user and converts into pwm signals with logical 1 having 70% high and 30% low and logical 0 -vice versa. Can you help me?
That sound very easy to implement. I'm not sure which method you gonna use to get user input, buttons/keyboard etc...
But you can first create a function that increment your uint32_t var locally and pass it into your Timer Init function to change the duty cycle value. Once you have that working you should see your pwm duty cycle change automatically as the code runs.
Once you are satisfied you can then get the value externally by a user, sound like a nice project, an LCD would be a great addidtion to see whats going on.
Time is always an issue, the best way to get assitance fast is by become the channel member.
Can we shift the pwm sideways by 50% of the counter period?
Hi, by sideway I believe you mean shifting left or right, leaving the Frequency and period fixed, you can probably achieve that by playing with the Duty Cycle, you can either halve or double the high time. Try playing with those values and see what you get.
can you please share the code
Hi, I have attached the main.c file under the video description. Try to follow the tutorial you should be able to produce the same PWM signal.
Analyze PWM signal using SIGLENT SDS 1104X-E Digital Storage Oscilloscope
th-cam.com/video/-PA0lr3GyAQ/w-d-xo.html
The pulse width wasn't being modulated here lol you just showed how to generate a square wave.
Hi, Thank you for your humorous comment.
A square wave is a PWM signal with a constant duty cycle and amplitude. More control can be introduced, like changing the duty cycle periodically in the code to achieve the desired modulation.