Hi,
I have a problem trying to work with PWM and change period on flowed the simulation appears ok, but when download to arduino uno, there is no change, when monitoring with oscilloscope the cycle is the only change.
I attach a potentiometer to AN3 with variable VELM1 (0-255 bytes), then PWM ChangePeriod take the variable VELM1, and for prescaler is 8, after that I have a SetDutyCycle with this calculation (VELM1-2)/2, to have 50% Cycle.
I Hope my explanation is ok.
Attached is the file for review
Best
Cesar
Help PWM Change Period
Moderator: Benj
-
- Posts: 5
- Joined: Thu Feb 07, 2013 10:42 pm
- Contact:
- 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: Help PWM Change Period
Hello Cesar,
You might want to include a delay in the loop so you are not continually updating the PWM control registers at high speed. Hopefully that will help.
If not then let me know and I will look at the underlying C code to make sure it is changing the period register correctly.
You might want to include a delay in the loop so you are not continually updating the PWM control registers at high speed. Hopefully that will help.
If not then let me know and I will look at the underlying C code to make sure it is changing the period register correctly.
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
-
- Posts: 5
- Joined: Thu Feb 07, 2013 10:42 pm
- Contact:
Re: Help PWM Change Period
Hi Benj,
Thanks for the help, I try your idea with different options, but when see on oscilloscope only modify the cycle, do you have any other idea?
Thanks for the help, I try your idea with different options, but when see on oscilloscope only modify the cycle, do you have any other idea?
- 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: Help PWM Change Period
Hello,
In the compiler output there should be a warning message like this.
In the compiler output there should be a warning message like this.
You could instead try changing the PWM properties to use channel 3 which uses timer 1 as the clock source and seems to have the period registers. This seems to work correctly.C:\Program Files (x86)\Flowcode 6\CAL\/AVR\AVR_CAL_PWM.c:105:5: warning: #warning "PWM Channel Uses Resource Timer 0"
C:\Program Files (x86)\Flowcode 6\CAL\/AVR\AVR_CAL_PWM.c:449:3: warning: #warning "Period control register not available on target device, period will default to 255 + 1"
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