NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Everything Else » Basketball Scoreboard/Clock Project

April 29, 2013
by Keyster
Keyster's Avatar

Here is a picture of my newest project so far. I have the front panel done and am now installing the electronics on the back. The top scoreboard is the "sample" i am going by. This is going to be a clock in my man cave (garage). The top section will be hours and minutes. The "home" score will be seconds and the "guest" score will be temperature and humidity. The "period" section will be "A" or "P" (AM or PM).

I am linking the picture to facebook which I have never tried before. If the picture does not work I will fix it tonight from home. (is it working fine in the preview window)

scoreboard project

April 29, 2013
by pcbolt
pcbolt's Avatar

That looks awesome...

April 29, 2013
by xodin
xodin's Avatar

Cool project. You could also tie it in to the computer over UART to retrieve the score/time/period/possession of a live sports game off of the internet, and have it update the data on the board in near real-time.

April 29, 2013
by Keyster
Keyster's Avatar

that is a great idea. i have written software to pull data from websites before but not sure where to get "near real time" scores and time from. i know ESPN does stuff like that but it would need to be in some kind of RSS feed or XML format or i would be completely lost. i will google around for that. Thanks Xodin.

I am going to have a wireless RFM22B module in it so it can get the time from my computer in the house via a "base station" Nerdkit. Pushing information to it should be quite easy once i have that setup. (in theory anyway) :)

April 29, 2013
by Rick_S
Rick_S's Avatar

Cool project. I'm looking forward to seeing it progress.

Rick

April 29, 2013
by Keyster
Keyster's Avatar

here is a Youtube video of a test run when i got the first panel together.

Test Run #1

May 02, 2013
by xodin
xodin's Avatar

No prob, thanks for the post, it makes me want to try something similar. I'll look into a source for the sports scores. I have the ability to write programs that can pull data from any website, regardless of format, but for it to work consistently the key will be to find a source that consistently provides the data in the same format (RSS and XML would be examples of that, but consistent HTML would work too). Also, it would be ideal if the URL were in a predictable format so that you don't have to manually enter a different URL for each game you want to track on your board, though that might not be too big of a deal. Will let you know if I find something that would work well.

May 03, 2013
by scootergarrett
scootergarrett's Avatar

xodin

How are you getting data from a website? I have always wanted to do that but I keep getting told to use Python which I just started to learn, but I can't even figure out how to install libraries. Ever since I was a little kid I thought why don't they make an alarm clock that shuts it self off if school is canceled.

May 05, 2013
by xodin
xodin's Avatar

I prefer to use perl, but python would work also, or even C or C++. Basically all you have to do is open a TCP socket connection on port 80 to a web server, send an HTTP GET command, and store the result. To parse the result I almost always use regular expressions to extract the data I'm looking for.

Regarding the scoreboard, ESPN is the best place I've found so far to pull the data, though there would need to be different extraction scripts for different types of games: football, basketball, baseball, etc...

May 05, 2013
by Ralphxyz
Ralphxyz's Avatar

scootergarrett, if you look at a web page source you can find the fields you are interested in seeing, so you just need a script to sort them out once you know their names. At least for simple screen scrapper applications.

Ralph

May 06, 2013
by Keyster
Keyster's Avatar

i found a website that shows the location to pull the data from:

Link To Website

here is a link to the live data for an example. of course i just found this so i am not sure what it looks like during the game but it looks promising.

Link to Live ESPN Bottomline Data - NBA Example

this appears to be only professional sports. i am going to keep looking for the college stuff.

May 07, 2013
by Keyster
Keyster's Avatar

Here is a YouTube video of it with ALL LEDs working finally!

YouTube

May 07, 2013
by Keyster
Keyster's Avatar

