delay

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

Moderators: Benj, Mods

Post Reply
franky
Posts: 49
Joined: Tue Jan 13, 2009 7:23 pm

delay

Post by franky »

hi,
i'm using flowcode V3 and ecio40, but i need to use a delay less than 1ms.. how can i do?
thanks!

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

Re: delay

Post by Sean »

Hello Franky,

The C compiler supports shorter delays.

You will need to add a C Code icon to your flowchart and enter something similar to the following code:

delay_10us(12);

This would generate a 120us delay.

There is a delay_us() function that works in a similar way, but the C compiler will not accept it unless the clock frequency can be divided exactly.

You can pass Flowcode variables to these functions if required. Example:

A global Flowcode variable, Var1, would be declared as FCV_VAR1 in the C code - delay_10us(FCV_VAR1);

A local (macro) Flowcode variable, Var2, would be declared as FCL_VAR2 in the C code.

franky
Posts: 49
Joined: Tue Jan 13, 2009 7:23 pm

Re: delay

Post by franky »

thank you sean,
but can you post an example for fc V3?
waiting for your kind reply.

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: delay

Post by Benj »

Hello Franky

You simply need to add a C code icon to your program and then add the following to the contents of the icon.

delay_10us(x);

Where x is the number of micro seconds x 10 you wish to delay for.

Alternativly there is

delay_us(x);

Where x is the number of micro seconds you wish to delay for. In v3 the clock speed must divide exactly to allow this function to compile.

franky
Posts: 49
Joined: Tue Jan 13, 2009 7:23 pm

Re: delay

Post by franky »

thak you benj!
i'll go to try.

franky
Posts: 49
Joined: Tue Jan 13, 2009 7:23 pm

Re: delay

Post by franky »

hi benj,
i have tryed yor solution but when i try to compile show me this error "C:\Users\FRANKY\Desktop\_SERVO\test servo.c(286): error: missing semicolon
test servo.c failure"

how can i solve it?

a lot of thanks!

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: delay

Post by medelec35 »

When you use a C block, and place a statement e.g. delay_10us(15); notice the semicolon after the bracket, that's missing. Just add it and recompile.
Each C statment requires a semicolon (;) at the end.
Martin

franky
Posts: 49
Joined: Tue Jan 13, 2009 7:23 pm

Re: delay

Post by franky »

you are right medelec!
thank you very much!!

franky
Posts: 49
Joined: Tue Jan 13, 2009 7:23 pm

Re: delay

Post by franky »

hi at all!,

i have another question.. how can i do to pass a global Flowcode variable, "time" in the C code when i use the delay_10us function?

thank you very much!

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

Re: delay

Post by Steve »

Global FLowcode variables such as "time" become "FCV_TIME" in C code.

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: delay

Post by Benj »

Hello

If time is a byte variable then you would use like this...

Code: Select all

delay_10us(FCV_TIME);
Otherwise you would use like this.

Code: Select all

while (FCV_TIME > 255)
{
 FCV_TIME = FCV_TIME - 255;
 delay_10us(255);
}
delay_10us(FCV_TIME);

franky
Posts: 49
Joined: Tue Jan 13, 2009 7:23 pm

Re: delay

Post by franky »

thank you so much to everybody!!!

Post Reply