7-segment display with P16F84


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Jul 2007
    Posts
    5

    Default 7-segment display with P16F84

    Hi all, I am new to PIC's but have been studying electronics for 3 years and work as a technician.

    I recently came across this site http://www.melabs.com/resources/articles/ledart.htm
    with instruction on how to run 7-segment display, i have built the circuit and programmed the PIC with this code: http://www.melabs.com/resources/samp...p/7segment.pbp
    but the numbers run really fast and display 0 runs too fast to read it, I have tried adding a PAUSE 1000 under "mainloop" and just below GOSUB display but it only make the displays flash on and off

    I am trying to get them to display a number for atleast 1 second each or atleast make it so i can read digit 0

    PS I have tried contacting the site but they never got back to me.

    Thanks is advance.
    once I get this working and learn a little more I plan on adding push buttons and making it into a stopwatch or either a countdown timer.

    Raf

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default

    Code:
    i	Var	Byte
    n	Var	Byte
    Value	Var	Word
    
    
    	TRISB = $80		' Set segment pins to output
    	TRISA = $f0		' Set digit pins to output
    
    mainloop:
    	For Value = 0 To 9999
    		GoSub display	' Display the value
    	Next Value
    	
    	GoTo mainloop		' Do it forever
    You need to modify this patch to something like this
    Code:
    i	Var	Byte
    n	Var	Byte
    Value	Var	Word
    timedelay      var        word
    
    	TRISB = $80		' Set segment pins to output
    	TRISA = $f0		' Set digit pins to output
    
    mainloop:
    	For Value = 0 To 9999
                    for timedelay = 0 to 2000
    		GoSub display	' Display the value
                    next
    	Next Value
    	
    	GoTo mainloop		' Do it forever
    The value you choose for the timedelay will help you persist a value for as long as you choose.

    Jerson
    Last edited by Jerson; - 9th July 2007 at 13:02.

  3. #3
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by spitfire View Post
    Hi all, I am new to PIC's but have been studying electronics for 3 years and work as a technician.

    I recently came across this site http://www.melabs.com/resources/articles/ledart.htm
    with instruction on how to run 7-segment display, i have built the circuit and programmed the PIC with this code: http://www.melabs.com/resources/samp...p/7segment.pbp
    but the numbers run really fast and display 0 runs too fast to read it, I have tried adding a PAUSE 1000 under "mainloop" and just below GOSUB display but it only make the displays flash on and off

    I am trying to get them to display a number for atleast 1 second each or atleast make it so i can read digit 0

    PS I have tried contacting the site but they never got back to me.

    Thanks is advance.
    once I get this working and learn a little more I plan on adding push buttons and making it into a stopwatch or either a countdown timer.

    Raf

    This is the section of code you should try to alter

    Code:
    display:
    	For i = 0 To 3		' Loop through 4 digits
    		n = Value Dig i	' Get digit to display
    		GoSub display1	' Display the digit
    		Pause 1		' Leave it on 1 millisecond
    	Next i			' Do next digit
    	Return
    This displays each digit for 1 millisecond. try increasing the length of the pause.

    By adding your Pause 1000 in the main loop you are adding a 1 second delay between counting. The LEDs are only lit during the display subroutine so you have 4mS of display and then a second waiting to the next 4mS.

    Try a 25mS delay (PAUSE 25) or longer to make the digits more visible but you may then notice a flicker across the digits.

    Try adding another counting loop so that you only increment the 0-9999 count once every "x" passes through the main loop.

    HTH

    Keith
    Keith

    www.diyha.co.uk
    www.kat5.tv

  4. #4
    Join Date
    Jul 2007
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    Thank alot guys, I was hardly expecting such promt replys.
    I will try your suggestions out now.

  5. #5
    Join Date
    Jul 2007
    Posts
    5


    Did you find this post helpful? Yes | No

    Thumbs up

    I got it working using your method Jerson by setting "for timedelay = 0 to 100", works great.

    I was wondering if someone could recomend some books or any other good sources of information for writing code?

    Cheers,
    Raf

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hi Spitfire,
    I have bought several books, and without this forum, I would be using them as table levelers, I do not have one I would recommend. Keep reading this forum and the PBP manual, read the archives . . every post, thats waaay better than any book I've seen. Bruce is writing one though and when it is published, I will buy one.
    JS
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  7. #7
    Join Date
    Dec 2006
    Posts
    18


    Did you find this post helpful? Yes | No

    Default

    Does anyone know where i can get one of those 3 digit seven segment displays that are designed to be multiplexed. aka has 12 pins instead of well loads more.

Similar Threads

  1. 7 Segment Displays and MAX7219
    By Bill Legge in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 31st October 2010, 18:30
  2. Weird compile issue 7 segment LED display
    By George in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 21st June 2006, 02:12
  3. 7 segment digit problem (using Mister E's code)
    By jmgelba in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 9th September 2005, 20:25
  4. WRITE not working
    By servo260 in forum mel PIC BASIC Pro
    Replies: 31
    Last Post: - 29th December 2004, 02:02
  5. Multiplex two 7 segment display
    By Fernando Santos in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 20th July 2003, 13:26

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts