Pumpkin, Inc.

Pumpkin User Forums

Time accuracy in Salvo

If you can't make Salvo do what you want it to do, post it here.

Time accuracy in Salvo

Postby luben » Fri Nov 24, 2000 7:34 am


One another question - if my time slice is for example 10ms, what is the accuracy of this time. I mean, how exactly is the time. I know that you use timer interrupts, but if some other events occure this time could be changed a little bit. I'm sure that this is not one machine cycle (for 10ms). I'm sure that your timing is very accurate, just asking - how much +/- cycles (for some high precision time projects).

Luben Christov

Posts: 324
Joined: Sun Nov 19, 2000 12:00 am
Location: Sofia, Bulgaria

Re: Time accuracy in Salvo

Postby Salvo Tech Support » Sat Nov 25, 2000 12:57 pm

The accuracy of the timer has two components -- that of the system tick counter, and that of time-based Salvo task services (e.g. OS_Delay()).

1. The accuracy of the system tick counter is dependent on your interrupt service routine (ISR). Since the system timer can be read via OSGetTicks() from anywhere (not just from inside a task), it's up to you, the user, to provide an ISR with as little jitter as possible to call OSTimer().

Your (user) code might look something like this on a PIC16C77:

void interrupt IntVector(void)
if ( TMR2IF && TMR2IE )
TMR2IF = 0;

The jitter of this ISR will depend primarily on the longest time that interrupts are disabled. For example, assuming that Salvo disables interrupts longer than any other part of your program, then a Salvo application with a couple of tasks might disable interrupts for a maximum of 120 cycles. On a 4MHz PIC, that means 120us, which means that the accuracy of the system tick counter will vary <1.5% from 10ms.

2. Now we look at what happens with OS_Delay(). If we have:

void Task7 (void)
for (;;)

which means we want a 10ms delay in Task7(), then there are two extreme cases: 1) OS_Delay(1) happens just before the timer interrupt -- then the delay will be very short, say, only 1ms; or 2) OS_Delay(1) happens just after the timer interrupt, in which case the delay will be approximately 10ms. Therefore task delays have an inherent accuracy of +0, -1 timer ticks.

Also, keep in mind that even after the delay in Task7() above expires, the task will not run again until it is the highest-priority eligible task -- it may be blocked by other, higher-priority tasks, which will increase the delay.

Chapter 6 FAQ of the User Manual contains additional information on the Timer.

[This message has been edited by Salvo Tech Support (edited November 25, 2000).]

Salvo Technical Support
Please request all tech support through the Forums.
Salvo Tech Support
Posts: 173
Joined: Sun Nov 19, 2000 12:00 am

Return to Coding

Who is online

Users browsing this forum: No registered users and 2 guests