Variable frequency

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

Moderators: Benj, Mods

Post Reply
User avatar
vidor
Posts: 42
Joined: Mon Jan 28, 2008 4:56 pm
Location: Sweden

Variable frequency

Post by vidor »

Hi,

I have to thank for that great software!
I am developing AVR programs in Assembler and Pascal and a little C.
I've boght the pro version of Flowcode for AVR to develop applications faster and learn C too.
I managed to do some simple programs in no time at all, but I am stuck with a problem:
I want to do a PWM with variable frequency but no success.
I am using ADC0-value to change the Frequency... I've defined the DutyCycle for ~50%.
I can change the frequency, but the DutyCycle is changing too.
How can I achieve to vary the frequeqncy without changing the DutyCycle?

My best regards

Vidor

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: Variable frequency

Post by Benj »

Hello Vidor

Please could you send me your program and ill try to find out whats going wrong. My email is ben@matrixmultimedia.co.uk

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times

Re: Variable frequency

Post by Sean »

The PWM duty period and cycle period are both controlled seperately and regulated by the selected clock source. If the cycle period is to be changed, but the duty cycle is to be maintained, the duty period must be recalculated (based on the new cycle period).

An alternative method is to select different prescaler settings (5 settings available) or use an external, variable clock source, possibly using Timer2.

Post Reply