|
Microcontroller › 8051 › Re: Project MC012 – Problems with code
thanks for you help earlier.
as u may see in the video : http://www.engineersgarage.com/microcontroller/8051projects/stopwatch-AT89C51-circuit
when the stop button is pressed it jumps a second.
How do i alter code to make it more accurate to max 9 seconds on display and rest in mili and micro seconds?
sir i saw the video on the link sent by you in the last post but i din’t see any kind of jump when the stop button is pressed…
Dear ‘dagakshay’ (and members),
If you look closley at the 0:10 mark on the video, you will see it goes from around 4.08seconds to 5.05 as soon as the stop button is pressed….
@Thomas
You are right about the jump thing. This happens because a human cannot press a switch for a precise duration and so the controller detects it continously for some time.
To prevent this and to take the input only once at a time you’ll need to add a small circuit for Edge Triggering. Check this link for an example of positive edge triggering. You can then modify your circuit accordingly.
yes thomas i think what nikhil saying is correct… but really a nice concept
Thanks for you reply Nikhil.
So you are saying the problem is NOT with the code?
Cause it on my cuircuit when i press it quickly the miliseconds is aprox correct just 1 second added… Even if i leave it for few seconds it consistantly jumps aprox 1 second.
I will add what you said onto the cuircuit and see what happens.
Thanks.
thomas just check and let us also know if that idea works…..
It doesnt work
Still getting a second jump…
Also how do I alter the code to display:
‘sec’ ‘milisec’ ‘milisec’ ‘milisec’ on the 4 7 segments
Instead of :
‘sec’ ‘sec’ milisec’ ‘milisec’
Eg want to display:
1. 275
1 second and 275 milliseconds
is this why thee is a second added on?
void mplex_delay(unsigned int time) // Function to provide a time delay of approximatelty one second using Timer 1
{
int i,j;
for (i=0;i<=time;i++)
for(j=0;j<=50;j++);
}
void digi_out(unsigned int current_num)
{
P2=digi_val[current_num];
mplex_delay(msec);
}
ya, this will not provide youi exact tym delay…
het y you not try your own code… use timers….
yh was adviced to do that before too…. problem is im not sure how to
check out the Timer tutorial
thnx. whats this code then? it does use timer too right?
ya even they do used the timers…
you just forget this one write a new on your own… it will mostly solve your problem….
you can also use RTC they are made especially for this porpose… but i never used it….
http://www.engineersgarage.com/electronic-components/rtc-ds12c887
http://www.engineersgarage.com/microcontroller/8051projects/interface-rtc-12c887-AT89C51-circuit
http://www.engineersgarage.com/microcontroller/8051projects/alarm-clock-rtc-12c887-AT89C51-circuit
thnx!
write a new one? wow… okay i’ll try…. i’ll give it a go before I come crawling back for help! i’ll need all the help later tho!
thanks again.