Help PWM Change Period

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
Gestaltening
Posts: 5
Joined: Thu Feb 07, 2013 10:42 pm
Contact:

Help PWM Change Period

Post by Gestaltening »

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
Attachments
PWM_PeriodTest.fcfx
(7.38 KiB) Downloaded 303 times

User avatar
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

Post by Benj »

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.

Gestaltening
Posts: 5
Joined: Thu Feb 07, 2013 10:42 pm
Contact:

Re: Help PWM Change Period

Post by Gestaltening »

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?

User avatar
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

Post by Benj »

Hello,

In the compiler output there should be a warning message like this.
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"
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.

Post Reply