Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 17th February 2009, 04:24 AM   #1
Question 74HC164 Shift Register Doubt

I have been fine tuning my 5(columns) X 7(rows) matrix system using 74HC164.
But still I'm not getting a smooth display result.I'm doubt with the "Clock_Pulse" routine.

Code:
Do_Show		call	Reset		;reset 74HC
		bsf	Data		;make 74HC data pin high for the first time
		movf	Col1,W
		call	Clock_Pulse
		bcf	Data		;make 74HC data pin low 
		movf	Col2,W
		call	Clock_Pulse
		movf	Col3,W
		call	Clock_Pulse
		movf	Col4,W
		call	Clock_Pulse
		movf	Col5,W
		call	Clock_Pulse
		goto	Do_Show	


Clock_Pulse	movwf	Col_Data	;get the column data
		clrf	PORTB						
		bsf	Clock		;low to high transition
		bcf	Clock		;make low for next transition
		movf	Col_Data,W
		movwf	PORTB														
		return
__________________
Gayan

My Website
http://gsmicro.blogspot.com/
Gayan Soyza is offline  
Old 17th February 2009, 04:37 AM   #2
Default

add a single nop between bsf and bcf
Code:
..
		bsf	Clock		;low to high transition
                nop                          ;give shift register time to act
		bcf	Clock		;make low for next transition
...
depending on the clock of your uC and the type of the shift register you might add more then one nop (note that HC is few times slower then HCT especially if you are running it on 3V - if you are using 5V rails only - use HCT .. much faster)
arhi is offline  
Old 17th February 2009, 04:42 AM   #3
Default

I just checked the DS, the min time for the pulse is 5ns so one nop is enough
arhi is offline  
Old 17th February 2009, 04:44 AM   #4
Default

Hi arhi thanks for you help.

Crystal is 4Mhz.Supply is 5V.
The letter is displaying but I can see an additional column.Also I can see the off state LEDs also lights very dimly.

I have put an 4.7K pullup resister to the reset pin of 74HC.I think that also better if I can remove and connect that reset pin to direct to PIC.
__________________
Gayan

My Website
http://gsmicro.blogspot.com/
Gayan Soyza is offline  
Old 17th February 2009, 04:52 AM   #5
Default

the HC is fast enough for what you need but in general, HCT is faster not that it would make many difference .. you need that nop for the clock ...

now, that's what you need to change in the pulse sub ... as for the whole code .. it looks ok ... try with the nop and say if it is ok now
arhi is offline  
Old 17th February 2009, 04:56 AM   #6
Default

Earlier I did my Reset routine like this with tristate condition.

Code:
Reset		bsf	STATUS,RP0
		bcf	TRISA,2		;make RA2 output
		bcf	STATUS,RP0
		;
		bcf	PORTA,2		;reset pulse
		nop			;//
		nop			;//
		bsf	STATUS,RP0
		bsf	TRISA,2		;;make RA2 input
		bcf	STATUS,RP0
		return
After calling this "Reset" Routine that 4.7K pullup resister will hold the reset pin of 74HC high.I don't know why I did like that stupid.
__________________
Gayan

My Website
http://gsmicro.blogspot.com/

Last edited by Gayan Soyza; 17th February 2009 at 04:57 AM.
Gayan Soyza is offline  
Old 17th February 2009, 05:07 AM   #7
Default

IIRC reset pin is active low, so if you push up with 10K (or 4.7K, I prefere 10K) and do what you did it should work ... but .. why would you do it ? if you are reserving a pin for reset pin, you do not need to pull-up .. just connect to pic, bcf reset; nop, nop, bsf reset ... and go forward
arhi is offline  
Old 17th February 2009, 05:11 AM   #8
Default

I totally agree with you arhi I'll try with the adjustments & tell the latest progress.
__________________
Gayan

My Website
http://gsmicro.blogspot.com/
Gayan Soyza is offline  
Old 17th February 2009, 05:46 AM   #9
Default

I found what I used to get mine to work
Code:
Dataout macro Var,Var1
	Local 	Loop
	movlw	.8
	movwf	Var1
Loop  rlf	Var,f
	btfss	STATUS,C
	bcf	Data
	btfsc	STATUS,C
	bsf	Data
	bsf	Clock
	nop
	nop
	nop
	nop
	bcf	Clock
	decfsz 	Var1,f
	goto	Loop
	endm
