Jump to content
ELFORUM - Forumul electronistilor

7 segmente conectate la un PIC


ionut_h
 Share

Recommended Posts

salut,am un afisor lcd , nu gasesc modelul pe net.am incercat sa aflu ce reprezinta cei 29 de pini ai lui.am aflat segmentele a 2 digiti.va rog sa-mi spuneti cum fac legatura la un PIC?care e catodul in cazul asta?multumesc.

Link to comment
Share on other sites

am 2 segmente, deci 2 drivere CD4056. imi trebuie pic cu 18 pini ( 16f84) sau 40 pini (15f877a) ?intrarile pt cd4056 vin de la LCD?ce reprezinta intrarile a,b,c a lui cd4056?se poate sa-mi arati va rog o schema cu picul 16f877a si cu driverele CD4056? multumesc.

Link to comment
Share on other sites

cd4056 observasem ca e pentru lcd-uri. ce sa faci cu el la 7seg ?

 

iti dau ce am facut eu de curand, m-am jucat printre altele si cu 4digiti avand catod comun

Posted Image

nu ai nevoie de 16pini pt 2 digiti pt ca poti face foarte usor multiplexare, si ramai cu 10

pe portul b 7:0 pui liniile de date (a,b,c,...) iar pe portul c 4:0 ai comanda fiecarui digit + general

obs:

- trebuie sa adaptezi la 2 digiti totul.

- codul e luat copy paste selectiv de la mine, si trebuie sa te mai uiti tu .. in principiu ar trebui sa numere pana la 99

 

#include <pic.h>#include <stdio.h>#include <string.h>#include <math.h>#include <stdlib.h>#define t2 500#define t4 1bank2 unsigned short int time2, time4;bank2 unsigned int iter;// *********** region 7segments ************** //const char SSEG[] = { // de la drepta la stanga, ".GFEDCBA"  	0b00000101, // 0, LED Segment: A,B,C,D,E,F // de la drepta la stanga, ".GFEDCBA"  	0b11011101, // 1, LED Segment: B,C  	0b01000110, // 2, LED Segment: A,B,D,E,G  	0b01010100, // 3, LED Segment: A,B,C,D,G	0b10011100, // 4, LED Segment: B,C,F,G	0b00110100, // 5, LED Segment: A,C,D,F,G	0b00100100, // 6, LED Segment: A,C,D,E,F,G	0b01011101, // 7, LED Segment: A,B,C	0b00000100, // 8, LED Segment: A,B,C,D,E,F,G	0b00010100  // 9, LED Segment: A,B,C,D,F,G  };bank2 unsigned char DispDigit[4];bank2 unsigned char DigitCount;void SSEG_display(float);// *********** endregion 7segments ************** //void main(void) {	#asm("sei")  	#endasm	TRISB = 0x00;	TRISC = 0x00;	// ********* region TMR0 setup ********** //	// use internal CLK - !OPTION<5>, prescaler belongs to TMR0, 	// !WDT - !OPTION<3>, 1/64 prescaler OPTION<2,1,0>	OPTION = 0b10000111;	TMR0 = 236;	//	GIE = 1; // enable global interrupts INTCON<7>	T0IF = 0; // clear interrupt flag INTCON<2>	T0IE = 1; // enable Timer0 interrupt flag INTCON<5>	// ****** endregion TMR0 setup ********** //	// ******** region 7segments setup ********* //	RC4 = 1;	DigitCount = 0;	DispDigit[0]=SSEG[0];      // Zero Digit	DispDigit[1]=SSEG[0];      // Zero Digit  	DispDigit[2]=SSEG[0];      // Zero Digit  	DispDigit[3]=SSEG[0];      // Zero Digit  	// ******** endregion 7segments setup ****** //	time2 = t2;	time4 = t4;	iter = 0;	#asm("cli")  	#endasm	while(1) {		if (time4 == 0) task4(); // multiplexare 7segments  	}}void task2(void){	time2 = t2;	SSEG_display(++iter);	if(iter == 99) iter=0;}void task4(void){	time4 = t4;	PORTB = DispDigit[DigitCount];    switch(DigitCount){		case 0: { RC0=0;RC1=1;RC2=1;RC3=1; break; }		case 1: { RC0=1;RC1=0;RC2=1;RC3=1; break; }		case 2: { RC0=1;RC1=1;RC2=0;RC3=1; break; }		case 3: { RC0=1;RC1=1;RC2=1;RC3=0; break; }		default: break;    }    DigitCount++;    if (DigitCount > 3) DigitCount=0;}void SSEG_display(float power){	if(power >= 1000) return;	if(power >= 100)	{		DispDigit[0] = SSEG[power%10]; power/=10;		DispDigit[1] = SSEG[power%10]; power/=10;		DispDigit[2] = SSEG[power];		DispDigit[3] = SSEG[0];	}	else if(power <= 99)	{		DispDigit[0] = SSEG[power%10]; power/=10;		DispDigit[1] = SSEG[power];		DispDigit[2] = SSEG[0];		DispDigit[3] = SSEG[0];	}	else	{		DispDigit[0] = SSEG[power];		DispDigit[1] = SSEG[0];		DispDigit[2] = SSEG[0];		DispDigit[3] = SSEG[0];	}}void interrupt isr(void){	if (T0IE && T0IF ) 	{		if (time4 > 0) --time4;     	T0IF = 0;		TMR0 = 236;	}	}
bafta
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.Terms of Use si Guidelines