Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

LCD Powertip Init?

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
autoguider

Bascom Member



Joined: 24 Sep 2007
Posts: 82
Location: Aachen

germany.gif
PostPosted: Fri Sep 03, 2021 1:33 pm    Post subject: LCD Powertip Init? Reply with quote

Dear all,
I want to run a Powertip PC1604A on a 328p.
https://www.alldatasheet.com/datasheet-pdf/pdf/78286/POWERTIP/PC1604-A.html

As I am running short on pins at the CPU I did a parallel to series conversion and send the bytes, bit by, bit to a 8bit shift register (4094N)
The display needs then the enable signal and the rs signal from the CPU. The rs signal isused by the LC module to distinguish between command and data.
So the data output is shared between the shift register and the LCD module. It is send after the 8 data bits are send to the shift register.
It does not effect the output of the shift registeras there is no clock signal activated.
See circuit diagram.

For some reason, I think it is with the initialisation, the display is illuminated for appr. 3s after activation and then it turns dark.
Please see here the code for the parallel to serial conversion:


Code:

Sub Dataout_lcd(byval A As Byte , Byval Rs As Byte)         'rs=1 means text
                                                               'rs = 0 commands
' PortC.1 Daten and RS                  'Pin  24
' PortB.5 LCD Enable                    'Pin 19
' Portc.2 ShiftRegClock                 'Pin 25







Loadadr A , X
$asm
push r16                                                    'save registers to stack
push r17
ldi r17, 8                                                  'set loop index to 8
ld r16, x                                                   'data to working register

ConversionLoop:                                             'shift MSB in Carry bit
roL r16                                                     'if Carry =0 Jump to Clearbit
brcc Clearbit
Setbit:
sbi PortC,1                                                 'if Carry =1 then set data output bit to High
jmp clockset                                                'Goto set clock for shift register to High
Clearbit:
CBi portC,1                                                 'if carry = 0 then set data output bit to Low
nop

Clockset:
sbi portC,2                                                 ' Set clock for shift register to High
nop
nop
nop
nop
nop
nop
cbi PortC,2                                                 'Set clock to Low
dec r17                                                     'decrement loop index
brne ConversionLoop                                         'if <> 0 do loop again

Loadadr Rs , X                                              ' Command or data?
ld r17, X
cpi r17,0                                                   ' If rs =0 then command
breq Set_command                                           ' command  => Bit =0

sbi portC,1
rjmp end                                                   ' Bit = 1 => Data
Set_command:
Cbi portC,1

End:
Nop
nop
sbi portB,5                                                 ' Set Enable to High
nop                                                         ' Wait
nop
nop
nop
nop
cbi portB,5                                                ' Enable set to Low , Data transfer from databus into LCD module
pop r17                                                    ' Restore registers
pop r16
$end Asm
Return
End Sub
 

I defined some constant for better reding of the code

Code:
.equ Lcdon =    &B00001100                  'LCD turn on
.equ Lcd_Off =  &B00000000
.equ Lcdclear = &B00000001                  'LCD clear, Cursor pos =1

.equ LcdSet8BitMode = &B00110000              'LCD 8Bit data bus
.equ Lcdentry =   &B00000110                  'cursor moves right, no shift

.equ LcdCursor =  &B00010100                  'Cursor beim Schreiben nach rechts geschoben
.equ Mode_2_lines = &B00111000                '8Bit,2 lines, 5x8 Dotmatrix
.equ LcdClear = &B00000001
.equ Lcd_2_Zero = &B000000010


.equ Lcdline1 = &B10000000
.equ Lcdline2 = &B11000000                                 'DDRAM für 2. Zeile H40
.equ Lcdline3 = &B10010100                                 'DDRAM für 3. Zeile
.equ Lcdline4 = &B11010100                                 'DDRAM für 4. Zeile



Const Base_line_1 = &H00
Const Base_line_2 = &H40
Const Base_line_3 = &H10                                    ' for 4x16
Const Base_line_4 = &H50
'
'Const Base_line_3 = &H14                                    ' for 4x20
'Const Base_line_4 = &H54



 


Here the code for the init procedure

Code:
Sub Init_lcd
   waitms 15
   Call Dataout_lcd(lcdSet8BitMode , 0)
   Waitms 5
   Call Dataout_lcd(lcdSet8BitMode , 0)
   Waitms 1
   Call Dataout_lcd(lcdSet8BitMode , 0)
   waitus 40
   Call Dataout_lcd(lcdSet8BitMode , 0)
   waitus 40
   Call Dataout_lcd(mode_2_lines , 0)
   waitus 40
   Call Dataout_lcd(lcdclear , 0)
   waitms 2
   Call Dataout_lcd(lcdentry , 0)
   waitus 40
   call Dataout_lcd(lcdon,0)
   wait 5

End Sub
 

I measured on the entry of the LCD module the voltages corresponding to the last data pattern sent. So the conversion seems to work.
The voltage between the 300 Ohm resistor and pin 15 of the module drops after the 3s to 0.58V.
The 300 Ohms are not too high as the module is illuminted for 3s.
So I suppose it is the init procedure.

Please let me have your advice.

kind regards
Christian

(BASCOM-AVR version : 2.0.8.4 )
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Fri Sep 03, 2021 10:40 pm    Post subject: Reply with quote

This approach looks uncomfortable.
I would look up the proper lib for this display and adapt the output routines for cmd and data to the given hardware.
It would make the serial converter transparent for the code and would also allow to use Bascom's LCD-commands.
AFAIR there's a lib for LCDs using PCFxxx, there one could look up proper ways for adaption.
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Sat Sep 04, 2021 1:22 am    Post subject: Reply with quote

Why not use the I2C library and a PFC8574 adapter
Note you can have up to 8 LCDs connected this way using 2 pins of the mcu.
There is also a library to use a 128x64 graphical display with I2C.
https://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=14773
Back to top
View user's profile
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 1161
Location: France

france.gif
PostPosted: Sat Sep 04, 2021 5:54 pm    Post subject: Reply with quote

The txt lcd are a little bit old fashion
now for less than 25$ you have tft display or HMI system look at https://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=13923&highlight=hmi+nextion
Nextion offers many new features
with only 2 wires too (serial link) they are very fast
Wink JP
I have some old 2 and 4 lines Lcd to sell Razz

and I'm ready to help you for Nextion

_________________
pleasure to learn, to teach, to create
Back to top
View user's profile Visit poster's website
SZTRAD

Bascom Member



Joined: 30 Dec 2019
Posts: 165

blank.gif
PostPosted: Sun Sep 05, 2021 8:15 am    Post subject: Reply with quote

Is the RS pin of the display really connected to the 4094 data pin?
You don't see the problem?
Use 4 bit transfer using 4094 and if you want to be sure, control the OE pin 4094.
RS
Back to top
View user's profile
i.dobson

Bascom Expert



Joined: 05 Jan 2006
Posts: 1570
Location: Basel, Switzerland

switzerland.gif
PostPosted: Sun Sep 05, 2021 8:20 am    Post subject: Reply with quote

Hi,

I've come across this https://www.makerconnect.de/index.php?threads/3-wire-lcd-mit-schieberegister.2211/

The comments are in german and the code uses a 75hc595 shift register, maybe you could adapt it for your requirements.

Regards
Ian Dobson

_________________
Walking on water and writing software to specification is easy if they're frozen.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum