Cos'è ElectroYou | Login Iscriviti

ElectroYou - la comunità dei professionisti del mondo elettrico

Interfacciamento [PIC18F2550] con LCD 16x2

Tipologie, strumenti di sviluppo, hardware e progetti

Moderatore: Foto UtentePaolino

0
voti

[21] Re: Interfacciamento [PIC18F2550] con LCD 16x2

Messaggioda Foto UtenteIlGuru » 1 ott 2015, 0:39

CarloD ha scritto:Ho notato che i pin del display D0 D1 D2 e D3 che non sono collegati se verifico con la sonda dell'oscilloscopio trovo 5 V su tutti.


Male. Vanno collegati a massa.

Quello che hai segnato con CLOCK rappresenta il segnale E del display?
\Gamma\nu\tilde{\omega}\theta\i\ \sigma\epsilon\alpha\upsilon\tau\acute{o}\nu
Avatar utente
Foto UtenteIlGuru
5.317 2 10 13
G.Master EY
G.Master EY
 
Messaggi: 1910
Iscritto il: 31 lug 2015, 23:32

0
voti

[22] Re: Interfacciamento [PIC18F2550] con LCD 16x2

Messaggioda Foto UtenteWALTERmwp » 1 ott 2015, 1:08

IlGuru ha scritto:Male. Vanno collegati a massa.
non è necessario, almeno per quanto riguarda le mie esperienze poi, tutto è possibile.
Non credo il problema sia questo, ma lo troveremo, se non si stanca prima l'OP.

Saluti
W - U.H.F.
Avatar utente
Foto UtenteWALTERmwp
29,7k 4 8 13
G.Master EY
G.Master EY
 
Messaggi: 8820
Iscritto il: 17 lug 2010, 18:42
Località: le 4 del mattino

0
voti

[23] Re: Interfacciamento [PIC18F2550] con LCD 16x2

Messaggioda Foto UtenteWALTERmwp » 1 ott 2015, 14:07

Proviamo ad accanirci ancora sulle tempistiche, anche se ormai stiamo raschiando il fondo.
All'inizio, dopo aver posto a zero RS, modifica il ritardo passando da 500 ms a 200us.

Poi, tornando sui passi già compiuti, per quanto riguarda lo hardware
CarloD ha scritto:Al momento ho inserito anche una resistenza di pull-down (15K) sulle porte RB0-RB1-RB2-RB3-RC0-RC2.
lasciando una resistenza per ogni pin, collegale in pull-up.

Prova e facci sapere, grazie.

Saluti
W - U.H.F.
Avatar utente
Foto UtenteWALTERmwp
29,7k 4 8 13
G.Master EY
G.Master EY
 
Messaggi: 8820
Iscritto il: 17 lug 2010, 18:42
Località: le 4 del mattino

0
voti

[24] Re: Interfacciamento [PIC18F2550] con LCD 16x2

Messaggioda Foto UtenteCarloD » 7 ott 2015, 22:50

Il segnale che avevo erroneamente etichettato clock è il segnale E del display.
Ho provveduto comunque a collegare a 0V i pin del display D0 D1 D2 D3 (non utilizzati).
Ho provveduto a mettere le resistenza in pull-up.
Ho modificato il ritardo passando da 500 ms a 200us, dopo aver impostato a 0 RS.
Mi dispiace dovervi dire che l'esito è ancora negativo.
Dovrebbe arrivarmi a giorni un display nuovo per sostituirlo così possiamo escludere il malfunzionamento di quello attuale.
Se avete altri suggerimenti a riguardo sarò contento di implementarli.

Grazie come sempre del tempo dedicatomi

Carlo
Avatar utente
Foto UtenteCarloD
10 2
 
Messaggi: 14
Iscritto il: 5 set 2015, 14:55

0
voti

[25] Re: Interfacciamento [PIC18F2550] con LCD 16x2

Messaggioda Foto UtenteWALTERmwp » 7 ott 2015, 23:00

Tutto quello che abbiamo provato è stato fatto confidando nell'integrità dello LCD.
A questo punto, in attesa del nuovo arrivo, lascerei inalterato il codice.
Anche se lo hai già fatto, ti suggerirei di ricontrollare i collegamenti e che tra un pin e l'altro del display non vi sia qualche "corto".
Potresti anche rifare le saldature e riprovare, vuoi mai che ce ne sia una fredda ?

