![]() | ![]() | ![]() |
| | |||||||
| 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. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| 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.
__________________ 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. | |
| |
| | (permalink) |
| 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 ; Last edited by Mike, K8LH; 6th September 2007 at 11:34 PM. | |
| |
| | (permalink) |
| 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/ | |
| |
| | (permalink) |
| Does this look correct? Conventional wiring to multiplexed or non-multiplexed common cathode displays. Last edited by Mike, K8LH; 15th September 2007 at 12:37 PM. | |
| |
| | (permalink) |
| hi, Looks the same as my sketch.
__________________ 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. | |
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) | |
| Quote:
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
;****************************************************************** 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. | ||
| |
| | (permalink) | |
| Quote:
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. | ||
| |
| | (permalink) | |
| Quote:
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. | ||
| |
| | (permalink) |
| 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. | |
| |
| | (permalink) |
| 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.
__________________ /Mats Last edited by matseng; 12th September 2007 at 05:11 PM. | |
| |
| | (permalink) | |
| Quote:
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. | ||
| |
| | (permalink) | |
| Quote:
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. | ||
| |
| | (permalink) | ||||
| Quote:
Quote:
Quote:
Quote:
I'm off to look up some space saving resistor arrays to keep within my pcb outline. Once again- THANKS!!!! | |||||
| |
| | (permalink) |
| 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 | |
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| 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 |