which it the same s arhi I added some nop to get a good clock
be80be is offline  
Old 17th February 2009, 05:51 AM   #10
Default

I have change my shift registers 74hc595n it has a latch thay work alot better and only 19cents each
be80be is offline  
Old 17th February 2009, 05:52 AM   #11
Default

latch is nice but requires extra pin
arhi is offline  
Old 17th February 2009, 07:05 AM   #12
Default

HI be80be thanks for your contribute.

By looking at your code can you tell are you feeding the row data via a shift register or direct from PORTB?
__________________
Gayan

My Website
http://gsmicro.blogspot.com/

Last edited by Gayan Soyza; 17th February 2009 at 07:06 AM.
Gayan Soyza is offline  
Old 17th February 2009, 02:37 PM   #13
Default

here this shows better the macro sends the data out and this shows how it is loaded
Code:
Main					;main program

	movlw	0x07
	movwf	CMCON			;turn comparators off (make it like a 16F84)
	banksel TRISA
	movlw	b'00011000'		;initializing porta
	movwf	TRISA
	banksel	PORTA
	clrf 	PORTA
Send
	movlw 	b'00000001'			;fill tx buffer
	movwf	TX
	HC4015 TX,CountSPI
	goto	Send1
Send1
	movlw 	b'00000010'			;fill tx buffer
	movwf	TX
	HC4015 TX,CountSPI
	goto	Send2
Send2
	movlw 	b'00000100'			;fill tx buffer
	movwf	TX
	HC4015 TX,CountSPI
	goto	Send3
Send3
	movlw 	b'00001000'			;fill tx buffer
	movwf	TX
	HC4015 TX,CountSPI
	goto Send4
Send4
	movlw 	b'00010000'			;fill tx buffer
	movwf	TX
	HC4015 TX,CountSPI
	goto Send5
Send5
	movlw 	b'00010000'			;fill tx buffer
	movwf	TX
	HC4015 TX,CountSPI
	goto	Send6
Send6
	movlw 	b'00100000'			;fill tx buffer
	movwf	TX
	HC4015 TX,CountSPI
	goto	Send7
Send7
	movlw 	b'01000000'			;fill tx buffer
	movwf	TX
	HC4015 TX,CountSPI
	goto Send8
Send8
	movlw 	b'10000000'			;fill tx buffer
	movwf	TX
	HC4015 TX,CountSPI
	goto Send		
Loop

Last edited by be80be; 17th February 2009 at 02:39 PM.
be80be is offline  
Old 18th February 2009, 02:57 AM   #14
Default

Hi Arhi I solved my clock pulse routine.You must waste cycles after clearing the PORTB.
Also I added that nop as well
Code:
;**********************************
;Clock pulse routine to SR-74HC164
;**********************************

Clock_Pulse	movwf	Col_Data	;save column data
		clrf	PORTB
		goto	$+1
		goto	$+1
		goto	$+1
		goto	$+1
		goto	$+1												
		bsf	PORTA,0		;low to high transition
		nop				
		bcf	PORTA,0		;make low for next transition
		nop
		movf	Col_Data,W
		movwf	PORTB	
		goto	$+1
		goto	$+1
		return
__________________
Gayan

My Website
http://gsmicro.blogspot.com/

Last edited by Gayan Soyza; 18th February 2009 at 02:58 AM.
Gayan Soyza is offline  
Old 18th February 2009, 03:01 AM   #15
Default

Now a serious problem I'm having.I spent many hours to solve my new problem but I couldn't do that.

I can scroll a letter from right to left slowly.When I make it speed scrolling it displays like mirroring.Not smooth lines moving.

I have put a new thread regarding this for assistance.

Led Matrix Mirroring Problem.
__________________
Gayan

My Website
http://gsmicro.blogspot.com/

Last edited by Gayan Soyza; 18th February 2009 at 03:31 AM.
Gayan Soyza is offline  
Reply

Tags
74hc164, doubt, register, shift

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
shift register question stef_eng Electronic Projects Design/Ideas/Reviews 1 11th October 2008 10:32 PM
Shift register mstechca General Electronics Chat 1 19th December 2005 12:45 AM
EDO RAM as Shift Register aurosunil General Electronics Chat 0 17th August 2004 10:25 AM
Using Shift Register toyracer Electronic Projects Design/Ideas/Reviews 5 13th November 2003 02:19 PM



All times are GMT. The time now is 09:09 PM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker