Managing parallel LCD 1 line 16 characters PICAXE 28x1

huguenotte

New Member
I wanted to walk a lcd module salvaged from an old fax mode / / with the picaxe 28x1, using 4 bits for data and 2 bit signals, commands or data, I used starter pack PICAXE - 28x1 - AXE001N, here is the BASIC code
Code:
'//////////////////////////////////////////////////////////
'// Gestion d'un afficheur LCD 1 ligne 16 caractères avec un PICAXE 28X1 
'// Starter pack pour PICAXE-28X1  - AXE001N  
'// de chez [URL]http://www.gotronic.fr/catalog/micro/micro-frame.php?page_cible=picaxe.htm[/URL]
'// Ex: pour mon afficheur (WM-1601M) 1 ligne 16 caractères 
'// format HITACHI hd44780U en mode 4 bits
'// les broches connecter au picaxe sont
'// D4 a D7 sur D4 a D7 du LCD  
'// D0 -> E - D1-> R/W - D3 -> RS - D4 à D7 du LCD sur D4 à D7 du picaxe 
'// apres avoir envoyer le programme faire un reset ou enlever et remettre l'alimentation du  picaxe
 
#picaxe 28x1     ' définition du picaxe pour l'editeur
 
' // Définition des variable pour faciliter la lecture du programme. nous avons 14 variables
symbol Dat     = b1       ' Dat=variable b1
symbol Dat_Tmp = b2    ' Dat_Tmp = variable b2
symbol Dat1    = b3
symbol Chr     = b4
symbol Chr_Tmp = b5
symbol i    = b6
symbol j     = b7
symbol k     = b8
symbol L    = b9
symbol NumText = b10
symbol ligne   = b11
'// définition de Constantes
 
symbol RS    = 4         ' valeur du bit 2   
symbol RW    = 2        ' valeur du bit 1 cablé mais non utilisé ici
symbol enable  = 1     ' valeur du bit 0 
' //définition du texte a envoyer a l'afficheur LCD
             'larg 16 CARACTERES  '
 
TABLE  0, (" BONJOUR MARIE  ")  
TABLE 16, ("HELLO CHRISTOPHE")  
TABLE 32, ("CE SOIR AU DINER")  
TABLE 48, ("JE VOUS PROPOSE ")  
TABLE 64, ("UN BARBECUE AVEC") 
TABLE 80, ("DU BOULGOUR BIO ") 
TABLE 96, ("UNE SALADE MACHE") 
TABLE 112,("SUIVI DU PLATEAU") 
TABLE 128,("DE FROMAGE      ")  
TABLE 144,("AVEC UN ROSE DE ")  
TABLE 160,("PROVENCE 2008 ET") 
TABLE 176,("DE L'EAU PLATE  ")  
TABLE 192,("POUR LE DESSERT ")  
TABLE 208,("JE VOUS PROPOSE ") 
TABLE 224,("DU MELON GALIA  ")  
TABLE 240,("  BON APPETIT   ")  
 
 pause 100    ' pause pour init afficheur  
 gosub LCD_Init   ' init du lcd
 
 
'// Début du programme
main:
'//  
 for ligne = 0 to 240 step 16
     NumText=ligne
     gosub aff_line 
 next ligne
 
 goto main
 
aff_line: 
 gosub Efface_Lcd   ' efface le lcd
 gosub Affiche_Text  ' affichage des 16 caractères  
 pause 3000    ' pause de 3 secondes 
 
 
'// Routine d'éffacement de l'ecran lcd
 
Efface_Lcd:
 Dat=0x01
 gosub LCD_Commande
 return
'// routine d'affichage des 16 caractères 
 
Affiche_Text:
 J=NumText:  K=J+15:  L=J+8 ' DDRAM ADRESSE des caracteres afficheur LCD 
 for I = J to K   
 If I = L Then    ' 0  1  2  3  4  5  6  7  8  9  10 11 12 13 14 15
   let Dat = 0xc0   ' 00 01 02 02 04 05 06 07 40 41 42 43 44 45 46 47 
   gosub LCD_Commande  ' Si 8 caracteres déja envoyés pointeur mem vers 40
 end if     '
 readtable I,Chr    ' read value from table
 gosub LCD_Chr
 next I     ' next character
 
 return
 
 
'//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'// Initialisation de l'écran LCD (configuration LCD)
'//
'//  - Ici il est important de connaître les "instructions set"
'//    de votre afficheur LCD, car suivant le type d'LCD le jeu
'//    de commande diffère.
'//  - Ex: pour mon afficheur (WM-1601M) 1 ligne 16 caractères ci-dessous
'//  - En connaissant ces caractéristiques vous pourrez l'adapter
'//    à des afficheurs LCD de différents types. voir votre datasheet
'//  - initialisation du lcd format HITACHI hd44780U en 4 bits 
'//  - mode 4 bits 1 ligne de 16 caractères 5*7 
LCD_Init:
 let outpins = 0x00  ' Registre DATA =0 (D0,D1...D7) à ZERO
 pauseus 390   ' pause 39 milliseconds
 
 Dat= 0x20
 gosub pulse_e 
 
 Dat= 0x20
 gosub pulse_e
 
 Dat= 0x80
 gosub pulse_e
 
 Dat=0x28   
 gosub LCD_Commande
 Dat=0x0c   
 gosub LCD_Commande
 Dat=0x06   
 gosub LCD_Commande
 Dat=0x01
 gosub LCD_Commande
 
     return
 
