CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

runtime

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
tony
Guest







runtime
PostPosted: Thu Mar 11, 2004 9:49 am     Reply with quote

Hello,
i need to run a program for a specfic amount of time. e.g 5 secs, so i can calculate speed.

does anybody know the easiest way to do this,

will my counter still oerate when the counter is running or will it stop count to 5 and then move on to the next bit of code.

i'm using ccs, 16f877 and microchips ide board.

Thanks.
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Thu Mar 11, 2004 10:28 am     Reply with quote

What does your program do?

If you have any serial output and you record it with something like something like terminal by Br@y++ that can timestamp the incomming data, you can use the timestamps to check the speed of your program. Note that adding print statements to your program may slow it down a lot.
_________________
The search for better is endless. Instead simply find very good and get the job done.
Guest








PostPosted: Thu Mar 11, 2004 10:43 am     Reply with quote

its a speedo,

it counts the revolutions,

then there is a sum, but time is one of the factors in the sum
Thomas Blake



Joined: 18 Jan 2004
Posts: 22
Location: Burbank CA

View user's profile Send private message

time
PostPosted: Thu Mar 11, 2004 11:30 am     Reply with quote

Don't "run the program" for 5 seconds, run the counter/accumulator for 5 seconds.

Calculate the ints/second for the timer and clock speed you're using.
Compare it to the constant that equals 5 sec for that timer/clock.
If it's <, then continue to count and accumulate, else jump to an infinite loop or wait-for-switch loop.

Put thecounter/accumulator code in the main loop, not the timer interrupt handler. Use the timer/interrupt handler to set a go/stop flag instead.

Hope this helps.
Guest








PostPosted: Thu Mar 11, 2004 11:41 am     Reply with quote

you'll have to excuse my ignorance here i'm new enought pics.

i'm using a 20Mhz crytals,
so how would i calculate int ints/second.

by any chace would you have some examples of the code needed
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Thu Mar 11, 2004 1:52 pm     Reply with quote

time=seconds;
While(time==seconds);
time=seconds;
while(time+5>seconds)
{ On_Now=Input(pin);
if(On_Now && Was_Off) ++pulse count;
Was_Off=!On_Now;
}

Take this and add an interupt driven time keeper.
Guest








PostPosted: Fri Mar 12, 2004 10:28 am     Reply with quote

using the speed.c example i think i have solved my problem

setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);

long time;

set_timer1(0); // start counting


time=get_timer1();

now the only problem i have is trying to figure ou the follwoing line:

mph = 0.000009929*(float)time/3600.0; // calculate the time in hours
mph = distance/(63360.0*mph);

what is 0.000009929?
distance is a distance in inches and 63360=no of inches in a mile
Guest








PostPosted: Thu Apr 08, 2004 3:20 pm     Reply with quote

anybody??

i'm still having problems
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group