Delays

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

Moderators: Benj, Mods

Post Reply
echase
Posts: 429
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times

Delays

Post by echase »

How does Flowcode proramme delays? E.g. if I set a 4 second delay I assume the code in the PIC runs around a dummy loop lots of times until about 4 secs are up. How accurate is it?

If I add a TMR0 interrupt at 15Hz to do another short macro this will interrupt this delay about 60 times and so presumably slow it down. Is that right or does the delay auto compensate for the interrupt time

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

Post by Benj »

Hello

The delays are based on clock speed. If your clock speed is accurate then the delays will also be accurate or at least down to the nearest micro/nano second. Clocks generated from ceramic resonators, RC circuits or internal oscillators will generally be fairly inaccurate. If you give me your clock speed and the delay time then I can work out the error for an accurate crystal.

Unfortunatly the interrupt routine will indeed slow down the delay. You can look at the casm file generated from flowcode and work out exactly how many assembler commands there are in your interrupt routine. This will let you know exactly what the slow down amount will be over a second so you can compensate if need be.

echase
Posts: 429
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times

Re: Delays

Post by echase »

I am using a 4 second and four 150mS delays with a 250kHz internal precision clock. How accurate is that? Thought that clock was pretty accurate even though it's not a crystal one.

The reason for the four 150mS delays is that I discovered rather too late that Flowcode doesn’t appear to process a number higher than 255. Any chance of an error message if a user attempts to enter a higher number? Far as I can tell entering say 900mS just truncates to 255 or is it 900-3*255?

My June EPE article is in newsagents this week with you guys mentioned.

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

Re: Delays

Post by Steve »

A delay of 900ms will automatically be converted to 3 delay_ms(255) plus 1 delay_ms(135).

I think when a variable is used, it may work differently.

By the way, I saw the article. It looks like a massive project! Oh, and thanks for the mention... Glad we could help.

echase
Posts: 429
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times

Re: Delays

Post by echase »

Yes a massive project for me. Hence lots of questions!

I was using a variable preset in the boot routine to between 500 and 999ms and am pretty certain it was not correctly calculating it. I can see that an error message is difficult when a variable is used as Flowcode does not know the variable value.

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

Post by Benj »

Hello,

Thanks for the mention looking forward to reading the article.

When using a variable delay you can do something similar to the following where delayval is your INT delay variable.

calc: delayval = 800

loop: delayval > 255
{

delayms: 255

calc: delayval = delayval - 255

}

delayms: delayval

Post Reply