News:

Let's find out together what makes a PIC Tick!

Main Menu

PIC 16F917 driving Lumex S401M16KR

Started by broderic, Jul 30, 2022, 09:27 AM

Previous topic - Next topic

broderic

Hello.
With the following simple code I would like to test the LCD as per subject.
The issue is that instead of having only one segment turned on, the one related to ":", I have all segment related to LCD pin 12 turned on, as multiplexing wouldn't work well.
So I'm in doubt if it is a matter of my wrong PIC setting or LCD setting.
I kindly ask if anyone has some knowledge/suggestion to understand this unproper working of my code.
Thanks a lot for your attention.

'PIC16F917 connected to Lumex LCD S401M16KR.
'pin1(COM0) to RB4
'pin2(COM1) to RB5
'pin3(COM2) to RA2
'pin4(COM3) to RD0
'pin12 (COL,4C,4B,4A) to RB2 (SEG2)       only one connection for initial testing
Device 16F917
Xtal = 8          '8MHz crystal

Declare Create_Coff = On
TRISC=0
TRISA=0
TRISD=0
TRISB=0
TRISE=0 
DelayMS 1000      'wait for LCD start up

LCDSE0=0xFF
LCDSE1=0xFF
LCDSE2=0xFF

LCDPS = %10000111   'Selecting the frame prescale             
LCDCON = %11110011 'enabling the LCD module
PIR2.4 = 0          'clearing LCD interrupt flag
LCDDATA0=0
Do

 Set LCDDATA0.2  ' should expect only ":" to be turned on  (COL), instead
                 ' all segment related to pin 12 are turned on (COL,4C,4B,4A)
                 ' so as LCDDATA3.2, LCDDATA6.2, LCDDATA9.2 would be set by code
                 ' but they're not.

Loop               


broderic

It seems it was only a matter of control voltage to be applied at RC0,RC1,RC2 with a voltage divider.
The enclosed schematic is only representative since Proteus does not simulate that display.
With following code seems to work properly.
'Program LCD2.C page 153 "Programming 8-bit microcontroller in C" M.P.Bates,
'using LCD Lumex S401M16KR
'LCD program to count up from 0 to 9999 using BCD digits

Device 16F917
Xtal = 8          '8MHz crystal
Dim DigMap[11] As Byte = 0xFD,0x60, 0xDB, 0xF3, 0x66, 0xB7, 0xBF,0xE0, 0xFF, 0xE7, 0x00
Dim Dig1 As Byte
Dim Dig2 As Byte
Dim Dig3 As Byte
Dim Dig4 As Byte
Dim BCD1 As Byte =0
Dim BCD2 As Byte =0
Dim BCD3 As Byte =0
Dim BCD4 As Byte =0
Declare Create_Coff = On
LCDCONbits_LCDEN=0
LCDPS = 0x00  'it works better  with improved contrast stability
   
LCDSE0.1 = 1  'Segment pins : 1 means that that pin is dedicated to LCD
LCDSE0.2 = 1
LCDSE0.3 = 1
LCDSE0.6 = 1
LCDSE1.3 = 1
LCDSE2.5 = 1
LCDSE2.6 = 1
LCDSE2.7 = 1

LCDDATA0=0     'Switch off all segments
LCDDATA1=0
LCDDATA2=0
LCDDATA3=0
LCDDATA4=0
LCDDATA5=0
LCDDATA6=0
LCDDATA7=0
LCDDATA8=0
LCDDATA9=0
LCDDATA10=0
LCDDATA11=0
PIR2.4 = 0          'clearing LCD interrupt flag
LCDCON = %10011111  'it works
DelayMS 1000        'wait for LCD start up

Do
    Inc BCD4
    If BCD4=10 Then
       BCD4=0
       Inc BCD3
       If BCD3=10 Then
          BCD3=0
          Inc BCD2
          If BCD2=10 Then
             BCD2=0
             Inc BCD1
             If BCD1=10 Then
             BCD1=0
             EndIf 
          EndIf
       EndIf
    EndIf                   
           
    Dig4= DigMap[BCD4]                  'digit 4
    LCDDATA9.2=GetBit Dig4,7             
    LCDDATA6.2=GetBit Dig4,6               
    LCDDATA3.2=GetBit Dig4,5               
    LCDDATA0.1=GetBit Dig4,4               
    LCDDATA3.1=GetBit Dig4,3               
    LCDDATA9.1=GetBit Dig4,2             
    LCDDATA6.1=GetBit Dig4,1
    DelayMS 300
                         
    Dig3= DigMap[BCD3]                  'digit 3
    LCDDATA9.3=GetBit Dig3,7             
    LCDDATA6.3=GetBit Dig3,6               
    LCDDATA3.3=GetBit Dig3,5               
    LCDDATA1.3=GetBit Dig3,4               
    LCDDATA4.3=GetBit Dig3,3               
    LCDDATA10.3=GetBit Dig3,2             
    LCDDATA7.3=GetBit Dig3,1       
    DelayMS 300
                         
    Dig2= DigMap[BCD2]                  'digit 2
    LCDDATA9.6=GetBit Dig2,7   
    LCDDATA6.6=GetBit Dig2,6               
    LCDDATA3.6=GetBit Dig2,5             
    LCDDATA2.5=GetBit Dig2,4               
    LCDDATA5.5=GetBit Dig2,3             
    LCDDATA11.5=GetBit Dig2,2               
    LCDDATA8.5=GetBit Dig2,1         
    DelayMS 300
                 
    Dig1= DigMap[BCD1]                  'digit 1
    LCDDATA11.6=GetBit Dig1,7     
    LCDDATA8.6=GetBit Dig1,6   
    LCDDATA5.6=GetBit Dig1,5   
    LCDDATA2.7=GetBit Dig1,4   
    LCDDATA5.7=GetBit Dig1,3   
    LCDDATA11.7=GetBit Dig1,2     
    LCDDATA8.7=GetBit Dig1,1         
    DelayMS 300
 
Loop
End


Thanks

broderic

Hello.
Does anyone know where I can buy a 1/2 duty (2 common) 1/2 bias segmented LCD?
It doesn't matter the number of digits (2 or 3 or 4,...).
I would like to make an application test with this kind of driving method.
I'm bothering 'cause I find no one on the web!

Thanks

Regards