Sonsivri

Electronics => Pic Basic Languages => Topic started by: Lumos on October 24, 2010, 08:27:33 08:27



Title: Problem with Proton Basic and a 16x4 LCD
Post by: Lumos on October 24, 2010, 08:27:33 08:27
Hello,

With commands "Print at 3,1 ..." and "Print at 4,1..." the text is written from the first position 3,4 and 4,4.
Print at 1,1 and 2,1 is ok.
(I use LCD_Lines 4, LCD_Interface 4)

Who can help me?


Title: Re: Problem with Proton Basic and a 16x4 LCD
Post by: Wizpic on October 24, 2010, 09:29:26 09:29
That's not much to go on
You need to give us a bit more info, like show some sample code, your set up for the lcd then we may be able to help you

wizpic


Title: Re: Problem with Proton Basic and a 16x4 LCD
Post by: bbarney on October 24, 2010, 12:14:27 12:14
Try inserting this line near the top of your code as it seem's to cure a lot of wierd lcd problems with certain chips
Declare FLASH_CAPABLE = FALSE


Title: Re: Problem with Proton Basic and a 16x4 LCD
Post by: piappo on October 24, 2010, 12:49:37 12:49
try this:

Cls
Print At 1, 1 , ""
Print At 2, 1,  ""
Print At 3, 1 , "try"
Print At 4, 1,  "this"


Title: Re: Problem with Proton Basic and a 16x4 LCD
Post by: Lumos on October 24, 2010, 06:58:00 18:58
hello, thanks for your help.

Declare FLASH_CAPABLE = FALSE -> did not work
Print At 1, 1...4,1 -> did not work


Title: Re: Problem with Proton Basic and a 16x4 LCD
Post by: pickit2 on October 24, 2010, 08:06:08 20:06
Lumos is your code a secret? or the pic chip you used? and of couse the chipset the LCD is using.

That's not much to go on
You need to give us a bit more info, like show some sample code, your set up for the lcd then we may be able to help you
wizpic


Title: Re: Problem with Proton Basic and a 16x4 LCD
Post by: Wizpic on October 24, 2010, 08:53:52 20:53
Lumos is your code a secret? or the pic chip you used? and of couse the chipset the LCD is using.

The code is there it's hiding just above the picture  :D
It's called RHandT.txt

It must be hwo they have been uploaded

wizpic


Title: Re: Problem with Proton Basic and a 16x4 LCD
Post by: piappo on October 24, 2010, 09:05:53 21:05
change your code con this:
start:

   
   
  
   Print At 1,17,"Ta(",Dec2 Ta,") > Ti(",Dec2 Ti,")"
   Print At 2,17,"rHa(",Dec2 rHa,")< rHi(",Dec2 rHi,")"
   
Line 3 is an extension of Line 1 and Line 4 is an extension of Line 2


if the display is 20x4:

        Print At 1,21,"Ta(",Dec2 Ta,") > Ti(",Dec2 Ti,")"
   Print At 2,21,"rHa(",Dec2 rHa,")< rHi(",Dec2 rHi,")"


Title: Re: Problem with Proton Basic and a 16x4 LCD
Post by: pickit2 on October 24, 2010, 10:26:07 22:26
The problem is in your config 18Fxxx devices need Config start /and/end
and inculed the Declare Flash_Capable = FALSE  

plus there maybe another gotyou about the 16x4 line display, but I don't have my notes here at home.
look at the post above, its something about the code.
Code:
 Config_Start
   PLLDIV = 5           ' Divide by 5 (20 MHz oscillator input)
   CPUDIV = OSC1_PLL2   ' [OSC1/OSC2 Src: /1][96 MHz PLL Src: /2]
   USBDIV = 2           ' USB clock source comes from the 96 MHz PLL divided by 2
   FOSC = HS            ' Internal oscillator, HS used by USB
   FCMEN = OFF          ' Fail-Safe Clock Monitor disabled
   IESO = OFF           ' Oscillator Switchover mode disabled
   PWRT = OFF           ' PWRT disabled
   BOR = On             ' Brown-out Reset enabled in hardware only (SBOREN is disabled)
   BORV = 3             ' Minimum setting
   VREGEN = Off         ' USB voltage regulator not enabled
   WDT = OFF            ' HW Disabled - SW Controlled
   WDTPS = 128          ' 1:128
   MCLRE = OFF          ' RE3 input pin enabled; MCLR disabled
   LPT1OSC = OFF        ' Timer1 configured for higher power operation
   PBADEN = Off         ' PORTB<4:0> pins are configured as analog input channels on Reset
   CCP2MX = On          ' CCP2 input/output is multiplexed with RC1
   STVREN = On          ' Stack full/underflow will cause Reset
   LVP = OFF            ' Single-Supply ICSP disabled
   XINST = OFF          ' Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
   Debug = OFF          ' Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
