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.

Shifting(74LS164) is not working!!

Status
Not open for further replies.
To use a 74ls164 you shift data and clock it in the clear pin high if the clear pin is low it will not clock in. This video is with a 8 pin 12f683 and 3 74ls164 and 105 leds you can see it works. I just used the clock and data hold clear high [embed]http://www.youtube.com/v/ShmWUE1sRBM&hl=en&fs=1[/embed]
 
hi be80be ,

okay , i getting clearer what you mean , does it mean that i must hold the data pin and clear pin high all the way so that the clock can be pulsed into the 74ls164 ??
 
Two pins control the data the clock and the data pin you shift data in and clock it in till you load all your data but the clear pin has to stay high while this is happen your clear pin has to be going low if that happens no new data will load just move the clear pin to vdd add try it that way holding it high and load you code like you have it
 
Last edited:
hi be80be,

i will give a try once i get back to the lab...thanks for everything =) , i will get back to you sir after i try it out .

Regards
TK
 
Here what i'm saying hook your 74ls164 up like this and use just the data and clock to shift your data in I tried your code in mplab sim your only sending data out one time and it all looked right. It's shifting it out one bit a time and the clock was right and the clear line went high like it should.
 

Attachments

  • 877a.PNG
    877a.PNG
    11.5 KB · Views: 317
Last edited:
hi,be80be

you mean is i should put the clear pin high?? or make clear pin high is the mistake i did??
can me have a example of the code to make it send out other continuous data ??
thanks for helping me so much ..

Regards
TK
 
You have changed your code to like what Pommie showed you. Post your new code what your using and I help you get it going. Like I said I ran what you had posted And the only thing it wasn't doing right was shifting the data . But I think you fixed that if you added what mike told you to do. Read this it shows you how it all works PIC microcontrollers : chapter 7 - Examples. It's about using shift registers. You shift data like this.
1. load bit to to RC1
2. clock bit out
3. load next bit RC1
4 clock bit out
You keep doing that till you have loaded and shifted say all 8 bits
What the code you posted is doing is just loading the same thing over and over.
There will be no change.
So if you change your code post it and lets look at that
 
Last edited:
Hi,

I've just got my 6 digit display working when driven by serial to parallel data conversion.

Code / schematics attached in case they can be of any help or interest to the OP. The code is probably a bit long winded - only just got it working and haven't spent any time trying to compact / streamline it yet.
 

Attachments

  • Serial to Parallel.jpg
    Serial to Parallel.jpg
    222.1 KB · Views: 231
  • 6 digit display.jpg
    6 digit display.jpg
    318.3 KB · Views: 211
  • Serial2Parallel.asm
    7.5 KB · Views: 169
Hi be80be,
THANKS A LOT!!that help me a lot , because after mike help me in coding the part i should do it , i dun understand how to do t in my way of displaying character and ended up no output can be seen..the website i have tried , it's working..now i am working on the coding =)

Hi Angry,

Thanks for your schematic and coding , i will go into it as soon as i try out the 1 be80be gave me =)..it's a nice 1.
 
hi be80be

i got it working only the first column , it's not shifting...
is it correct that i do something like this??

Code:
	movlw .8
                movwf shift_count

                MOVLW  0x00 ;put data into f0
		MOVWF  	f0

		MOVLW	0x70
		MOVWF	f1
		
		
		MOVLW	0x88
		MOVWF	f2
		
		MOVLW	0x88
		MOVWF	f3
		
		MOVLW	0xff
		MOVWF	f4
		
		MOVLW	0x88
		MOVWF	f5
		
		MOVLW	0x88
		MOVWF	f6
		
		MOVLW	0x88
		MOVWF	f7


				