And a picture of the backside (it's backside, not my backside)

back of scoreboard

the following link is the full size picture if you would like to see it up close:

Link to full size picture

May 08, 2013
by pcbolt
pcbolt's Avatar

Great progress!

Are you using shift registers to control each digit? I can't really tell from the photos but it looks like you're using the SPI lines to output data but I don't see several "Slave Select" lines (unless your using a shift register for that).

If you want to get something functional up quickly before diving into the "base station NK" option, you can get a clock module real easily here...Real Time Clock Module. I got one cheaper at Futurlec but it took ages for shipping. Nice thing is it works on the I2C lines so it should be OK.

May 08, 2013
by Rick_S
Rick_S's Avatar

That's what it looks like it could be to me. Shift registers driving mosfets driving a segment in a display. You don't need slave select lines, you can just shift all data out each time (3 Lines - Shift clock, Latch clock, Serial Data). He only has about 67 entities to update. You can shift that out pretty darn quick. I was shifting out 640 pixels in an 8x80 matrix display w/o any noticeable flicker.

This is a very cool project Jim. I wouldn't have anywhere to put something like this, but all the same, it is very cool indeed. Did this idea stem from your tractor pull score board? Just curious what made you think of it.

Rick

May 08, 2013
by Keyster
Keyster's Avatar

Hey Guys,

Yep, shift registers control Mosfets that give the GND to each segment (7 segments per number). the board is broke down into sections; minutes, hours, home score, visitor score and period. each section can be Latched individually so what i do is push 16 bits out the SPI and then latch the corresponding section. IE, shift out the minutes, latch minutes. if i shift out data for the wireless module i just don't latch anything. i am also going to have one input shift register (not hooked up yet) for some buttons on the side. these will control the mode for setting the time and brightness manually if needed. i hope i don't run out of pins because each latch takes a pin and i will have to Slave Select the wireless module and the input register so they don't step on each other. i also still need to add a temp/humidity sensor that i don't even have in the design yet. argggg!

the clock chip i have is the "PCF8593 Real Time Clock". i got a few of them from Digikey a while back and it works pretty cool. it fires an Interrupt every second so once i read the time from it at boot up i can use that interrupt to keep the time internally on the Atmega. the interrupt fires a Pin Change Interrupt internally which adds one to the seconds which in turn forces an update on the display. i am thinking about having it "re-check" the time from the RTC once an hour and then check with the base station once every 24 hours to get an update. i will probably use a supercap for battery backup unless you guys suggest against it.

@Rick, this is going to sound kind of silly but i thought about this about 1 year ago. my daughter plays basketball and i was sitting in the gym and looked up at the scoreboard and it just popped in my head, "I can build that". this year i had a two car garage built in my back yard which is also going to be my workshop so i have a BIG bare wall just needing something to hand on it. i put 2 and 2 together and started this build. This actually happens to me ALL THE TIME now. Ever since i started working with these Microcontrollers EVERYTHING i see i think "how would i build that?" i have not decided if it is a curse or a blessing. i guess i can thank/blame the Nerdkits guys for that.

May 08, 2013
by pcbolt
pcbolt's Avatar

Interesting.

But it seems to bring me back to the same question (almost). If you can latch each section individually and a section can consist of 2 shift registers, do you still need, let's say, 5 lines (hr, min, home, visitor, period) for the latches? That would make sense from your description...I just can't trace each line from the photo (even the big one :-).

If I understand it correctly, Rick's solution seems like it may help you immensely when searching for more pins to use as outputs (unless of course you're already doing it this way). Just create an array in your program which hold the state of each section, update any changes to the array then just spit the whole thing out and latch all sections at once with a single pin (assuming the shift registers are all chained together). The other allowance you might consider is the timing of the shift registers usually isn't too demanding so you can use the MCU timers to create your own SPI lines.

I can certainly relate to the curse/blessing dilemma. Things that were once mystifying go to being "it can't be that simple".

May 09, 2013
by Rick_S
Rick_S's Avatar

Looking at the photo closer, and Jims description, it does appear he is using 5 latch lines, a clock line, a serial data line, and I'm guessing doing PWM on the Output Enable line for the "BRI"ghtness? This give the advantage of just updating one section if desired, but with so few segments, if you needed the extra I/O, just one latch will do.