Saluti
W - U.H.F.
Avatar utente
Foto UtenteWALTERmwp
29,7k 4 8 13
G.Master EY
G.Master EY
 
Messaggi: 8820
Iscritto il: 17 lug 2010, 18:42
Località: le 4 del mattino

0
voti

[26] Re: Interfacciamento [PIC18F2550] con LCD 16x2

Messaggioda Foto UtenteCarloD » 18 ott 2015, 21:51

Sostituzione LCD eseguita e risaldature rifatte.
il risultato è il medesimo. :(
Avatar utente
Foto UtenteCarloD
10 2
 
Messaggi: 14
Iscritto il: 5 set 2015, 14:55

0
voti

[27] Re: Interfacciamento [PIC18F2550] con LCD 16x2

Messaggioda Foto UtenteWALTERmwp » 18 ott 2015, 22:00

Puoi riportare una foto che comprende il PIC e l'LCD, così da avere visibilità sul collegamento che c'è tra i due ?
Specifica il codice del display.
Inserisci anche il sorgente del programma, completo, così come lo hai compilato.

Saluti
W - U.H.F.
Avatar utente
Foto UtenteWALTERmwp
29,7k 4 8 13
G.Master EY
G.Master EY
 
Messaggi: 8820
Iscritto il: 17 lug 2010, 18:42
Località: le 4 del mattino

1
voti

[28] Re: Interfacciamento [PIC18F2550] con LCD 16x2

Messaggioda Foto UtenteCarloD » 18 ott 2015, 23:52

Ottime notizie :-)
Ci siamo.....
ho provato a riscrivere il codice seguendo le istruzioni riportando pari pari quanto scritto a pag.42 del data sheet del HD44780U, con l'unica variante allo step#3 dove indico che è un LCD con 2 linee e non 1.
dis seguito riporto il codice riscritto:
Codice: Seleziona tutto
/*LCDMain versione 2.0.0

*/

/** C O N F I G U R A T I O N      B I T S**********************************/

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

// CONFIG1L
#pragma config PLLDIV = 1       // PLL Prescaler Selection bits (No prescale (4 MHz oscillator input drives PLL directly))
#pragma config CPUDIV = OSC1_PLL2// System Clock Postscaler Selection bits ([Primary Oscillator Src: /1][96 MHz PLL Src: /2])
#pragma config USBDIV = 1       // USB Clock Selection bit (used in Full-Speed USB mode only; UCFG:FSEN = 1) (USB clock source comes directly from the primary oscillator block with no postscale)

// CONFIG1H
#pragma config FOSC = HS        // Oscillator Selection bits (HS oscillator (HS))
#pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)
#pragma config IESO = OFF       // Internal/External Oscillator Switchover bit (Oscillator Switchover mode disabled)

// CONFIG2L
#pragma config PWRT = OFF       // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOR = ON         // Brown-out Reset Enable bits (Brown-out Reset enabled in hardware only (SBOREN is disabled))
#pragma config BORV = 3         // Brown-out Reset Voltage bits (Minimum setting)
#pragma config VREGEN = OFF     // USB Voltage Regulator Enable bit (USB voltage regulator disabled)

// CONFIG2H
#pragma config WDT = OFF        // Watchdog Timer Enable bit (WDT disabled (control is placed on the SWDTEN bit))
#pragma config WDTPS = 32768    // Watchdog Timer Postscale Select bits (1:32768)

// CONFIG3H
#pragma config CCP2MX = ON      // CCP2 MUX bit (CCP2 input/output is multiplexed with RC1)
#pragma config PBADEN = OFF     // PORTB A/D Enable bit (PORTB<4:0> pins are configured as digital I/O on Reset)
#pragma config LPT1OSC = OFF    // Low-Power Timer 1 Oscillator Enable bit (Timer1 configured for higher power operation)
#pragma config MCLRE = ON       // MCLR Pin Enable bit (MCLR pin enabled; RE3 input pin disabled)

// CONFIG4L
#pragma config STVREN = ON      // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
#pragma config LVP = ON         // Single-Supply ICSP Enable bit (Single-Supply ICSP enabled)
#pragma config XINST = OFF      // Extended Instruction Set Enable bit (Instruction set extension and Indexed Addressing mode disabled (Legacy mode))

