Hi Team
It seems that I can not use the full range of the PWM on PIC32 as I can only adjust the Period and duty similar to a PIC8
I would expect to be able to adjust between 0 -65535 and not only 255
My apologies if my understanding is incorrect
Thank you for looking into this
PIC32 PWM Component
Moderator: Benj
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
PIC32 PWM Component
- Attachments
-
- 1.JPG (59.25 KiB) Viewed 10085 times
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: PIC32 PWM Component
Hello Peter,
Yes the PWM on the PIC32 should be 16-bit.
I believe I have found and fixed the problem now.
The Period should default to 255 but can now be edited up to 65535.
Use the SetDuty10Bit macro to assign a duty over the range 0-255.
Let me know how you get on.
Yes the PWM on the PIC32 should be 16-bit.
I believe I have found and fixed the problem now.
The Period should default to 255 but can now be edited up to 65535.
Use the SetDuty10Bit macro to assign a duty over the range 0-255.
Let me know how you get on.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: PIC32 PWM Component
Hello Ben
Thank you very much for the help, I will let you know how I get along
Thank you very much for the help, I will let you know how I get along
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: PIC32 PWM Component
Hi Ben,
The PWM pin now is active however we still have some issues or misunderstanding from my side ,
As you will see in the Flowchart I enable the PWM pin and I set the following in the properties
(1) the period to 20 000 which shows a time of 500 uSec as expected( I want 2Khz)
(2) set the Timer to Timer2
(3) do a 8bit avarage on a adc pin and load this 0-255 value to the DC regsiter ( I also loaded fix value of 127 and 255 )
The results as you will see in the scope prints
(1) the Frequency or period is double the expected so my 2Khz i2 4 Khz
(2) The duty cycle never goes bigger than 2.9 uSec about 2% max of the period
Note: I am sure I get the 255 in the adc8Bit value as when I display this variable in PORTD I can light up all 8 Leds and any numer down to 0
Sorry if I am doing something wrong
The PWM pin now is active however we still have some issues or misunderstanding from my side ,
As you will see in the Flowchart I enable the PWM pin and I set the following in the properties
(1) the period to 20 000 which shows a time of 500 uSec as expected( I want 2Khz)
(2) set the Timer to Timer2
(3) do a 8bit avarage on a adc pin and load this 0-255 value to the DC regsiter ( I also loaded fix value of 127 and 255 )
The results as you will see in the scope prints
(1) the Frequency or period is double the expected so my 2Khz i2 4 Khz
(2) The duty cycle never goes bigger than 2.9 uSec about 2% max of the period
Note: I am sure I get the 255 in the adc8Bit value as when I display this variable in PORTD I can light up all 8 Leds and any numer down to 0
Sorry if I am doing something wrong
- Attachments
-
- 4.JPG (18.71 KiB) Viewed 10036 times
-
- 3.JPG (36.9 KiB) Viewed 10036 times
-
- 2.JPG (55.13 KiB) Viewed 10036 times
-
- 1.JPG (65.02 KiB) Viewed 10036 times
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: PIC32 PWM Component
Thanks Peter,
Sounds like another bug to me, should be easy to solve so I'll get on it.
Sounds like another bug to me, should be easy to solve so I'll get on it.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: PIC32 PWM Component
Hi Peter,
Right here is another component fix which hopefully better reflects what the PIC32 PWM hardware is doing.
Let me know how you get on.
Right here is another component fix which hopefully better reflects what the PIC32 PWM hardware is doing.
Let me know how you get on.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: PIC32 PWM Component
Hi Ben;
Thank you very much this file is working fine the following observations
(1) The perioad fit exactly to the setting in PWM properties
(2) The Duty cycle does not work with values between 0 -and 255 as you mentioned in a previous post
In my understanding from the PIC32 the Duty cycle value must match the Period value to achieve 100% Duty cycle
there for when I apply a value between 0 and the 40000 which is the period cycle or value I can scale the Duty cycle exactly between 0 and 100%
I achievde this by doing a 10 bit ADC read(0 -1023) and mulitiply by 40 which is for a fast test 0 -40000 (also load 40000 directly to the setDutycycle Function )
in C code and there it works as I mentioned above and now in FC also like it is now with the last file you posted
Many Thanks once again.
Have good one
Thank you very much this file is working fine the following observations
(1) The perioad fit exactly to the setting in PWM properties
(2) The Duty cycle does not work with values between 0 -and 255 as you mentioned in a previous post
In my understanding from the PIC32 the Duty cycle value must match the Period value to achieve 100% Duty cycle
there for when I apply a value between 0 and the 40000 which is the period cycle or value I can scale the Duty cycle exactly between 0 and 100%
I achievde this by doing a 10 bit ADC read(0 -1023) and mulitiply by 40 which is for a fast test 0 -40000 (also load 40000 directly to the setDutycycle Function )
I am only concerned if the setDutycycle() function expects 0-255 then something is still wrong however my asuption above is based on my experience using the PWMBenj wrote: Use the SetDuty10Bit macro to assign a duty over the range 0-255.
in C code and there it works as I mentioned above and now in FC also like it is now with the last file you posted
Many Thanks once again.
Have good one
- Attachments
-
- 1.JPG (49.31 KiB) Viewed 9968 times
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR