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.

please help : how to drive 7 segment using 74hc595

Status
Not open for further replies.

engasm

New Member
this is my first post here
please help me in this

i wanna drive 7 segment using a 74hc595 shift register and pic
i have problems when i try to display numbers on the 7 segment
i get the zero then once i continue sending the code that should display the one i get random reading instead.
can any one tell me how the code must be in order to get numbers from 0 to 10 correctly here

i'm using pic16f48 as the controller on which i burn the code
 
Since none of us are psychic, please post a schematic of how you are driving the 7-segment.
 
i want a micro c or picbasic or picbasic pro code
i burn it as 16f84, it was a writing mistake
thnx 4 ur fast respond
 
Each number has a unique 7-bit code which is determined by the wiring between U12 and the 7-segment display. For each number you serial output the 7-bit code from U1 into U12 and then halt U12 to display the code (and number).

Without seeing the code or how the display is wired (what segment to which U12 output) it's impossible to know where your problem occurs.
 
code

below is my code, when execute it displays only number 2
i want an easy way with as small as possible code to make it goes from 0 to 9
i hope someone can help me with that
the circuit picture is attached in my previous post

Code:
'****************************************************************
'*  Name    : UNTITLED.BAS                                      *
'*  Author  : [select VIEW...EDITOR OPTIONS]                    *
'*  Notice  : Copyright (c) 2011 [select VIEW...EDITOR OPTIONS] *
'*          : All Rights Reserved                               *
'*  Date    : 9/11/2011                                         *
'*  Version : 1.0                                               *
'*  Notes   :                                                   *
'*          :                                                   *
'****************************************************************
trisb=$00
i VAR byte
j VAR byte

no1 VAR byte[7]
no2 VAR byte[7]
no3 VAR byte[7]

no1.0=1
no1.1=1
no1.2=0
no1.3=0
no1.4=1
no1.5=1
no1.6=1
no1.7=1

no2.0=1
no2.1=0
no2.2=0
no2.3=1
no2.4=0
no2.5=0
no2.6=1
no2.7=0

no3.0=1
no3.1=1
no3.2=1
no3.3=1
no3.4=1
no3.5=1
no3.6=0
no3.7=0

SER VAR PORTB.1
SRCK VAR PORTB.0
RCK  VAR PORTB.2
main:


                for i=0 to 3
                goto loop1
                label1:
                SER = 0'
                SER = 0'
   			    RCK = 1'   // clock RCK
        		RCK = 0'
        		pause 500
        		next i
        		
        		loop1:
 		        for j=7 to 0  STEP -1

        		SER = no2.0[j]'
                	    
				SRCK = 1'    // clock SRCK
				SRCK = 0'    
        	
        		
        		
        		next j
        		
        		goto label1 
        		

goto main




END
 
.........
the circuit picture is attached in my previous post
..........
The circuit diagram doesn't show how the connections are made to the 7-segment display (which wire to which segment). Without that it's not possible to determine what code you need.
 
the pins that are connected to the 7 segment are marked as this
a
b
c
d
e
f
g

from top to bottom
and the pins of the ic are clear in the picture
is that enough ?!
 
Below is the truth table for a 7-segment display. You generate code so you end of with the shown sequence for the desired number in the shift register.

For example for number 4, the code in the shift register would be:
Q7=1 (G) (1st serial bit output)
Q6=1 (F)
Q5=0 (E)
Q4=0 (D)
Q3=1 (C)
Q2=1 (B)
Q1=0 (A) (last serial bit output)

Do the same for all the other numbers. I don't understand your code well enough to tell you how to write it.

7-segment.gif
 
thnx a lot
i did wrote a code that goes from 0 to 9 in a loop
but know if i want to receive data from a serial input to the pic and display it in the 7 segment which i used shift register to drive
how this can be accomplished ?!!
 
The shift register has 8-bits and you are not using the Q0, so you output eight serial bits from the pic to the shift-register with the first seven being the segment bits (G-segment first), and the last bit is a don't care (either 1 or 0). After the 8-bit shift you stop the shift-register and the display will then read the segment output values (and if you did it right, the desired numeral).
 
could u explain it more ?! i don't get it
the pic will receive sth from an input using serial port in pic lets say its a tall sensor
and i want the pic after receiving how tall i am, in serial .
send it to the shift register so it will be displayed in the 7 segment
an example would be appreciated

thnx 4 ur fast response
 
What don't you get? The pic has to generate the serial output per the table I posted for the digit you want to display. As I said I don't really understand your pic code so you have to do that.

Don't see how I can simplify it any further.
 
can u write a code in any other language like micro c or others
all what i want to know is how can i display the number that i receive from serial port and stored in a variable lets say "Numbers"
how can i get the number out from the variable called number to transfer it into coded binary number and send it to shift register
how can i make this process alive or instantaneously
such that as the sensor reading changes the number in the 7 seg changes >

did i make my question clear ?
i'll accept a code in any language
 
I'm not much of a code writer so someone else will have to help you with that. But conceptually you can use a lookup table to convert the input number to the required sequence for the display. This lookup table can be stored in EPROM. For example the display sequence for number five could be stored as an 8-bit word at address 5 in the EPROM. Thus when number 5 is input, you go to EPROM address 5, which will have the sequence to display 5, which you then send out serially to the display shift register.
 
Since your driving a single 7 segment, you can cheat with a lookup table. Consult the instructions for whatever language you're programming in, nearly all of them have a lookup table function. Assign values provided by Carl's truth table to the lookup table's index positions 0 through 9. Then it's a matter of choosing the number you want, grabbing the appropriate binary code from the index position from the table and shifting it out to the '595.

In Proton Basic:
' index positons equal decimal value you want to display
' I'm going with LSB = 0, but it doesn't matter
' I didn't put all the values in, just 0, 1, 2 and 3
Segments = LookUp IDX, [252, 96, 242, 182]
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top