// CONFIG5L
#pragma config CP0 = OFF        // Code Protection bit (Block 0 (000800-001FFFh) is not code-protected)
#pragma config CP1 = OFF        // Code Protection bit (Block 1 (002000-003FFFh) is not code-protected)
#pragma config CP2 = OFF        // Code Protection bit (Block 2 (004000-005FFFh) is not code-protected)
#pragma config CP3 = OFF        // Code Protection bit (Block 3 (006000-007FFFh) is not code-protected)

// CONFIG5H
#pragma config CPB = OFF        // Boot Block Code Protection bit (Boot block (000000-0007FFh) is not code-protected)
#pragma config CPD = OFF        // Data EEPROM Code Protection bit (Data EEPROM is not code-protected)

// CONFIG6L
#pragma config WRT0 = OFF       // Write Protection bit (Block 0 (000800-001FFFh) is not write-protected)
#pragma config WRT1 = OFF       // Write Protection bit (Block 1 (002000-003FFFh) is not write-protected)
#pragma config WRT2 = OFF       // Write Protection bit (Block 2 (004000-005FFFh) is not write-protected)
#pragma config WRT3 = OFF       // Write Protection bit (Block 3 (006000-007FFFh) is not write-protected)

// CONFIG6H
#pragma config WRTC = OFF       // Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) are not write-protected)
#pragma config WRTB = OFF       // Boot Block Write Protection bit (Boot block (000000-0007FFh) is not write-protected)
#pragma config WRTD = OFF       // Data EEPROM Write Protection bit (Data EEPROM is not write-protected)

// CONFIG7L
#pragma config EBTR0 = OFF      // Table Read Protection bit (Block 0 (000800-001FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR1 = OFF      // Table Read Protection bit (Block 1 (002000-003FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR2 = OFF      // Table Read Protection bit (Block 2 (004000-005FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR3 = OFF      // Table Read Protection bit (Block 3 (006000-007FFFh) is not protected from table reads executed in other blocks)

// CONFIG7H
#pragma config EBTRB = OFF      // Boot Block Table Read Protection bit (Boot block (000000-0007FFh) is not protected from table reads executed in other blocks)

/** I N C L U D E S*********************************************************/
#include "xc.h"
#include "delays.h"

/** V A R I A B L E S*******************************************************/
int i;
int s;
/** D E C L A R A T I O N S*************************************************/
#define _XTAL_FREQ 12000000

#define RS_PIN   LATCbits.LATC0      /* PORT for RS */
#define TRIS_RS  TRISCbits.TRISC0       /* TRIS for RS */

#define E_PIN   LATCbits.LATC2     /* PORT for E  */
#define TRIS_E   TRISCbits.TRISC2       /* TRIS for E  */

#define LED    LATAbits.LATA4     /* PORT for LED  */
#define TRIS_LED   TRISAbits.TRISA4       /* TRIS for LED  */

#define LCD_D7  LATBbits.LATB3 /* PORT for D7 LCD */
#define TRIS_D7 TRISBbits.TRISB3    /* TRIS for D7 LCD */

#define LCD_D6  LATBbits.LATB2 /* PORT for D6 LCD */
#define TRIS_D6 TRISBbits.TRISB2 /* TRIS for D6 LCD */

#define LCD_D5  LATBbits.LATB1 /* PORT for D5 LCD */
#define TRIS_D5 TRISBbits.TRISB1    /* TRIS for D5 LCD */

#define LCD_D4  LATBbits.LATB0 /* PORT for D4 LCD */
#define TRIS_D4 TRISBbits.TRISB0 /* TRIS for D4 LCD */

// dichiarazione prototipi funzioni
int delay500 (void);
int E_Pulse_H(void);
int E_Pulse_L(void);