Shift1:	
		BSF	PORTC,1 ;DATA PIN SET TO HIGH

		RLF  	f0,f        ;ROTATE left data
		btfsc	f0,0        ;if test bit is 0 skip if test bit is 1 send 1 to 
		BSF	PORTD,0  ; bit 0 of PORTD
		
		
		RLF		f1,f ;70
		btfsC	f1,0
		BSF		PORTD,1
				

		RLF		f2,f ;88
		BTFSC	f2,0
		BSF		PORTD,2
				

		RLF		f3,f ;88
		BTFSC	f3,0
		BSF		PORTD,3
		
		RLF		f4,f ;ff
		BTFSC	f4,0
		BSF		PORTD,4
		
		RLF		f5,f ;88
		BTFSC	f5,0
		BSF		PORTD,5
		
		RLF		f6,f ;88
		BTFSC	f6,0
		BSF		PORTD,6
		
		RLF		f7,f ;88
		BTFSC	f7,0
		BSF		PORTD,7

		BCF	PORTC,1          ;set data pin to low

		GOTO CLK                 ;send clock to shift once
                CALL DELAY               
		DECFSZ	shift_count ;decrease counter for 8 times shifting
		GOTO Shift1                ;if shift_count <8 loop or else go to
		GOTO STANDBY            ;standby

is there any mistake i did that cause the 74ls164 is not shifting the second bit in??

update****

another thing that come in to my mind , is it i need to load all the 8 bits of the first data at first only i go into 8 bits of second data??

Regards,
TK
 
Last edited:
another thing that come in to my mind , is it i need to load all the 8 bits of the first data at first only i go into 8 bits of second data??
That's it I do it like this
Code:
HC164 macro  var,var1

         movlw   .8     ;8 bits to send out
         movwf   var1 ; counter to count out the bits
SendLoop:
         rlf         var,f          ;rotate var left one place
         btfss    STATUS,C  ; is carry a 1
         bcf        data         ; if not set data to 0
         btfsc    STATUS,C   ; is carry a 0
         bsf        data         ;if not set data to 1
         
         bsf       clock          ; generate a clock 
         nop                       ;two nop for clock delay
         nop
         bcf        clock
         decfsz  var1,f        ;has eight bit been sent 
        goto     SendLoop  ; if not go back and keep loading till done
 
Last edited:
Then you just have this in your main code to use it

Code:
          cblock  xxxxx           ; change xxxx to what it is 
          Tx
          CountSPI
          endc


main:
        movlw   0xcb          ;fulls the buffer
        movwf   Tx              ; Tx <- '110010011'
        HC164   Tx,CountSPI  ;lets the macro send the data
SendLoop:
        goto SendLoop
When I get home from work I'll post you a sample that you can try
 
Last edited:
That's it I do it like this
Code:
HC164 macro  var,var1

         movlw   .8     ;8 bits to send out
         movwf   var1 ; counter to count out the bits
SendLoop:
        [COLOR="Red"] rlf         var,f          ;rotate var left one place
         btfss    STATUS,C  ; is carry a 1
         bcf        data         ; if not set data to 0
         btfsc    STATUS,C   ; is carry a 0
         bsf        data         ;if not set data to 1[/COLOR]
         
         bsf       clock          ; generate a clock 
         nop                       ;two nop for clock delay
         nop
         bcf        clock
         decfsz  var1,f        ;has eight bit been sent 
        goto     SendLoop  ; if not go back and keep loading till done

hi be80be ,
thanks for staying with me so long . the code above i got some question too..those highlighted in red , STATUS is it same like var?? or it's the status inside file register??

from my previous coding i put something like this btfss var,c and btfsc var,c i didnt use macro to do it.

and other than that , my project actually is sending out data from microcontroller , so do i did the same as the example you did?? because from the code u posted it seem to be sending out data from register.wherelse mine should be sending out data from microcontroller and make it shift using shift register .
therefore , in short my shift register
1)data pin should be on always
2)after data come in from micro-controller
3)send in clock pulse to push data from microcontroller and shift it by 1 column

repeat from step 2 to step 3 until all the data has been send out.

Regards,
TK
 
It' the STATUS Status Register of the pic The var holds your data Like say 8 bits and the var1 counts them when it gets to 8 it rolls over If you added the code that Pommie showed you should be doing it right. Post what code your using now and lets look at it. From the code you have posted so far it looks like your only clocking once. A shift register like the 74ls164 has to clock in each bit so if you send 8 bits you clock eight times send bit 1 clock send bit 2 clock you see what I'm saying
 