'// routine validation des données Brochge E du lcd
'// Dat contiant la donnée sur 8 bits D7-D4 + RS + R/W  
pulse_e:
 
 let outpins =Dat or enable
 pauseus 4
 let outpins =Dat
 pauseus 4
 return
 
'//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'// ENVOYER UNE COMMANDE A L'ECRAN LCD
LCD_Commande:  
 'Dat=b1
 'Dat_Tmp=b2
 
     Dat_Tmp = Dat And 0xF0  ' Suppression des 4 bits poids faible
     gosub LCD_Enable    ' Valider (E)nable LCD  
     Dat_Tmp= Dat and 0x0F    ' Suppression des 4 bits poids fort
      Dat_Tmp=Dat_Tmp*16      ' Et décalage poids faible => poids fort
     gosub LCD_Enable             ' Valider (E)nable LCD
                                   ' (de 40µs à 1.64ms suivant la commande (voir vos caractéristique LCD)
 return
 
'//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'// ACTIVATION DE LA BROCHE (ENABLE) DE L'ECRAN LCD
LCD_Enable:
 
 'let outpins =0 or enable
 Dat1=Dat_Tmp
 Dat1=Dat1 or enable   ' Activer (E)nable LCD
 let outpins = Dat1             
 pauseus 4' Tempo oblig pour valid Enable
 Dat1=Dat1 xor enable ' Désactiver (E)nable LCD
 let outpins = Dat1 ' Envoyer valeur sur registre DATA
 pauseus 4  
 return 
'//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'// ENVOYER UN CARACTERE A L'ECRAN LCD
LCD_Chr:
 Chr_Tmp = Chr And 0xF0        ' Suppression des 4 bits poids faible
 Chr_Tmp = Chr_Tmp or RS  ' ajoute le bit RS 
 Dat_Tmp = Chr_Tmp
 gosub LCD_Enable   ' Valider (E)nable LCD
 Chr_Tmp = Chr and 0x0F  ' Suppression des 4 bits poids fort
 Chr_Tmp = Chr_Tmp * 16  ' Et décalage poids faible => poids fort
 Chr_Tmp =Chr_Tmp or RS  ' ajoute le bit RS
 Dat_Tmp = Chr_Tmp   
 gosub LCD_Enable   ' Valider (E)nable LCD 
 return
This is my first program picaxe, then I had wanted to send characters from the PC via cable com, so I adapt the code and create a soft VB6 to send 16 characters at the same time, if you ca interesse I give you the basic code vb​




Tony HUGUENOTTE
 

Attachments

Last edited:

saunj

Senior Member
Merci - bon code

My french is limited. I also used a 1x16 from a fax machine, but with numbers. I never could gat a field to cross the center, so had to use the two halves for different numbers.
 

westaust55

Moderator
well done with your first project.

Many do have problems with driving LCD's using parallel connections.

For those who want some further translation:
(here is some of the larger blocks of text translated to English)

'// Management of a bill-poster LCD 1 line 16 characters with a PICAXE 28X1
'// Starter pack for PICAXE-28X1 - AXE001N
'// from http://www.gotronic.fr/catalog/micro...ble=picaxe.htm
'// Ex: for my bill-poster (WM-1601M) 1 line 16 characters
'// format HITACHI hd44780U in mode 4 bits
'// the pins to connect to the picaxe are
'// D4 to D7 on PICAXE --> D4 to D7 of the LCD
'// D0 --> E, D1--> R/W, D3 --> RS,- D4 with D7 of the LCD on D4 with D7 of the PICAXE
'// after having to send the program to make a reset or to remove problems of the PICAXE


'// Initialization of l' screen LCD (configuration LCD)
'//
'// Here it is important to know the " instructions set"
'// of your bill-poster LCD, because according to the type of LCD the
'// order of comamnds differs.
'// Ex: for my bill-poster (WM-1601M) 1 line 16 characters below
'// By knowing these characteristics you will be able to adapt
'// with bill-posters LCD of various types. to see your datasheet
'// initialization of the lcd format HITACHI hd44780U in 4 bits
'// mode 4 bits 1 line of 16 characters 5*7


TABLE 0, (" HELLO MARIE ")
TABLE 16, (" HELLO CHRISTOPHE")
TABLE 32, (" THIS EVENING FOR DINER")
TABLE 48, (" I PROPOSE TO YOU")
TABLE 64, (" WITH A BARBECUE")
TABLE 80, (" BOULGOUR BIO ")
TABLE 96, (" A MACHE/FIELD SALAD")
TABLE 112, (" FOLLOW-UP WITH A PLATER")
TABLE 128, (" OF CHEESE ")
TABLE 144, (" WITH A ROSE FROM")
TABLE 160, (" PROVENCE 2008 AND")
TABLE 176, (" THE PLAIN WATER ")
TABLE 192, (" FOR THE DESSERT ")
TABLE 208, (" I PROPOSE TO YOU")
TABLE 224, (" MELON GALIA ")
TABLE 240, (" GOOD APPETITE ")
 
Last edited:
Top