delay limitations

Any general or miscellaneous queries that do not fit into the other forum catagories

Moderators: Benj, Mods

Post Reply
Timo
Posts: 7
Joined: Tue Nov 06, 2007 8:42 pm
Location: Northumberland
Contact:

delay limitations

Post by Timo »

I understand that the delay icon in Flowcode will not allow delays of less than 1ms to be generated and for those such as myself wishing to use microsecond delays (for servo driving) it is necessary to insert a block of C code. What I don’t understand is why this is the case and how to create the necessary C code.
Can you supply an example of a C code routine for this?
Understanding this anomaly would be of great assistance.

Tim
Regards,
Tim

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 limitations

Post by Benj »

Hello Tim

There is a microsecond command but this has not been implemented into Flowcode as of yet as it does not work for all clock speeds.

The C code command is

Code: Select all

delay_us(1); //Delay for 1 microsecond
delay_us(50); //Delay for 50 microseconds
A more reliable approach is to use delays of 10 microseconds as this works for all clock speeds.

Code: Select all

delay_10us(1); //Delay for 10 microseconds
delay_10us(50); //Delay for 500 microseconds
Hope this helps.

Timo
Posts: 7
Joined: Tue Nov 06, 2007 8:42 pm
Location: Northumberland
Contact:

Re: delay limitations

Post by Timo »

Thanks for that Ben, it was helpful but say I want to assign a variable called DELAY in the main Flowcode prog. to the delay value how would that appear in the C code module?
Would it be something like:

delay_FCV_DELAYus(FCV_DELAY)); //Delay for DELAY variable amount

The bit in parenthesis looks dodgy.
My concern is that since it's not possible to simulate the C module within FC, the C code syntax etc. has to be spot-on before compiling to chip.
Regards,
Tim

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 limitations

Post by Benj »

Hello Tim

In Flowcode say you have a variable called count.

Then the C code would be,

Code: Select all

delay_us(FCV_COUNT);
delay_10us(FCV_COUNT);

jimhumphries
Posts: 112
Joined: Wed Oct 12, 2005 6:29 pm
Location: USA
Been thanked: 1 time
Contact:

Re: delay limitations

Post by jimhumphries »

Ben:

Is there a plan to add the 10 uS delay feature to the Delay component in V4 while maintaining the Sec and mSec choices? Having to pick uS delays that are multiples of 10 would be fine for my applications.

Jim

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

Re: delay limitations

Post by Steve »

Hi Jim,

Yes - we'll probably add this feature to v4.

[Hey - this is my 1000th post. Do I get a medal or something??]

jimhumphries
Posts: 112
Joined: Wed Oct 12, 2005 6:29 pm
Location: USA
Been thanked: 1 time
Contact:

Re: delay limitations

Post by jimhumphries »

Steve:

1000 posts - you sure get a medal in my book!! This is probably a good time to thank you for all of the assistance you have given to me over the past few years in getting my application(s) going in Flowcode - it just keeps getting better!

That would be great if V4 would allow for uS delays (albeit in 10 uS increments). Somewhat off topic (now that I have buttered you up) but the next big thing for me will be availability of floating point math for the PICs. I take it that will roll out with V4 also. Any chance we could see that any sooner as a V3 update?

Jim

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

Re: delay limitations

Post by Steve »

Consider me truly buttered-up!

It may be possible to implement fp in Flowcode PIC as an update - I'll look into it. But what I really want to do is crack on with the v4 work - there's a lot to get through!!!

jimhumphries
Posts: 112
Joined: Wed Oct 12, 2005 6:29 pm
Location: USA
Been thanked: 1 time
Contact:

Re: delay limitations

Post by jimhumphries »

Steve:

Just the basics (+-x/) is all I ask. Nothing fancy like arctan :)

Jim

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

Re: delay limitations

Post by Steve »

Unfortunately, it's 90% of the work to do the basics!!

jimhumphries
Posts: 112
Joined: Wed Oct 12, 2005 6:29 pm
Location: USA
Been thanked: 1 time
Contact:

Re: delay limitations

Post by jimhumphries »

Steve,

How right you are but then again the basics will do 90% of the work!

Jim

Post Reply