+ Reply to Thread
Page 3 of 8
First 1 2 3 4 5 6 7 ... Last
Results 31 to 45 of 107

Thread: Binary input Hex dispaly (7 segment LED)?

  1. #31
    ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent
    Join Date
    Jan 2007
    Location
    Hampshire. England.
    Posts
    10,821
    Blog Entries
    13

    Default

    hi,
    This simple program was written in collaboration with MikeK8LH.
    Written for the 16F628A PIC.

    Accepts two 4,bit binary inputs and displays 0 thru F [hex] on two, 7 segment
    Common Cathode LED's.

    Uses the msd/lsd LED digit selection, as shown in Mike's post.
    Attached Files
    Last edited by ericgibbs; 7th July 2008 at 11:21 AM.
    Eric " Good enough is Perfect "
    I will NOT answer PM's requesting technical help, please use the Forum
    PIC tutorials: Nigel's www.winpicprog.co.uk/ Bill's: www.blueroomelectronics.com/


  2. #32
    Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent
    Join Date
    Jan 2005
    Location
    Michigan, USA
    Posts
    2,521

    Default

    Hi Eric.

    You've got a few lines of code that aren't really doing anything. Other than that your logic is fine.

    I would make it a little tighter and simpler but that's just a style difference. In the example below the basic logic and function are unchanged, except for (1) the loop time is constant for either digit now, and (2) digit segment data and the digit select bit are written at the same time to prevent image blur or smear.

    Code:
    ;
    ;  variables
    ;
    Dig_Sel equ     0x70            ; bit 7 is used to select digit
    Temp    equ     0x71            ;
    ;
            org     0x0000
    Reset
            clrf    STATUS          ; force bank 0
            movlw   h'07'           ;
            movwf   CMCON           ; turn comparator off
            bsf     STATUS,RP0      ; bank 1
            movlw   h'FF'           ;
            movwf   TRISA           ; make Port A all inputs
            movlw   h'00'           ;
            movwf   TRISB           ; make Port B all outputs
            bcf     STATUS,RP0      ; bank 0
            clrf    Dig_Sel         ; init Digit Select (B7 = 0)
    Loop    
            movf    PORTA,W         ; get Lo input in b3..b0
            btfsc   Dig_Sel,7       ; low digit? yes, skip, else
            swapf   PORTA,W         ; get Hi input in b3..b0 
            call    SegData         ; get segment data
            iorwf   Dig_Sel,W       ; pick up digit select bit (b7)
            movwf   PORTB           ; update display
    
            movlw   b'10000000'     ; digit select bit mask
            xorwf   Dig_Sel,F       ; toggle b7 digit select bit
            goto    Loop            ;
    
    Do you think there might be any problem scanning the display at such a high frequency (something like 20-KHz)? Anyone?
    Last edited by Mike, K8LH; 6th September 2007 at 10:34 PM.

  3. #33
    ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent
    Join Date
    Jan 2007
    Location
    Hampshire. England.
    Posts
    10,821
    Blog Entries
    13

    Default

    hi Mike,
    That looks fine, much more compact.
    I will have to get a couple of 628A and give it a try in real time, as we both know simulators do have limitations.

    I did consider the high refresh rate [20KHz] but the spec on my FND357 LED's indicated it would be OK. It would be interesting if one of the OP's, who have been asking for bin2hex drivers gave it a shot. For about $2 its much more cost effective and has a smaller on board footprint than discrete ic's.

    If the refresh rate is too fast for some LED's a short inter LED delay would be easy to implement.

    Regards
    Eric " Good enough is Perfect "
    I will NOT answer PM's requesting technical help, please use the Forum
    PIC tutorials: Nigel's www.winpicprog.co.uk/ Bill's: www.blueroomelectronics.com/

  4. #34
    Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent
    Join Date
    Jan 2005
    Location
    Michigan, USA
    Posts
    2,521

    Default

    Does this look correct? Conventional wiring to multiplexed or non-multiplexed common cathode displays.
    Attached Images
    Last edited by Mike, K8LH; 15th September 2007 at 11:37 AM.

  5. #35
    ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent
    Join Date
    Jan 2007
    Location
    Hampshire. England.
    Posts
    10,821
    Blog Entries
    13

    Default

    hi,
    Looks the same as my sketch.
    Attached Files
    Last edited by ericgibbs; 7th July 2008 at 11:21 AM.
    Eric " Good enough is Perfect "
    I will NOT answer PM's requesting technical help, please use the Forum
    PIC tutorials: Nigel's www.winpicprog.co.uk/ Bill's: www.blueroomelectronics.com/

  6. #36
    Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent
    Join Date
    Jan 2005
    Location
    Michigan, USA
    Posts
    2,521

    Default

    Quote Originally Posted by ericgibbs
    It would be interesting if one of the OP's, who have been asking for bin2hex drivers gave it a shot. For about $2 its much more cost effective and has a smaller on board footprint than discrete ic's.
    I agree. It might also be helpful for those chaps building discrete logic clocks but the design does have some limitations. For example, it almost seems you'd need two versions, one with leading zero suppression, and one without, and I don't see an easy way to implement brightness control.

  7. #37
    Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent
    Join Date
    Jan 2005
    Location
    Michigan, USA
    Posts
    2,521

    Default

    Quote Originally Posted by ericgibbs
    If the refresh rate is too fast for some LED's a short inter LED delay would be easy to implement.
    I agree. Here's a simple low overhead 8 bit DelayUS() sub-system (macro and subroutine) that could be used by those interested in experimenting with inter-digit delay time;
    Code:
            radix   dec
    ;******************************************************************
    ;                                                                 *
    ;  DelayUS(8..1031), 4 MHz clock      Mike McLaren, K8LH, Jun'07  *
    ;                                                                 *
    ;  requires the use of constant operands known at assembly time!  *
    ;                                                                 *
    ;  7 words, 0 ram variables, 14 bit core                          *
    ;                            ^^^^^^^^^^^                          *
    ;  the macro generates 2 instructions;                            *
    ;                                                                 *
    DelayUS macro   delay           ; parameter 8..1031
            movlw   delay/4-1
            call    Delay4Tcy-(delay%4)
            endm
    ;                                                                 *
    ;  code for simulation testing;                                   *
    ;                                                                 *
    SimTest DelayUS(1000)           ; delay 'n' usecs
            nop                     ; put simulator break point here
    ;                                                                 *
    ;******************************************************************
            nop                     ; entry point for (delay%4) == 3  |B0
            nop                     ; entry point for (delay%4) == 2  |B0
            nop                     ; entry point for (delay%4) == 1  |B0
    Delay4Tcy
            addlw   -1              ; entry point for (delay%4) == 0  |B0
            skpz                    ;                                 |B0
            goto    Delay4Tcy       ;                                 |B0
            return                  ;                                 |B0
    ;******************************************************************
    
    You might use it within the driver loop like this;

    Code:
    Loop
            movf    PORTA,W         ; get Lo input in b3..b0
            btfsc   Dig_Sel,7       ; low digit? yes, skip, else
            swapf   PORTA,W         ; get Hi input in b3..b0
            call    SegData         ; get segment data
            iorwf   Dig_Sel,W       ; pick up digit select bit (b7)
            movwf   PORTB           ; update display
            DelayUS(1000)           ; delay 1 msec
            movlw   b'10000000'     ; digit select bit mask
            xorwf   Dig_Sel,F       ; toggle b7 digit select bit
            goto    Loop            ;
    
    Last edited by Mike, K8LH; 7th September 2007 at 12:49 PM.

  8. #38
    dalmation Newbie
    Join Date
    Aug 2007
    Posts
    80

    Default

    Quote Originally Posted by Mike, K8LH
    Eric (Ericgibbs) contacted me off list and he's got a much simpler and more elegant solution that doesn't involve the screwy Charlieplexed display wiring and code. His method uses your suggestion for using 1 pin to drive the common cathodes on both displays.
    This is what I was thinking (I was gonna use an npn and a pnp to achieve the same thing, but this is better).

    If I understannd correctly- when the RB? is HIGH, CC1 wil be active- When RB? is LOW, CC2 will be active. Is that right?

    Thanks again guys- theres no way I could suss this out on my own.

    -Dalmation.

  9. #39
    dalmation Newbie
    Join Date
    Aug 2007
    Posts
    80

    Default

    Quote Originally Posted by Mike, K8LH
    Here's the first draft of the 16F628A firmware (untested). Hope to test it this coming weekend.

    Mike

    Wow- thats a lot of work you've put in. I cant say I understand the programming, but I noticed that on the segment table, there is no A-F?

    I got myself a book on PIC programming and I look forward to having a better understanding- I really appreciate your help in the mean time.

    -Dalmation.

  10. #40
    dalmation Newbie
    Join Date
    Aug 2007
    Posts
    80

    Default

    I was looking at different LED's for use with this circuit, and I think these will suit me best- they are Dual Digit, common cathode displays.

    These are easy enough to incorporate using the 2 transistor digit switching, right?

    0.3 dual digit numeric.pdf

    Thnaks again guys- I hope I can help you all out with something in the future!!

    -Dalmation.

  11. #41
    matseng Newbie
    Join Date
    Sep 2003
    Location
    Dubai, UAE
    Posts
    4

    Default

    By adding some resistors it's possible to control four displays on each 16F628.

    This is true if the circuit driving this display unit are capable of both sourcing and sinking the signal (i.e. not open collector) and can handle an extra load of 100 uA.

    The same pins on the '628 can be connected both to the displays via 220 ohm resistors as well as the outputs from the controlling circuit via 47 Kohm resistors.

    The '628 will first set the pins as input, read the incoming signal, calculate the correct bitpattern, set the ports as outputs, output the bitpattern, wait 20 mS and repeat all over again.

    This means that the segments on the display can only be changed 50 times per second, but i think that's enough...

    The attached picture only shows half of the circuit. It needs to be repeated for portB.

    Mike: What program are you using to draw your schematics?

    EDIT - I just realized that it's not possible to drive four displays this way using the 628 since the RA5 -port is crippled and can only be used as an input. This input/output sharing thing can be used in other applications to reduce the number of ports required, but for this specific application it's not usable. Sorry.
    Attached Images
    Last edited by matseng; 12th September 2007 at 04:11 PM.

  12. #42
    ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent
    Join Date
    Jan 2007
    Location
    Hampshire. England.
    Posts
    10,821
    Blog Entries
    13

    Default

    Quote Originally Posted by dalmation
    Wow- thats a lot of work you've put in. I cant say I understand the programming, but I noticed that on the segment table, there is no A-F?

    I got myself a book on PIC programming and I look forward to having a better understanding- I really appreciate your help in the mean time.

    -Dalmation.
    hi,
    Look at my version of the program, I did add the 'A,b,c,d,E,F' patterns.
    http://www.electro-tech-online.com/a...m?d=1189081163
    You can change to 'HELP?' and many others to suit your project.
    Last edited by ericgibbs; 12th September 2007 at 01:50 PM.
    Eric " Good enough is Perfect "
    I will NOT answer PM's requesting technical help, please use the Forum
    PIC tutorials: Nigel's www.winpicprog.co.uk/ Bill's: www.blueroomelectronics.com/

  13. #43
    dalmation Newbie
    Join Date
    Aug 2007
    Posts
    80

    Cool

    Quote Originally Posted by ericgibbs
    hi,
    Look at my version of the program, I did add the 'A,b,c,d,E,F' patterns.
    http://www.electro-tech-online.com/a...m?d=1189081163
    You can change to 'HELP?' and many others to suit your project.

    Noticed it straight after my post. Looks excellent, thanks.

    Just checked so see if my universal programmer can do pic chips- it can! :-)

    I'll get some pics and experiment on some veroboard this weekend (missus permitting :-)

    Thanks again guys.

    -Dalmation.

  14. #44
    dalmation Newbie
    Join Date
    Aug 2007
    Posts
    80

    Default

    Quote Originally Posted by matseng
    By adding some resistors it's possible to control four displays on each 16F628.
    Thats pretty impressive, mate. That would save a lot of (precious) space and of course money. I like it.


    Quote Originally Posted by matseng
    This is true if the circuit driving this display unit are capable of both sourcing and sinking the signal (i.e. not open collector) and can handle an extra load of 100 uA.
    To be honest, I'll need to check if it can sink the signal- I hope so! I'll check the circuit tonight and let you know (fingers crossed). The extra 100uA certainly wont be a problem either way.

    Quote Originally Posted by matseng
    The '628 will first set the pins as input, read the incoming signal, calculate the correct bitpattern, set the ports as outputs, output the bitpattern, wait 20 mS and repeat all over again.
    I am (for now), in terms of pic program writing, totally dependant on the time people have (incredibly generously!) donated to my cause in this thread- I'm deeply impressed. A program has been written that does 2 displays per pic, and I'm gonna play with that. If anyone can write one to suit your method, then great, otherwise I'll use it as an incentive to learn more on the subject- so far I can make led's flash on and off and change the timing- early days!

    Quote Originally Posted by matseng
    This means that the segments on the display can only be changed 50 times per second, but i think that's enough...
    I believe 50Hz is perfectly adequate for led displays, so that should be fine.


    I'm off to look up some space saving resistor arrays to keep within my pcb outline.

    Once again- THANKS!!!!

  15. #45
    matseng Newbie
    Join Date
    Sep 2003
    Location
    Dubai, UAE
    Posts
    4

    Unhappy

    I'm sorry. I have to take back my idea since I just realized that it's not possible to use the RA5 -port as an output as it is crippled on most of the PICs and can only be used as an input.

    This input/output sharing thing can be used in other applications to reduce the number of ports required, but for this specific application it's not usable.

+ Reply to Thread
Page 3 of 8
First 1 2 3 4 5 6 7 ... Last

Similar Threads

  1. driving multiplexed 7 segment display
    By mathur2000 in forum Micro Controllers
    Replies: 8
    Latest: 11th October 2009, 03:51 AM
  2. Using Oscilloscopes
    By mechie in forum Electronic Theory
    Replies: 9
    Latest: 29th November 2007, 09:49 PM
  3. 7 Segment Led Clock using PC signal
    By vito3693 in forum Electronic Projects Design/Ideas/Reviews
    Replies: 3
    Latest: 18th April 2007, 03:22 AM
  4. 4-bit binary to decimal into dual 7 segment displays
    By jupiter669 in forum Electronic Projects Design/Ideas/Reviews
    Replies: 8
    Latest: 15th February 2004, 02:06 AM
  5. Convert Leds to 7 Segment Display
    By Almazick in forum General Electronics Chat
    Replies: 21
    Latest: 19th August 2003, 07:53 PM

Tags for this Thread