Pic's clock frequency => i need help

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

Moderators: Benj, Mods

Post Reply
Bboytom
Posts: 1
Joined: Wed Apr 12, 2006 1:18 pm
Contact:

Pic's clock frequency => i need help

Post by Bboytom »

Hello,
I'm a french student, that's why my english is very bad.
I currently work on Flowcode v2 for a PIC 16F84.
I would like to know how to increment a variable on each PIC's instruction cycle. Indeed, i need a variable "square" signal in order to make a motor's speed vary. In other words, i need a flexible width of impulse in a fixed frequency of about 1kHz. This is why i can't use delays because there's no so little delay.
I thought of a program as following

C_Max=Y (Y preset)
PW=X (X preset by an other program)
Outer Loop
C=0
Inner Loop C<PW
C=C+1
Output =1
End of inner loop
Inner Loop C<C_Max
C=C+1
Output=0
End of Inner Loop
End of outer loop

What do you think of that?
Have you got other solutions?
Thanks by advance

Ian
Posts: 110
Joined: Thu Sep 29, 2005 10:53 am
Location: Matrix Multimedia
Been thanked: 1 time
Contact:

Post by Ian »

Have a look at the interrupt timer macro as you can use that to trigger events at set intervals.

Set the correct clock speed for the oscillator (clock crystal) that you are using.
You can use the prescaler to adjust the timing frequency to a convenient one.

User avatar
Steve
Matrix Staff
Posts: 3424
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Post by Steve »

The other thing you could try is to use a 'C' code icon with a line of code similar to the following:

Code: Select all

delay_us(10);
This should give a delay of approx 10 microseconds.

You can use variables here as well, but make sure you prefix any FlowCode variable name with "FCV_" (e.g. if you have a variable "VAR" in FlowCode, refer to it as "FCV_VAR" in any 'C' code you use).

Post Reply