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
Pic's clock frequency => i need help
- Steve
- Matrix Staff
- Posts: 3424
- Joined: Tue Jan 03, 2006 3:59 pm
- Has thanked: 114 times
- Been thanked: 422 times
- Contact:
The other thing you could try is to use a 'C' code icon with a line of code similar to the following:
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).
Code: Select all
delay_us(10);
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).