Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

24 second shotclock timer for basketball using C compiler

Status
Not open for further replies.

clarence501

Junior Member level 3
Joined
Jan 24, 2011
Messages
26
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Philippines
Activity points
1,463
Hey Guys, I really need your professional help right now. I'm making this 24 second shotclock timer for my project.
I have been able to make the source code for setting the 24 shot clock, using interrupt. But I'm stuck on how to do the timing. What I want to do is to set the shot clock either from 0-24 value and then when i switch RB4 == 1 and press the interrupt RB0 again, it will start counting. I don't know how to do that yet. Can you guys give me some professional Help? This is the ISIS circuit model: **broken link removed**

Here is my source code:

#include <pic.h>
int num = 0;

void initialize(void);
void timing(void);
void do_outputs(void);

void main(void)
{
initialize();
while(1)
{
do_outputs();
timing();
}

}
void initialize(void)
{
PORTC = 0x40;
PORTD = 0x40;
TRISC = 0x00;
TRISD = 0x00;
INTEDG = 0;
GIE = 1;
INTE = 1;
}

void timing(void)
{

}

void do_outputs(void)
{
GIE = 0;
if (INTF)
{
INTF = 0;
if((RB2==1) && (RB4==0))
{num++;}
if((RB2==0) && (RB4==0))
{num--;}
{
if(num==-1)
{
num=24;
PORTC = 0x10;
PORTD = 0x40;
}
if(num==0)
{
PORTC = 0x40;
PORTD = 0x40;
}
if(num==1)
{
PORTC = 0x79;
PORTD = 0x40;
}
if(num==2)
{
PORTC = 0x24;
PORTD = 0x40;
}
if(num==3)
{
PORTC = 0x30;
PORTD = 0x40;
}
if(num==4)
{
PORTC = 0x19;
PORTD = 0x40;
}
if(num==5)
{
PORTC = 0x12;
PORTD = 0x40;
}
if(num==6)
{
PORTC = 0x02;
PORTD = 0x40;
}
if(num==7)
{
PORTC = 0x78;
PORTD = 0x40;
}
if(num==8)
{
PORTC = 0x00;
PORTD = 0x40;
}
if(num==9)
{
PORTC = 0x10;
PORTD = 0x40;
}
if(num==10)
{
PORTC = 0x40;
PORTD = 0x79;
}
if(num==11)
{
PORTC = 0x79;
PORTD = 0x79;
}
if(num==12)
{
PORTC = 0x24;
PORTD = 0x79;
}
if(num==13)
{
PORTC = 0x30;
PORTD = 0x79;
}
if(num==14)
{
PORTC = 0x19;
PORTD = 0x79;
}
if(num==15)
{
PORTC = 0x12;
PORTD = 0x79;
}
if(num==16)
{
PORTC = 0x02;
PORTD = 0x79;
}
if(num==17)
{
PORTC = 0x78;
PORTD = 0x79;
}
if(num==18)
{
PORTC = 0x00;
PORTD = 0x79;
}
if(num==19)
{
PORTC = 0x10;
PORTD = 0x79;
}
if(num==20)
{
PORTC = 0x40;
PORTD = 0x24;
}
if(num==21)
{
PORTC = 0x79;
PORTD = 0x24;
}
if(num==22)
{
PORTC = 0x24;
PORTD = 0x24;
}
if(num==23)
{
PORTC = 0x30;
PORTD = 0x24;
}
if(num==24)
{
PORTC = 0x19;
PORTD = 0x24;
}
if(num==25)
{
PORTC = 0x40;
PORTD = 0x40;
num = 0;
}
}
GIE =1;
}
}
 

Can't help with ISIS, I've never used it but your schematic will not work. You must at least make these changes:

1. add current limiting resisors in each segment connection of both displays.
2. add decoupling capacitors across the all the supply pins
3. add clock components, the 877a does not have an internal clock generator
4. tie /MCLR high, preferably through a resistor.

Also you may have to debounce the switch contacts, either in hardware or software.
The software would be far smaller and easier to maintain if you put the segment values into an array, for example "digit_1[10] = {0x10,0x40,0x79...};" so you could set the displayed digit by using something like "digit_1[2]; digit_2[3];" to show "23". It also makes the calculation of which digit to display much simpler. You are also missing code to actually time the seconds, it looks as though you intend to use timer interrupts but the ISR is missing.

Brian.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top