Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Forums > Electronic Projects Design/Ideas/Reviews


Electronic Projects Design/Ideas/Reviews Are you building an electronic project or want to? Maybe you need some assistance? Come and submit your electronic questions here and let our experienced members find a solution.

Reply
 
LinkBack Thread Tools Display Modes
Old 6th September 2007, 01:20 PM   (permalink)
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
File Type: asm Forum 4477 Chip3x.asm (4.6 KB, 15 views)
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/

Last edited by ericgibbs; 7th July 2008 at 12:21 PM.
ericgibbs is online now  
Old 6th September 2007, 10:51 PM   (permalink)
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 11:34 PM.
Mike, K8LH is offline  
Old 7th September 2007, 07:49 AM   (permalink)
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"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/
ericgibbs is online now  
Old 7th September 2007, 12:45 PM   (permalink)
Default

Does this look correct? Conventional wiring to multiplexed or non-multiplexed common cathode displays.
Attached Images
File Type: png Eric's 4477 IC.PNG (23.5 KB, 247 views)

Last edited by Mike, K8LH; 15th September 2007 at 12:37 PM.
Mike, K8LH is offline  
Old 7th September 2007, 01:04 PM   (permalink)
Default

hi,
Looks the same as my sketch.
Attached Files
File Type: pdf LED2.pdf (16.7 KB, 13 views)
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/

Last edited by ericgibbs; 7th July 2008 at 12:21 PM.
ericgibbs is online now  
Old 7th September 2007, 01:04 PM   (permalink)
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.
Mike, K8LH is offline  
Old 7th September 2007, 01:37 PM   (permalink)
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 01:49 PM.
Mike, K8LH is offline  
Old 11th September 2007, 02:46 PM   (permalink)
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.
dalmation is offline  
Old 11th September 2007, 02:50 PM   (permalink)
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.
dalmation is offline  
Old 11th September 2007, 02:55 PM   (permalink)
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.
dalmation is offline  
Old 12th September 2007, 02:21 PM   (permalink)
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
File Type: gif sameio.gif (14.5 KB, 21 views)
__________________
/Mats

Last edited by matseng; 12th September 2007 at 05:11 PM.
matseng is offline  
Old 12th September 2007, 02:47 PM   (permalink)
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.
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/

Last edited by ericgibbs; 12th September 2007 at 02:50 PM.
ericgibbs is online now  
Old 12th September 2007, 03:32 PM   (permalink)
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.
dalmation is offline  
Old 12th September 2007, 03:52 PM   (permalink)
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!!!!
dalmation is offline  
Old 12th September 2007, 05:14 PM   (permalink)
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.
__________________
/Mats
matseng is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
Using Oscilloscopes mechie Electronic Theory 9 29th November 2007 10:49 PM
driving multiplexed 7 segment display mathur2000 Micro Controllers 7 24th June 2007 11:08 PM
7 Segment Led Clock using PC signal vito3693 Electronic Projects Design/Ideas/Reviews 3 18th April 2007 04:22 AM
4-bit binary to decimal into dual 7 segment displays jupiter669 Electronic Projects Design/Ideas/Reviews 8 15th February 2004 03:06 AM
Convert Leds to 7 Segment Display Almazick General Electronics Chat 21 19th August 2003 08:53 PM



All times are GMT. The time now is 11:42 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker