Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Digital Clock(Big)... Using PIC

Status
Not open for further replies.
picasm said:
Mike,
I agree with you that the 25mA port limits would be ok for a small multiplexed 7-segment display.
But as the OP wants to make his own very large display, I assume he will need many leds per segment, and I don't favour his 5v supply requirement.
I would be happier if the drivers were able to handle about 500mA, at least it would help protect the chips during the software development stage if he had any multiplexing errors etc.
I think you may have misunderstood (or I wasn't clear). I was suggesting directly driving each display with some sort of latch with 25-ma/pin capability. No multiplexing at all. Of course there's no reason to throw 6 ICs at the solution (grin) and as you say it probably isn't a viable solution with "big displays".
 
Last edited:
Ayne said:
Now the complete Circuit..
**broken link removed**

I want to know from senior membors which will be the best choice for P-Channel MOSFETs for this knid of application.

C & C are welcome.

Thanks in advance..
I believe you have a workable solution Sir. And it seems you've settled on Common Anode displays.

Have fun. Mike
 
lol, I won't write the whole thing, but surely a push in the right direction will help.

Personally, I would prefer to use 7 I/O's for the segment's, instead of adding the 4511. Now you have one less component, and the whole project is still very doable with a single 28 Pin PIC.

From there, you need 'Shadow Registers' that contain the Hour/Minute/Second data. Multiplexing each buffer quickly would ensure the displays would not appear to flicker.

The following was written with Swordfish, and the wiring diagram is just a piccy from my site, so you could use the same analogy, but with a different circuit;
Note: This code displays how to use the ISRTimer library. Two timers are set up. One to increment a variable, the other to multiplex the displays

Code:
Device = 18F452
Clock = 20

#option _Segment_Port = PORTC                      // Define the 7-Segment PORT
#option _Segment_TRIS = GetTRIS(_Segment_Port)     // Nice way to automatically get the TRIS
                                                   //  automatically from a selected port
                                                   
Include "ISRTimer.bas"  
Include "utils.bas"

Dim Segment_1_TRIS As TRISD.1,                     // User must define what pins control
    Segment_2_TRIS As TRISD.0,                     //  each segment
    Segment_1 As PORTD.1,
    Segment_2 As PORTD.0            
Dim Number As Byte,                                // Program variables that require no
    Segment_Data As _Segment_Port,                 //  user settings
    Segment_TRIS As _Segment_TRIS,
    Segment_1_Data As Byte,
    Segment_2_Data As Byte

Const
    Timer1 = 0,
    Timer2 = 1
  
// Update_Segments event, multiplex the segment data...
Sub Update_Segments()

    If Segment_1 = 1 Then
        Segment_1 = 0
        Segment_Data = Segment_2_Data
        Segment_2 = 1
    Else
        Segment_2 = 0
        Segment_Data = Segment_1_Data
        Segment_1 = 1    
    EndIf

End Sub

Function Segment_Encode(Segment_Byte As Byte) As Byte  // Convert a byte into segment information
    Select Segment_Byte
    	    Case 0 
    	   	Result = %00111111
    	    Case 1			
    	   	Result = %00000110
    	    Case 2			
    		Result = %01011011
    	    Case 3			
    	   	Result = %01001111
    	    Case 4			
    	   	Result = %01100110
    	    Case 5			
    	   	Result = %01101101 
    	    Case 6			
       		Result = %01111100
    	    Case 7			
     		Result = %00000111
    	    Case 8			
    		Result = %01111111
    	    Case 9			
     		Result = %01100111		 
    	EndSelect
End Function

Sub EncodeSegmentData()                          // Encodes segment data

    Segment_1_Data = Digit(Number,1)             // Extract the first digit & convert it
    Segment_1_Data = Segment_Encode(Segment_1_Data)
    Segment_2_Data = Digit(Number,2)             // Extract the second digit & convert it
    Segment_2_Data = Segment_Encode(Segment_2_Data)

End Sub

// Increment_Number event will increment the register Number
Sub Increment_Number()

    Inc(Number)
    If Number = 100 Then 
        Number = 0
    EndIf
    
    EncodeSegmentData

End Sub

// Start Of Program...
Timer.Initialize(2)                              // initialize the timer module...

// initialise each timer
Timer.Items(Timer1).Interval = 5                 // 5ms
Timer.Items(Timer1).OnTimer = @Update_Segments   // timer1 event handler
Timer.Items(Timer2).Interval = 500               // 500ms
Timer.Items(Timer2).OnTimer = @Increment_Number  // timer2 event handler

Number = 0                                       // Initialize variables
EncodeSegmentData

Segment_TRIS = %00000000                         // Make the segment data lines outputs
Low(Segment_1_TRIS)
Low(Segment_2_TRIS)

Timer.Items(Timer1).Enabled = True               // enable the timers... 
Timer.Items(Timer2).Enabled = True
Timer.Start                                      // start processing all timers...
 
// main program loop...
While True

Wend
**broken link removed**
 
Driving segments directly from I/O pins is fine for a few displays but the I/O pins just can't meet the peak current demands when you lower the duty cycle with 4 or more displays.

I'm pretty good at analyzing code but I'm lost with that example. Why not just use a 1-msec interrupt to "scan" the display and update the Clock variables once per second (once per 1000 interrupts)?

I'm pretty proud of my High Performance PWM display design -- a single IC and six or seven transistors, and you don't need a 28 pin PIC
 
Last edited:
Mike said:
Driving segments directly from I/O pins is fine for a few displays but the I/O pins just can't meet the peak current demands when you lower the duty cycle with 4 or more displays.

I'm pretty good at analyzing code but I'm lost with that example. Why not just use a 1-msec interrupt to "scan" the display and update the Clock variables once per second (once per 1000 interrupts)?

I'm pretty proud of my High Performance PWM display design -- a single IC and six or seven transistors, and you don't need a 28 pin PIC


The multiplexing is done every 5mS, this could be lowered too 1mS if you want, just a matter of changing this line;
Code:
Timer.Items(Timer1).Interval = 1                 // 1ms
Timer.Items(Timer1).OnTimer = @Update_Segments   // timer1 event handler

Now, every 1mS, the following Procedure will execute;
Code:
// Update_Segments event, multiplex the segment data...
Sub Update_Segments()

    If Segment_1 = 1 Then
        Segment_1 = 0
        Segment_Data = Segment_2_Data
        Segment_2 = 1
    Else
        Segment_2 = 0
        Segment_Data = Segment_1_Data
        Segment_1 = 1    
    EndIf

End Sub

Of course you can add more displays if need be, but I would consider using a variable to track what segment is being displayed, and use a Select Case routine, like this;
Code:
Inc(Current_Display)                                 //
If Current_Display = 6 Then Current_Display = 0      // Roll over to first display if required
Select Current_Display                               // Find out what data to display
    Case 0
        // Display Seconds_0
    Case 1
        // Display Seconds_1
    Case 2
        // Display Minutes_0
    Case 3
        // Display Minutes_1
    Case 4
        // Display Hours_0
    Case 5
        // Display Hours_1
EndSelect

As for meeting the peak current demands, well the demands are met by the ULN2003 (upto 500mA per channel). It is driven by logic voltages (from the PIC)
 
Last edited:
gramo said:
As for meeting the peak current demands, well the demands are met by the ULN2003 (upto 500mA per channel). It is driven by logic voltages (from the PIC)
It seems you may not be familiar with duty cycle, average, and peak current.

If you multiplex 8 displays you'll have a 12.5% duty cycle. The 20-ma or so peak current that an I/O pin can supply to an individual LED will have an "average" current of 2.5-ma and your display will be much dimmer.
 
Last edited:
I am making Main Board in Eagle.
But there is a problem
**broken link removed**
How to connect +5 Volts and ground to IC2(4028) and IC1(4511).

(I will make it's PCB in Eagle)
Thanks
 
My project is approx 80% completed.

Power Supply And it's PCB.

**broken link removed**

**broken link removed**



Display Board And it's PCB

**broken link removed**

**broken link removed**


Main Board(Pcb under construction)

**broken link removed**


I am enjoying this Project.
I am writing it's code in MikroBasic.
Code is approx completed but not tested yet...

Soon i will post the Whole Project here.

Thanks.
 
What MOSFETs are you using?

What current are you passing through them?

The chances are you don't even need logic level MOSFETs as they will be alright at low currents with a low gate voltage. Check out the datasheet.
 
Mike said:
Hi Ayne,

(1) I wonder if your 4511 and your 7405 devices can source and sink the 'peak' current required to drive the displays to full brightness at a 1/6th duty cycle?

(2) What are the voltage/current ratings for the large 7-segment displays you plan to use? Some of the really large displays use series LEDs to make up the segments and you may need a higher source voltage.

May I offer an alternative driver method (below) for a full brightness display with PWM brightness control and fade-to-black capability? This method uses 8 I/O pins, common anode displays, a single MIC5821 8-bit serial-to-parallel 500-ma sinking driver IC, and 600 to 800 ma PNP source drivers.

Have fun and good luck with your project.

Mike

**broken link removed**


Excuse me if it is a stupid question, but with which software do you design these? They look REALLY nice...

Thank you
 
I have changed the IDEA :D
Now the Idea is:
Using PIC16F877A.
Clock will show the "Time And Date And Day And Temperature(later) also"

Now i am working on Schamatic...

I will post as it will complete.
 
Day-of-week may be difficult to display on 7-segment displays. I thought about using 7 discrete LEDs for one project (below).

Temperature, or Outside Temp' and Inside Temp' display modes is a good idea. I thought about adding it to my 16F88 clock using one-wire DS18B20 temperature probes since I have 3 pins left over (grin).

You need a 40 pin 16F877A?


(drawings were done using drawing tools in Excel 2000)
**broken link removed**
 
Last edited:
I have Complete my Design.

Now i am using PIC16F877A.
20MHz Crystel.

I am not enough expert in Assembly. I have write small program like blinking LEDs in Assembly but never do any big project with it but now i an going to program this project in Assembly.

**broken link removed**

If there will be some problem in programming in Assembly i will ask u.. I mean it is only possiable with ur help.

What u say,
I should use Two seprate crystal, one for PIC clock Frequnecy and one for Clock TICK.

OR

Only one crystal For both Purpose..

Plz give me a right Direction. (Which Timer I use for which purpose i mean For Scaning purpose which Timer or For Timer TIck Which Timer)

I request to Administator.. "Plz delete all post from above this POST".. I was going to start a new Thread but i not started. I don't want to listen huge on my this request. Remain Focus on Project in this thread.

Thanks
 
Last edited:
Mike said:
Hi Ayne,

(1) I wonder if your 4511 and your 7405 devices can source and sink the 'peak' current required to drive the displays to full brightness at a 1/6th duty cycle?

(2) What are the voltage/current ratings for the large 7-segment displays you plan to use? Some of the really large displays use series LEDs to make up the segments and you may need a higher source voltage.

May I offer an alternative driver method (below) for a full brightness display with PWM brightness control and fade-to-black capability? This method uses 8 I/O pins, common anode displays, a single MIC5821 8-bit serial-to-parallel 500-ma sinking driver IC, and 600 to 800 ma PNP source drivers.

Have fun and good luck with your project.

Mike

**broken link removed**

Mike, how can this circuit have brightness control? Can you do a timeing diagram showing the PWM signal in relation to the update signals for setting the segment values?
 
I use a 1 msec PWM period and I 'scan' the display columns using that 1 msec Timer 2 interrupt. The displays are blanked when the PWM signal is high at the beginning of each interrupt cycle and that's when I borrow the column driver lines RB1 and RB2 to load the MIC5821 shift register. One display column is turned on when the PWM signal goes low. Varying the PWM duty cycle between 2% and 100% provides full fade-to-black brightness control from 98% to 0%, respectively. The interrupt driver (listing below) uses 12 instruction words plus a few instructions later on to setup the SEGDAT and COLPOS variables for the next 'scan' interrupt cycle. You don't see anything in the driver code for brightness control because it's pretty much an invisible background process. Simply change the CCPR1 duty cycle register at any time in your Main program to adjust display brightness.

The green area in the drawing below is the portion of the digit or column scan interval where the display is "on" (during the PWM "off time").

brightness-control-png.15769


Code:
;
;  The seven LED columns are 'scanned' one at a time at 1-msec
;  interrupt intervals for an overall 14.3% LED duty cycle and
;  142.85-Hz refresh rate...
;
;  A minimum PWM 'on' time of 2% guarantees a minimum window
;  of 20-usecs (80 instruction cycles) at the beginning of
;  each interrupt cycle where PWM drives the <OE> input high
;  (display off)...  This allows me to reuse the RB1 and RB2
;  column driver lines temporarily as '5821 <DAT> and <CLK>
;  lines to load the '5821 (without messing up the display)
;  before RB1 and RB2 resume their column driver duties when
;  PWM drives <OE> low (display on)...
;
;  The 2% minimum PWM 'on' time limits maximum brightness to
;  98% but the 2% loss of brightness is inperceivable
;
ISR_LED
        movlw   d'8'            ;                                 |B0
        movwf   TEMP            ; serial bit count                |B0
ISR_Load
        bcf     SERCLK          ; preset '5821 CLK line lo (RB1)  |B0
        bcf     SERDAT          ; preset '5821 DAT line lo (RB2)  |B0
        rlf     SEGDAT,F        ; shift data bit into Carry       |B0
        skpnc                   ; a '1' bit?                      |B0
        bsf     SERDAT          ; yes, set SERDAT line to 1       |B0
        bsf     SERCLK          ; clock data bit into the '5821   |B0
        decfsz  TEMP,F          ; all 8 bits sent/loaded?         |B0
        goto    ISR_Load        ; no, branch and do another       |B0
;
;  now setup Port B column drivers before PWM drives the '5821
;  <OE> pin low to turn on the segment driver outputs & display
;
;  COLPOS variable cycles through the following fixed values
;  one interrupt at a time to 'scan' the display and switches;
;
;  00000010, column 1, inverted 11111101
;  00000100, column 2, inverted 11111011
;  00001000, column 3, inverted 11110111
;  00010000, column 4, inverted 11101111
;  00100000, column 5, inverted 11011111
;  01000000, column 6, inverted 10111111
;  10000000, column 7, inverted 01111111
;
ISR_Column
        comf    COLPOS,W        ; invert bits (only 1 bit low)    |B0
        movwf   PORTB           ; setup the column drivers        |B0
;
 

Attachments

  • Brightness Control.PNG
    Brightness Control.PNG
    17 KB · Views: 1,517
Last edited:
Ah i think i see what your doing:

When the PWM goes high

1. Set MIC5821 output to off (linked to PWM signal)
2. Clock in the required 7-seg code into the MIC5821.
3. Enable the next digit RBx line.

When the PWM goes low, the digit is shown. All other digits are off.
Repeat for each digit.

This means that each display is lit up in turn, and is on for 1/7th of the total time required to show all 7 digits as they take it in turn.

In that case, does the current to the display have to be 7 times greater than the normal If ? E.g. a 7-seg element may be rated at 25mA, so it should be driven at 175mA ?
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top