View previous topic :: View next topic |
Author |
Message |
autoguider
Joined: 24 Sep 2007 Posts: 82 Location: Aachen
|
Posted: Fri Sep 03, 2021 1:33 pm Post subject: LCD Powertip Init? |
|
|
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 |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Fri Sep 03, 2021 10:40 pm Post subject: |
|
|
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 |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
|
Back to top |
|
|
SZTRAD
Joined: 30 Dec 2019 Posts: 165
|
Posted: Sun Sep 05, 2021 8:15 am Post subject: |
|
|
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 |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
|
Back to top |
|
|
|
|
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
|
|