If I read the datasheet correctly, the SPI clock is anywhere from Oscillator frequency divided by 2 (7.3728 MHz) to fosc/128 (115.2 KHz). Even at the lowest speed, 64 bits (8 shift registers 8 bits each) would take virtually no time to update. Since this project isn't animated (It's just static digits that will change at most maybe every second?) either method would probably work just fine.

Rick

May 09, 2013
by Keyster
Keyster's Avatar

you guys have hit on one of my, i will call it, dilemmas during the making of this. i think the reason i went this way stems from my last few projects where speed was very important. i made a LED cube and also worked with the G35 Christmas lights where things have to flow pretty quick. Rick is absolutely correct that it could easily update in the given time frame (once per second). i may have a few small animations, for example have the period number do a figure eight while the clock is trying to contact the base station but even that will only be maybe 3 or 4 times a second which would not be a problem.

i think what it boiled down to was the fact that if the minute only changes once a minute, the hour only changes once an hour, and the AM/PM will only change once every 12 hours then why clock them out every second? of course, now, in retrospect clocking them all every cycle would probably only add 1ms to the time, would only use one latch pin, and would be undetectable to the human eye, i may go back and change it around. my control boards are already setup to work in a series like that as well.

another dilemma i had was whether to put the MOSFETs on the same board with the Shift registers and then run the "main" power through the ribbon cables. this would have been a cleaner solution because i could have soldered the ribbon wires straight to the segments and would not require that spaghetti of wires at each number. my original math was this:

LED is 2.1 volt drop and 20ma max. 20ma x 12 LEDs per segment = 240ma. 240ma x 8 lines per ribbon cable make it almost 2amps per ribbon. i opted to send only a signal over the ribbons and then control the power "close" to the segments.

in retrospect, my my math turned out to be wrong due to some changes in the design along the way. i changed the current limiting resistor to a 100ohm resistor to dim the LEDs a little. originally it was BLINDINGLY bright and i did not have the PWM in the original design either. So, on to the new math (don't laugh if i get this wrong, just pat me on the head and correct me) ;)

12 LEDs, every two in series with 100ohm resistor pulls 8ma x 6 so 48ma per segment. 48ma x 8 segments = 384ma. i would have no problem pushing that over a ribbon cable. In the math I use 8 segments instead of 7 because a few of them use the 8th pin to run the BONUS and Possession lights.

May 09, 2013
by countryguy828
countryguy828's Avatar

Hi Guys,

I'm not sure if this fits in here or not, but I am going to say it anyways. Has anyone considered using tpic6c595's as an alternative to 74hc595's. My understanding is the tpicc6c595 can handle more power than the 74hc595. I got a couple free samples from TI to test with.

tpic6c595 datasheet

Dave

May 09, 2013
by Keyster
Keyster's Avatar

Hey CountryGuy,

At a quick glance and with my "current" design power requirements i believe i could have used 9 Tpic6c595's and totally removed the FETs from the design and ran the outputs straight to the segments. of course, this is if all my math is correct. ;)

July 19, 2013
by Keyster
Keyster's Avatar

Hey Guys, i just wanted to give an update to this project.

i have two kids playing 5 sports this summer so it has slowed my progress somewhat. currently i have everything working except for the wireless. the module is connected and working fine i just have not written the code to make it communicate back to the PC. i can manually set the time via buttons that i will mount on the side so technically it is a clock! :)

things i had problems with:

my original plan was to hook the input shift register straight to the MISO line for reading the button input but it interfered with the wireless module. i "assumed" that there would be a select line on the shift register but found out quickly that there was not. it worked fine as long as my wireless module was de-selected. of course they stepped on each other when i selected the wireless module. i freed up some pins and now just bit bang the data in with my own code.

the temperature and humidity sensor (DHT22) gave me some problems. i had to pull out the trusty oscope to get the timing correct. i could get a reading about 1 out of every 10 tries but read on forums where most people got 100% reliable readings. Noter helped me out a little bit on that and i finally got the "start bit" timing correct and now it reads every time.