// ***********************MAIN******************************************
int main( void )
{
    //imposto direzione porte
    TRIS_RS = 0;
    TRIS_E = 0;
    TRIS_D7 = 0;
    TRIS_D6 = 0;
    TRIS_D5 = 0;
    TRIS_D4 = 0;
    ADCON1 = 0x0f;
//LED per "debug" e ritardo 1s per assicurare power on
    TRIS_LED = 0;
    LED = 1;
    delay500();
    LED = 0;
//Imposto pin RS display per comandi
    RS_PIN = 0;
    __delay_us(200);
// ***************************INIT********************************************
   
        E_Pulse_H();
   LCD_D7 = 0;
        LCD_D6 = 0;
        LCD_D5 = 1;
        LCD_D4 = 0;
        E_Pulse_L();
        __delay_us(200);

        E_Pulse_H();
   LCD_D7 = 0;
        LCD_D6 = 0;
        LCD_D5 = 1;
        LCD_D4 = 0;
        E_Pulse_L();
        __delay_us(200);

       
       E_Pulse_H();
       LCD_D7 = 1;
       LCD_D6 = 0;
       LCD_D5 = 0;
       LCD_D4 = 0;
       E_Pulse_L();
       __delay_us(200);

       E_Pulse_H();
       LCD_D7 = 0;
       LCD_D6 = 0;
       LCD_D5 = 0;
       LCD_D4 = 0;
       E_Pulse_L();
       __delay_us(200);

       E_Pulse_H();
       LCD_D7 = 1;
       LCD_D6 = 1;
       LCD_D5 = 1;
       LCD_D4 = 0;
       E_Pulse_L();
       __delay_us(200);

       E_Pulse_H();
       LCD_D7 = 0;
       LCD_D6 = 0;
       LCD_D5 = 0;
       LCD_D4 = 0;
       E_Pulse_L();
       __delay_us(200);

       E_Pulse_H();
       LCD_D7 = 0;
       LCD_D6 = 1;
       LCD_D5 = 1;
       LCD_D4 = 0;
       E_Pulse_L();
       __delay_us(200);
//*********************************INIT END***********************************

//Imposto il pin RS a 1 per scrivere un dato
    RS_PIN = 1;
    __delay_us(200);
//****************************************************************************
// scrivo carattere H = 01001000
    E_Pulse_H();
    LCD_D7 = 0;
    LCD_D6 = 1;
    LCD_D5 = 0;
    LCD_D4 = 0;
    E_Pulse_L();
    __delay_us(200);
    E_Pulse_H();
    LCD_D7 = 1;
    LCD_D6 = 0;
    LCD_D5 = 0;
    LCD_D4 = 0;
    E_Pulse_L();
    __delay_us(200);
//******************************* FINE ************************************
//Aggiungo loop infinito per far lampeggiare il LED come "debug" per
//verificare se il codice giunge al termine.
    while (1)
    {
        delay500();
        delay500();
        LED = 1;
       
    }
}

//********************************FUNZIONI************************************
int delay500 (void){
    for (s=0; s<10; s++){
        __delay_ms(50);
        return;
    }
   }

int E_Pulse_H(void)
{
    E_PIN = 1;
    __delay_us(200);
    return;
}


int E_Pulse_L(void)
{
   __delay_us(200);
    E_PIN = 0;
    return;
}

e nella foto il risultato
Allegati
Immagine.jpg
risultato
Avatar utente
Foto UtenteCarloD
10 2
 
Messaggi: 14
Iscritto il: 5 set 2015, 14:55

0
voti

[29] Re: Interfacciamento [PIC18F2550] con LCD 16x2

Messaggioda Foto UtenteIlGuru » 19 ott 2015, 22:45

Insomma coza aveva?
\Gamma\nu\tilde{\omega}\theta\i\ \sigma\epsilon\alpha\upsilon\tau\acute{o}\nu
Avatar utente
Foto UtenteIlGuru
5.317 2 10 13
G.Master EY
G.Master EY
 
Messaggi: 1910
Iscritto il: 31 lug 2015, 23:32

0
voti

[30] Re: Interfacciamento [PIC18F2550] con LCD 16x2

Messaggioda Foto UtenteCarloD » 27 ott 2015, 19:18

Copiando pari pari gli step come descritti a pagina 42 del data sheet HITACHI HD44780U, in sostanza ho tolto l'invio dei primi tre nibble 0011 (D7 D6 D5 D4).
Avatar utente
Foto UtenteCarloD
10 2
 
Messaggi: 14
Iscritto il: 5 set 2015, 14:55

Precedente

Torna a Realizzazioni, interfacciamento e nozioni generali.

Chi c’è in linea

Visitano il forum: Nessuno e 13 ospiti