Drive 4digit 7Segment by PIC16F84A

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

Drive 4digit 7Segment by PIC16F84A

Postby myzx » Wed Jan 11, 2012 11:53 am

Can anyone help me how to code to displaying simple multiplex 4x7 segment by using PIC16F84A. Simple, just display 1234 then delay 2second display 5678. Then it loop itself. Sorry i really noob in PIC. Plz.. Thanks :P
Attachments
09482-01_(1).jpg
4digit 7segment
09482-01_(1).jpg (8.27 KiB) Viewed 6192 times
4x7segent_(1).jpg
I want do like this but by using PIC16F84A
4x7segent_(1).jpg (26.51 KiB) Viewed 6192 times
User avatar
myzx
Greenhorn
 
Posts: 2
Joined: Wed Jan 11, 2012 10:15 am

Re: Drive 4digit 7Segment by PIC16F84A

Postby Brian Griffin » Wed Jan 11, 2012 12:07 pm

To multiplex (or "time-share") you must display one digit one at the time, very quickly until your eyes perceive it as looking at all the digits.

Have you started to light up one digit first, and get the segments lighted up correctly?

Also - if you have the chance - use a PIC16F628A which is an improved version of PIC16F84A.
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am

Re: Drive 4digit 7Segment by PIC16F84A

Postby ZaM » Wed Jan 11, 2012 12:10 pm

1. first you must try to ON at least 1 7-seg.
2. then try display 1234 using delay and loop to ON 1 segment on one time with speed that cannot be detect by human eye(blinking if using camera)
3. delay 2 second
4. display 5678 same as step 2
5. loop
ZaM
Moderator
 
Posts: 78
Joined: Tue Nov 23, 2010 4:16 pm

Re: Drive 4digit 7Segment by PIC16F84A

Postby ABSF » Wed Jan 11, 2012 4:58 pm

You need 4x PNP transistors for the digit drive (assuming LED is common anode) or else your PIC can get spolied. :?

Take a look at my board here:
http://forum.cytron.com.my/viewtopic.php?f=5&t=11348

Allen
The next war will determine NOT who is right BUT what is left.
User avatar
ABSF
Professional
 
Posts: 810
Joined: Wed Nov 10, 2010 9:32 am
Location: E Malaysia

Re: Drive 4digit 7Segment by PIC16F84A

Postby myzx » Wed Jan 11, 2012 8:53 pm

ZaM:
Only one digit at a time is active, but they change their state so quickly that one gets impression that all digits of a number are active simultaneously. Oh i see.
1.Thanks for the flows. Now i can code it easier.
2.Delay=10ms is it okay to make it blink of d'eye? What you prefer?

ABSF:
1.What you prefer d value for d Transistor the resistor if i'm using PNP Common Anode Transistor?
2.So if im using NPN Transistor so i must use Common Cathode(my output must 1 to enable digit)? While if i using PNP Transistor i should use Common Anode (my output must 0 to enable digit)? Is that right?
User avatar
myzx
Greenhorn
 
Posts: 2
Joined: Wed Jan 11, 2012 10:15 am

Re: Drive 4digit 7Segment by PIC16F84A

Postby shahrul » Wed Jan 11, 2012 10:21 pm

If using Common Cathode 7-segment, you can NPN transistor ex 2N2222 or you can use ULN2803 (transistor array).
Give the transistor high, will activate that 7-segment.
Related video
1. Electronic Dice
2. Timer and Stopwatch
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

Re: Drive 4digit 7Segment by PIC16F84A

Postby ABSF » Wed Jan 11, 2012 10:51 pm

myzx WROTE:ABSF:
1.What you prefer d value for d Transistor the resistor if i'm using PNP Common Anode Transistor?
2.So if im using NPN Transistor so i must use Common Cathode(my output must 1 to enable digit)? While if i using PNP Transistor i should use Common Anode (my output must 0 to enable digit)? Is that right?


Exactly. Follow Shahrul's connections and you'll be OK. If you want to use 16F84A or 16F628A, just connect the RB0-RB7 to the segment a-g &dp of the 7-segment LED. Connect RA0-RA3 to the digit driver. Put a 10K resistor on MCLR to Vcc. Dont forget to set CMCON=7; in your program.

Allen
The next war will determine NOT who is right BUT what is left.
User avatar
ABSF
Professional
 
Posts: 810
Joined: Wed Nov 10, 2010 9:32 am
Location: E Malaysia

Re: Drive 4digit 7Segment by PIC16F84A

Postby takao21203 » Mon Mar 19, 2012 7:58 pm

Hello I saw your post.

It is possible to drive 4digit LED display with some PIC directly, no resistors or transistors.

For instance I made one LED display with serial interface, based on 16f54, no extra parts are used.
The multiplex is 8x, every second phase is blank, and this is also used to clock in data.
However I'd rather recommend hardware serial port for this.

Lately I rather use C, not so much RISC assembly, because poor maintainability.
There is more information in this thread on picvietnam.com
http://www.picvietnam.com/forum/showthread.php?t=9976

Some attachments need login to see them but there are also pictures visible without login.

If you have worry about burnout of PIC, use lower voltage for instance 3 volts.

By the way I clicked the links and saw the stop watch. I started this morning with new circuit which actually, also is a stopwatch. It is based on the new 12f1822, and serial display. Circuit board can be much smaller, and it's faster to build.
I have not yet worked the master interface in Hitech C, only RISC assembly exists :)
And I want to try some new idea with this circuit. It has 1.2v battery supply.

stopwatch.jpg
User avatar
takao21203
Discoverer
 
Posts: 111
Joined: Mon Mar 19, 2012 7:52 pm
Location: Ireland, Europe

Re: Drive 4digit 7Segment by PIC16F84A

Postby ABSF » Mon Mar 19, 2012 11:17 pm

May be putting resistors between PIC and 7-segment LEDs are just good practice. I would put them in unless my PCB is short of space. It all depends on indivisuals. I have notice some beginners never bother to put in resistors when blinking LEDs on the SK40C. But as PICs are getting cheaper each day, so who cares... :roll:

As a hobbyist, I dont mind to burn a 16F628a or 12F629 but I wont risk the more expensive 40 pin or 68 pin PLCC PICs on this.

Allen
The next war will determine NOT who is right BUT what is left.
User avatar
ABSF
Professional
 
Posts: 810
Joined: Wed Nov 10, 2010 9:32 am
Location: E Malaysia

Re: Drive 4digit 7Segment by PIC16F84A

Postby Brian Griffin » Mon Mar 19, 2012 11:21 pm

ABSF WROTE:May be putting resistors between PIC and 7-segment LEDs are just good practice. I would put them in unless my PCB is short of space. It all depends on indivisuals. I have notice some beginners never bother to put in resistors when blinking LEDs on the SK40C. But as PICs are getting cheaper each day, so who cares... :roll:

As a hobbyist, I dont mind to burn a 16F628a or 12F629 but I wont risk the more expensive 40 pin or 68 pin PLCC PICs on this.

Allen


Putting resistors between things with lights and microcontrollers is my habit already.

Burning these lower end PICs are not fun - sometimes they are not even cheap! Last time I seen a 16F628a cost like RM8 something... :lol:
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am

Next

Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 7 guests

cron