Page 1 of 1

delay limitations

Posted: Wed Mar 26, 2008 11:33 am
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

Re: delay limitations

Posted: Wed Mar 26, 2008 11:54 am
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.

Re: delay limitations

Posted: Wed Mar 26, 2008 10:19 pm
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.

Re: delay limitations

Posted: Thu Mar 27, 2008 11:15 am
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);

Re: delay limitations

Posted: Wed May 07, 2008 11:38 pm
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

Re: delay limitations

Posted: Thu May 08, 2008 10:00 am
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??]

Re: delay limitations

Posted: Fri May 09, 2008 5:12 pm
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

Re: delay limitations

Posted: Fri May 09, 2008 5:25 pm
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!!!

Re: delay limitations

Posted: Fri May 09, 2008 5:57 pm
by jimhumphries
Steve:

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

Jim

Re: delay limitations

Posted: Fri May 09, 2008 8:41 pm
by Steve
Unfortunately, it's 90% of the work to do the basics!!

Re: delay limitations

Posted: Sat May 10, 2008 5:00 pm
by jimhumphries
Steve,

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

Jim