Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 How to configure, seven-segment display
Index -> Programming, C -> C Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
MPatel




PostPosted: Thu Jan 11, 2007 5:17 pm   Post subject: How to configure, seven-segment display

Introduction:
Hey, I'm new and I stumbled upon this website when I was browsing for help on the internet for my problem. I am in Grade 11, and I am currently taking Computer Engineering. For my final summative we were to combine the hardware and software that we learned throughout the year and combine it into our final summative/project. Now, we have limited time on this project and I have about 1.5 weeks left to complete. In school we are using MPLAB with 'C' programming.


My Project:
A game where there are three buttons and three LED's. LED's flash in random order and when LED is on and button is pressed then ''1'' is added to score. Score is only up to seven. Game basically like "Whack A Mole".


The Problem:
My problem is that I need to configure/code the seven segment display with my PIC-What I Program (P16F684), through my decoder (74LS47).

So, (P16F684) --> (74LS47) --> (Seven-Segment)

My ports on the P16F684 are RA5, RC5, RC4 and RC3, are in binary 8s, 4s, 2s, and 1s respectively. All of these ports go to the 74LS47 which takes in those 4 inputs and then transfer them to the seven segment display (7 inputs).

I need to know how to start at "0" and when a certain command is triggered add "1" to the previous score. So I know what I want to something like s=s+1 where "s" is the score. But I do not know how to transfer that onto my code.


What I Have Done:
I have the wiring, ports, pins for all and mostly all the code, I just need help with a THAT part of the code. I need to know how to make the score showing at all times, and how I can make it count upwards when I initialize this procedure. My teacher has given me some help about the wiring, which I have but not that much insight on the coding. The rest of my coding is complete except this crucial part. I am NOT one of those students that does not know anything and makes other people do their work, But I do need some help with this.

The Future:
Hopefully, I want to complete the score going up to seven first, so I have a backbone. Then I will try to use the dual-seven-segment so I can make the score go up higher. After I know how to use the simple seven segment display.

It may sound real confusing but if you need clarification I can re-state. I don't have the code right now, But I can paste it tommorow, so you can see what I am trying to accomplish. But if you have a gist of what I am trying to explain would you please help? Any help is appreciated. Thanks. Razz
Sponsor
Sponsor
Sponsor
sponsor
MPatel




PostPosted: Thu Jan 11, 2007 5:34 pm   Post subject: Re: How to configure, seven-segment display

Attachment:
Here is an attachment to give a VISUAL of just the 74LS47 and seven-segment-display pin numbers.



74LS47 to Seven Segment Display.doc
 Description:

Download
 Filename:  74LS47 to Seven Segment Display.doc
 Filesize:  592.5 KB
 Downloaded:  1147 Time(s)

MPatel




PostPosted: Thu Jan 11, 2007 9:53 pm   Post subject: Re: How to configure, seven-segment display

Hey, would anyone be able to solve my problem? Or am I unclear in my explanation?
Clayton




PostPosted: Thu Jan 11, 2007 11:28 pm   Post subject: Re: How to configure, seven-segment display

Just be patient. There isn't nearly as much activity in the C forums as there is in say the Turing Forums. Someone will get to it eventually, don't worry. Also be careful with the triple post. There's an edit button there for a reason Very Happy
Skynet




PostPosted: Fri Jan 12, 2007 12:05 am   Post subject: Re: How to configure, seven-segment display

Before you do any output, you'll first have to make sure the chip knows that the outputs are in fact outputs. For example, your PIC may have two "ports", each with 8 I/O pins. You'll be able to access some specialized registers with your code, assuming you've got the libraries. (Which are free from microchip.com) Telling the chip that Port A is output and Port B is input would then need code that looks like this:

code:

TRISA = 0x00;    // All 8 bits are output
TRISB = 0xFF;    // All 8 bits are input


After this is done, to work with the outputs you'll need to know how you've wired your circuit. You can either have current flowing into the pin from a higher voltage ("sinking") or flowing out to a lower voltage ("sourcing"). A typical micro can sink more current that it can source, which is something you may want to keep in mind.
Ex (Turning on an LED):

-------RA0 (Port A, Bit 0)---------///600 ohm///-----|<LED----------+5V

So, to use this pin
code:

PORTA = PORTA|0x1;      //On (bitwise OR operation on 0x1)
PORTA = PORTA&~0x1    //Off (bitwise AND the one's compliment of 0x1)

The nice thing about this (as far as nice things go in embedded programming, at least) is that you may be able to assign your score variable directly to your port, assuming your 74LS chip takes input in a nice sane binary fashion.
code:

PORTA = some_useful_byte;


So, really, two steps:
1) Set up the outputs by writing config registers
2) Use bitwise operations to output to these registers

Things to look out for:
1) Confirm the registers and their operations. Different chips have different setups, both for setting input vs. output & sinking vs. sourcing.
2) Your output logic. For example, the chip won't stop you from writing to an input.
3) Wiring. 95% of all chip problems I've seen resulted from bad wiring.[/code]
Display posts from previous:   
   Index -> Programming, C -> C Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: