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

source code for multiplexing

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



Joined: 13 Mar 2010
Posts: 1

View user's profile Send private message

source code for multiplexing
PostPosted: Sat Mar 13, 2010 8:09 am     Reply with quote

Hello everyone!

I'm trying to make a 4-Digit Counter using PIC16F877A but the problem is, I don't have any idea how to program this project. Please help me.

Here's the schematic diagram:



I will use CCS C compiler.

Thanks in advance!
John P



Joined: 17 Sep 2003
Posts: 331

View user's profile Send private message

PostPosted: Sat Mar 13, 2010 10:22 am     Reply with quote

You're wasting hardware by having U2 in the design. You can easily make the processor generate the correct segment outputs. You do have to use 7 pins of port d instead of 4, though.

There must be lots of ways to do this, but if it were my project I'd set up a repetitive interrupt at (say) 1KHz and have it do something like

Code:

                 // This code could be made tighter, but this is easier to read
static int8 count;

  if (++count > 3)
    count = 0;

  trisd = 0xF;                   // All off
  portc = (1 << count);
  portd = lookup_segments[digits[count]];
  trisd = 0;                     // Turn on again



This assumes that the number you want to display has its digits in a 4-element array named digits[] and that there is a lookup table for the segments in a 10-element array of constants named lookup_segments[].

I'd turn off the portd outputs using trisd while loading new data, because otherwise there would be a slight mismatch between the setting of port c and port d, which might lead to "ghost" operation of unwanted LED segments.
asmallri



Joined: 12 Aug 2004
Posts: 1630
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

Re: source code for multiplexing
PostPosted: Sat Mar 13, 2010 2:47 pm     Reply with quote

kaizer002 wrote:
Hello everyone!

I'm trying to make a 4-Digit Counter using PIC16F877A but the problem is, I don't have any idea how to program this project. Please help me.


You hardware design is not optimal and, depending on the brand, model and colour of the LED the LED may or may not illuminate as expected. The LED intensity is a function of how close the PIC output can be driven to the +5volt rail. Instead of using the 2n3704, if you use a PNP transistor connecting the emitter to +5v and the collector to the LED's common anode with a series resistor between the base and the PIC, this will result in the transistor turning fully on (saturate) with minimal power dissipation in the transistor. To turn on a display the ENx pin would need to go low (logic 0 output).

The modified circuit will result in the transistor turning fully on (saturate) with minimal power dissipation in the transistor.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
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