Config_End

Declare Flash_Capable = FALSE


Title: Re: Problem with Proton Basic and a 16x4 LCD
Post by: bbarney on October 24, 2010, 10:30:07 22:30
you thinking
Declare LCD_Interface 8

or to slow the display down

LCD_CommandUs = 2000
LCD_DataUs = 50

Or you thinking

LCDOUT $FE,

I know the LCDOUT $FE, worked one time in proton even though it's PBasicPro , but I think it was the problem Declare Flash_Capable = FALSE  
takes care of


Title: Re: Problem with Proton Basic and a 16x4 LCD
Post by: TomJackson69 on October 24, 2010, 10:56:10 22:56
Here is some of my though.

Since your program is displayed then I would assumed your initialize OK. How about the address of the LCD defined in Proton? It could be the DELAY not long enough between display each char. Try to slow down a bit between display each char will help.

I think there is a delay problem like bbarney has said, please FOCUS on that.

However here is LCD addresses:

Some 4x20 and 4x16 LCD have line address as:

Line1 0x00
Line2 0x20
Line3 0x00
Line4 0x40

For Hitachi HD66712 controller the address:

Line1 0x00
Line2 0x20
Line3 0x40
Line4 0x80

16 chars/line display address:
Line 1 0x80
Line 2 0xC0
Line 3 0x90
Line 4 0xD0

20 chars/line display address:
Line 1 0x80
Line 2 0xC0
Line 3 0x94
Line 4 0xD4

Tom


Title: Re: Problem with Proton Basic and a 16x4 LCD
Post by: Parmin on October 24, 2010, 11:07:48 23:07
I agree with TomJackson69, check your LCD display data sheet to make sure the display address are done correctly.


Title: Re: Problem with Proton Basic and a 16x4 LCD
Post by: bbarney on October 25, 2010, 02:15:27 02:15
Lumos
try what piappo say's but just try putting 40 characters on line one and see if the other char show up on line 3
you really need to setup up the config to like pickit says as portb.3 doubles as a ccp pin if not set right and you have it as your enable pin and you should use TRISB %xxxxxxxxxx along with PORTB % xxxxxxxxx so you know every pin is set the way you hope
 It would really help if you posted a link to the displays datasheet
one question does the display have 2 chips on it so 2 enable pins ?
another thing is you have
Quote
Print Cls
start:
    Print At 3,1,"Ta(",Dec2 Ta,") > Ti(",Dec2 Ti,")"
   Print At 4,1,"rHa(",Dec2 rHa,") < rHi(",Dec2 rHi,")"

try putting the cls further down with a delay and you just need cls no need for the print

Quote
start:

Cls
DelayMS 500   
            Print At 3,1,"Ta(",Dec2 Ta,") > Ti(",Dec2 Ti,")"
   Print At 4,1,"rHa(",Dec2 rHa,") < rHi(",Dec2 rHi,")"


Title: Re: Problem with Proton Basic and a 16x4 LCD
Post by: Lumos on October 25, 2010, 08:46:07 08:46
many, many thanks, piappo, it work  ;D

Thanks also to the others for the quick help


Title: Re: Problem with Proton Basic and a 16x4 LCD
Post by: Ahmad_k on October 25, 2010, 05:39:44 17:39
Guys this is an old problem with proton using 16x4 LCD.

There was an error with "Print at 4,1" and  "at 3,1"
According to the help :
 $FE, $C0        Move cursor to beginning of second line
 $FE, $94        Move cursor to beginning of third line
 $FE, $D4        Move cursor to beginning of fourth line

there was an error. this should be :
 $FE, $C0        Move cursor to beginning of second line
 $FE, $90        Move cursor to beginning of third line
 $FE, $D0        Move cursor to beginning of fourth line

and this error is embedded in the compiler. so if you want to print at 4,1 just use the above command.

ex : Print $FE,$D0,"Test String"