i All
I have set up a PWM with a 16bit value duty cycle with a Period overflow of 3200 ....
when I start the simulation the duty cycle diagram have a strange behaviour, is working but de value is smaller that what should be.
I connected the board with a motor and looks is working fine , I do not understand if is something wrong on my code or if is a kind of bug.
I also made a super small file with only the PWM and a delay and I have the same result. If I use the 8 Bit value all looks good
I attached the file, I apologise for the Italian comments
PWM display for 16 bit value
Moderator: Benj
-
- Posts: 22
- Joined: Tue Jul 03, 2018 12:21 pm
- Location: Southam UK
- Has thanked: 4 times
- Been thanked: 2 times
PWM display for 16 bit value
- Attachments
-
- Controller_L298N_Base_Torque_1.fcfx
- (34.74 KiB) Downloaded 242 times
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: PWM display for 16 bit value
Hi zumpitu,
The period is the value required for 8bit PWM to have a duty of 100%
For 10bit PWM this value has to be x 4
So if period is 3200 for 100% duty:
For SetDuty8Bit = 3200
For SetDuty10Bit = 3200 x 4 = 12800
Martin
The period is the value required for 8bit PWM to have a duty of 100%
For 10bit PWM this value has to be x 4
So if period is 3200 for 100% duty:
For SetDuty8Bit = 3200
For SetDuty10Bit = 3200 x 4 = 12800
Martin
Martin
-
- Posts: 22
- Joined: Tue Jul 03, 2018 12:21 pm
- Location: Southam UK
- Has thanked: 4 times
- Been thanked: 2 times
Re: PWM display for 16 bit value
Hi medelec35
Ok I see, thank you , and actually it work on that way,
but is still think is strange because my board ( Nucleo F446RE ) have all 16 bit timer and 2 32bit with same resolution , so according the wiki

I also tried to use the Oscilloscope, but I still don't understand how to make it working, I'm going to do some research to how to use it , because looks very very useful.
Ok I see, thank you , and actually it work on that way,
but is still think is strange because my board ( Nucleo F446RE ) have all 16 bit timer and 2 32bit with same resolution , so according the wiki
This is why I'm was confusedSetDutyCycle10Bit
PIC/AVR - Sets the full scale PWM duty cycle based on the current period setting.
If period = 255 then Duty of 512 is equal to 50%.
16-bit PICs have a 16-bit period range available.
If period = 65535 then Duty of 32768 is equal to 50%.


I also tried to use the Oscilloscope, but I still don't understand how to make it working, I'm going to do some research to how to use it , because looks very very useful.
- Attachments
-
- STM32F446RE CIRCUIT DIAGRAM
- stm32f446xe_512k.jpg (217.48 KiB) Viewed 4668 times
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
Re: PWM display for 16 bit value
Hi zumpitu,
Yes, you are correct, there is a bug in the PWM simulation display, for ST ARM, I will have a look at fixing it
Leigh
Yes, you are correct, there is a bug in the PWM simulation display, for ST ARM, I will have a look at fixing it
This is correct for ST ARM too.16-bit PICs have a 16-bit period range available.
If period = 65535 then Duty of 32768 is equal to 50%.
Leigh
-
- Posts: 22
- Joined: Tue Jul 03, 2018 12:21 pm
- Location: Southam UK
- Has thanked: 4 times
- Been thanked: 2 times
Re: PWM display for 16 bit value
Hi LeighM
Then the function is working properly but is just the graphic that is not correct, Thank you for the info !
Nice to see that you are looking to fix it
Then the function is working properly but is just the graphic that is not correct, Thank you for the info !
Nice to see that you are looking to fix it