hi be80be ,

okay , that means actually i cant wait until all 8 bits is loaded to the PORT eg.PORTD (0-7) only i send 1 clock pulse to send all 8 bits to column once??
because if i pulse every time bit goes in

e.g
PORTD,1 ;Portd pin 1 send 1 bit go in
call clock pulse
PORTD,2 ;PortD pin 2 send 1 bit go in
call clock pulse

and it will result in my character alignment run away from the origin doesn't it? because when clock pulse is sent in it will shift one time and the first bit will shift to second column and the second bit will shift to first column.

Regards
TK
 
hi be80be,
i just figure out something, below showing the red fonts coding which i after i tested out , i found that any code that after my delay is not working , for example below resulted in my count doesn't decrease and therefore it only show out 1 led is on.

and i suspect that's my delay problem..sir do you mind to have a look on the code below??

Code:
	cblock 0x20
	d1
	d2
	d3
	endc


Shift1	BSF		PORTC,1
		RLF 	11h,w
		MOVWF	11h
		BTFSC	11h,7 
		BSF		PORTD,0
		BTFSS	11h,7
		BCF		PORTD,0
		BCF		PORTC,1
		CALL 	CLK
	
		[COLOR="Red"]GOTO	DELAY2

		DECFSZ	19h,f
		GOTO Shift1
		GOTO Shift1[/COLOR]




CLK		BSF	PORTC,0
		NOP
		NOP
		NOP
		BCF	PORTC,0
	
		RETURN 

					; delay for test condition shift register


DELAY2
	movlw	0x03
	movwf	d1
	movlw	0x18
	movwf	d2
	movlw	0x02
	movwf	d3
Delay_0
	decfsz	d1, f
	goto	$+2
	decfsz	d2, f
	goto	$+2
	decfsz	d3, f
	goto	Delay_0
	RETURN
 
You have introduced two clock cycles per bit one of the rouitnes. This is a bad mistake. The clock sub-routine should be included in the routine to prevent a mistake like this.
 
hi colin,

ops i made some typo there sorry , btw i just figured out the problem.
Code:
Shift1	BSF		PORTC,1
	
		RLF 	11h,w
		MOVWF	11h
		BTFSC	11h,7 
		BSF		PORTD,0
		BTFSS	11h,7
		BCF		PORTD,0
		BCF		PORTC,1
		CALL	CLK
		call	DELAY
		DECFSZ	19h,f
		GOTO Shift1
		GOTO Shift1

DELAY					; common delay for all condition
		MOVLW	20		
		MOVWF	COUNT1
DELAY1	
		DECFSZ	COUNT2,1
		GOTO	DELAY1
		DECFSZ	COUNT1,1
		GOTO	DELAY1
		RETURN

the new code that i generated , at first when i generate the delay routine it's from

Code:
; Delay = 0.5 seconds
; Clock frequency = 4 MHz

; Actual delay = 0.5 seconds = 500000 cycles
; Error = 0 %

	cblock
	d1
	d2
	d3
	endc

Delay
			;499994 cycles
	movlw	0x03
	movwf	d1
	movlw	0x18
	movwf	d2
	movlw	0x02
	movwf	d3
[COLOR="Red"]Delay_0
	decfsz	d1, f
	goto	$+2
	decfsz	d2, f
	goto	$+2
	decfsz	d3, f
	goto	Delay_0

			;2 cycles
	goto	$+1[/COLOR]

			;4 cycles (including call)
	return
seem to be like some mistake in the generator therefore i get my own delay coding. it's working now

other than that , with the previously posted up schematic there's a component which actually is a must to put in , the ULN2803 which is darling pair transistor array which sink the current , ULN 2803 act like a ground for the led.

now i will try on getting the character on now. =) thanks
 
This is using your schematic and my code I had to change some things I for got to put in
Been a while I'll re post the code tomorrow.
[embed]http://www.youtube.com/v/V6Mtu7vRSvk&hl=en&fs=1& [/embed]
maybe even lay out some letters to scan.
 
Status
Not open for further replies.

Latest threads

Back
Top