my clock (PCF8593) works but was losing about 5-10 seconds a day. i am still playing with some capacitors to tune it better. last night i put in a 5PF cap and after about 2 hours it seemed to still be very close to the correct time. tonight i will let it run all night and see how close i got it.

my supercap came in two days ago and i gave it a charge. works perfectly! supercap power backup is now on the design!!!

it looks like my original picture has "gone away" so i will post another one here from a better source.

picture here

ohh, i just have the breadboard sitting on the back but once i get it so i can stand it up i will get a video and link it here.

August 13, 2013
by scootergarrett
scootergarrett's Avatar

Has anyone made any progress on getting the MCU to update based on data from the internet? I’m trying to do it in C, I have tried so many things to get C program to access internet data. I tried the URLDownloadToFile() function but get urlmon: no such file or directory. Some InternetOpen() function. And CURL but I never can get curl connected to with my C program. MatLab has a function urlread() that works great but I would like to keep it free. I’m good at programming but can’t use a computer. Any ideas would be appreciated.

August 14, 2013
by Keyster
Keyster's Avatar

Hey Scooter, i am not sure if this will help but here is something i wrote in C Sharp to read temperature and humidity sensor readings from a proprietary piece of hardware that only had a web interface. it works and may point you in the right direction.

you pass it the URL, the text you are looking for ("Sensor A:" for example) and how may bytes to return after the found text.

   protected static string ReadStringFromURL(string URL, string LookFor, int BytesToRead)
    {
        string sRet = string.Empty;

        HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(URL);

        myRequest.PreAuthenticate = true;

        // this is only needed if you have to logon to website
        myRequest.Credentials = new NetworkCredential("logon", "password");
        myRequest.KeepAlive = false;
        myRequest.Proxy = null;

        // this is only needed if you get certificate warnings on the page
        // most pages will not need this
        ServicePointManager.ServerCertificateValidationCallback = ReplyYes;
        HttpWebResponse myResponse = null;

        try
        {
            myResponse = (HttpWebResponse)myRequest.GetResponse();
        }
        catch
        {
            return (string.Empty);
        }

        Stream TheStream = myResponse.GetResponseStream();
        StreamReader sr = new StreamReader(TheStream);

        string httpLine = string.Empty;

        while (!sr.EndOfStream)
        {
            httpLine = sr.ReadLine();
            if (httpLine.Contains(LookFor))
            {
                sRet = httpLine.Substring(httpLine.IndexOf(LookFor)+LookFor.Length, BytesToRead);
                break;
            }
        }

        myResponse.Close();

        sr.Dispose();
        TheStream.Flush();
        TheStream.Close();
        TheStream.Dispose();

        return (sRet);
    }

    private static bool ReplyYes(object server, System.Security.Cryptography.X509Certificates.X509Certificate cert,
            System.Security.Cryptography.X509Certificates.X509Chain chain,
            System.Net.Security.SslPolicyErrors sslPolicyErrors)
    {
        return (true);
    }
October 16, 2013
by scootergarrett
scootergarrett's Avatar

I finally got a C (kind of) program that will copy a website into a string or to a file. I have found the Link to Live ESPN Bottomline Data - MLB Example website suggested above is the simplest but I don’t think it has as much info as I might want. I kept track of the website during a game and this is what I learned. There are a lot of ‘%2’ floating around, and other numbers that didn’t seem to change. Anyways now I can continuously pol this sight and could send it to my MCU. Now I want to build my own score board and get a raspberry pi to do the internet stuff.

October 16, 2013
by BobaMosfet
BobaMosfet's Avatar

scootergarrett-

It's not '%2' it's '%20'. That is a space character. The text you're referring to is URL-encoded. You can easily decode it. I suggest using regexp, makes it much easier to parse out exactly what you want with very little code.

Hope that helps BM

Post a Reply

Please log in to post a reply.

Did you know that two resistors can be used to make a voltage divider? Learn more...