good day,
I have to interface the I2C LCD (arduino like) using picbasic.
Any suggestion or code example please ?
Thanks in advance.
Ambrogio
IW2FVO
good day,
I have to interface the I2C LCD (arduino like) using picbasic.
Any suggestion or code example please ?
Thanks in advance.
Ambrogio
IW2FVO
Have a look at this :-
Forgive some of the comments.... Code did help me out :-)
http://www.picbasic.co.uk/forum/showthread.php?t=17302
Thanks Andy for the code,
I am not a good programmer and I would like to convert the PBP program that is normally used now to EASY control the I2C display.
At the moment I am using this piece of code:
INS CON 254 ' $FE: INSTRUCTION COMMAND MODE
CLR CON 1 ' CLEAR LCD , GOTO FIRST LINE, FIRST CHARACTER
DG CON 223 ' DEG SYMBOL °
LINE1 CON 128 ' $80: GOTO LINE 1
LINE2 CON 192 ' $C0: GOTO LINE 2
LINE3 CON 148 ' $94: GOTO LINE 3
LINE4 CON 212 ' $D4: GOTO LINE 4
And then I do the the following to write my own data on it:
LCDOUT INS, LINE2, " V=", DEC2 VLT/10, ".", DEC1 VLT
How could I translate the above in I2C enviroment for displaying ?
Thanks for the assistance
Regards,
Ambrogio
IW2FVO
This does not look straight forward to use. How for have you got? Have you found its address for example?
Steve Earl www.datageo.co.uk
there is a similar thread on the pbp3 forum it might be worth a look
http://support.melabs.com/threads/98...F8574-20x4-LCD
Last edited by richard; - 18th May 2014 at 07:27. Reason: linked it
this looks very interesting if you are open to alternatives.
http://www.robot-italy.com/en/lcd05-...ackground.html
I have used similar in the past and found them very easy, this one includes keypad inputs.
Steve Earl www.datageo.co.uk
Richard's link looks to be the solution you are looking for.
Last edited by EarlyBird2; - 18th May 2014 at 07:54.
Steve Earl www.datageo.co.uk
Steve,
the address is 0x20.
Thanks
Ambrogio
Thanks Steve,
I am running the PBP 2.50B version: is the Darrel include applicable to my pbp version ?
If not, what could I do ? Any possible modification to the program ?
Regards,
ambrogio
IW2FVO
Steve,
Thanks.
I have no more pins available on the pic and I have this LCD on my hands.
Anyway, what LCD ( 20x4) with serial interface could you suggest to me ? I could try to get one.
Regards,
Ambrogio
IW2FVO
Steve Earl www.datageo.co.uk
The good news is that it can be done here is some code.
from this threadCode:'ARDUINO IIC LCD GY-LCD-V1 'PIC 12F629 'PRINTS " HELLO RCG!_" Define OSC 20 DEFINE I2C_SLOW 1 CMCON = $7 OPTION_REG.7 = 0 C VAR GPIO.1 D VAR GPIO.0 ADDR VAR BYTE ADDR = $40 CMD VAR BYTE LCD_CMD VAR BYTE E VAR LCD_CMD.BIT4 RS VAR LCD_CMD.BIT6 E=0:RS=0 LCD_CMD = 0 PAUSE 1000 LCD_CMD = $2 GOSUB LCDWRITE GOSUB LCDWRITE LCD_CMD = $8 GOSUB LCDWRITE LCD_CMD = $0 GOSUB LCDWRITE LCD_CMD = $E GOSUB LCDWRITE LCD_CMD = $0 GOSUB LCDWRITE LCD_CMD = $6 GOSUB LCDWRITE RS=1 LCD_CMD = $44 GOSUB LCDWRITE LCD_CMD = $48 GOSUB LCDWRITE LCD_CMD = $44 GOSUB LCDWRITE LCD_CMD = $45 GOSUB LCDWRITE LCD_CMD = $44 GOSUB LCDWRITE LCD_CMD = $4C GOSUB LCDWRITE LCD_CMD = $44 GOSUB LCDWRITE LCD_CMD = $4C GOSUB LCDWRITE LCD_CMD = $44 GOSUB LCDWRITE LCD_CMD = $4F GOSUB LCDWRITE LCD_CMD = $42 GOSUB LCDWRITE LCD_CMD = $40 GOSUB LCDWRITE LCD_CMD = $45 GOSUB LCDWRITE LCD_CMD = $42 GOSUB LCDWRITE LCD_CMD = $44 GOSUB LCDWRITE LCD_CMD = $43 GOSUB LCDWRITE LCD_CMD = $44 GOSUB LCDWRITE LCD_CMD = $47 GOSUB LCDWRITE LCD_CMD = $42 GOSUB LCDWRITE LCD_CMD = $41 GOSUB LCDWRITE RETURN LCDWRITE: I2CWRITE D,C,ADDR,[LCD_CMD] E=1 I2CWRITE D,C,ADDR,[LCD_CMD] E=0 I2CWRITE D,C,ADDR,[LCD_CMD] RETURN END
http://www.picbasic.co.uk/forum/showthread.php?t=17302
If you need more help just ask,
Steve Earl www.datageo.co.uk
Does this code work?
If it does we can use it as a starting point and adapt it for your use.
Steve Earl www.datageo.co.uk
Thanks Steve for the kind assistance,
I can not test the code soon : the day before yesterday my display went off. I ordered another one and will be here in two weeks tiime.
Anyway : the dispaly is exactly the same of the one shown in the images attached to the link you have sent to me.
I really think that a smart code to control the i2c LCD will be appreciate by a lot of people that use PBP.
Thanks a lot for helping.
Regards,
Ambrogio
Let me know when you have a replacement. I am confident that we can get this to work between us. You do the testing and I will help with the programing.
I would do it all but I do not have the hardware anymore as I went over to touch screen PLCs. I am more interested in touch screen GLCD solutions based on a PIC (Amicus18 for example) which I need the hardware for.
Steve Earl www.datageo.co.uk
Thanks Steve,
I do appreciate your help. I will tell you as soon as I have the new dispaly in my hands.
Ambrogio
Hi Steve,
I received the new display just now.
It is equipped with the PCF 8574T.
It is connected to the QC2004A display in the following way:
pin_4 p0 > RS
pin_5 p1 > RW
pin_6 p2 > enable
pin_7 p3 > Backlight
pin_9 p4> data4
pin_10 p5 > data5
pin_11 p6 > data6
pin_12 p7 > data7
It is different wrt the one I had before: it has a different connections between the PCF and the LCD.
I will be ready for testing tomorrow or monday: please suggest me what trials to do just to start.
Thanks for all
Ambrogio
We start with Darrel's routine for PBP3 and make changes for your LCD pin setup and PBP2.x
http://support.melabs.com/threads/98...F8574-20x4-LCD
Steve Earl www.datageo.co.uk
Steve,
the point is that I do not have PBP_3.
My pbp is 2.50 B.
No arraywrite or read, no usercommand ... are available to me .
Thanks
Ambrogio
Yes the arraywrite command has to be handled differently in pbp2.5.
Arraywrite loads the LCD_Buff you need to replace Arraywrite with a routine that loads what you want displayed on the LCD into LCD_Buff.
For example
LCD_BuffLen = 4
LCD_Buff.0 = "T"
LCD_Buff.1 = "e"
LCD_Buff.2 = "s"
LCD_Buff.3 = "t"
LCD_WriteBuff
Just to give you an idea as I think this is how it works but obviously I have not tested it as only you have the hardware.
Also johncouture's LCD has the same pins as your's (check it) so his modified programs are the ones you need to use.
This is the first step more issues could be thrown up. I am expecting to enjoy the ride (voyage of discovery) and hopefully get it working.
Steve Earl www.datageo.co.uk
Steve,
sorry for not having reply soon because of " family duty ".
I wrote this small program and I am able to control Backlight :
DEFINE OSC 40 ' 10 MHz XTAL AND X 4 INTERNAL PLL
DEFINE I2C_SLOW 1
C VAR portd.3 ' S_CLOCK
D VAR portd.2 ' S_DATA
ADDR VAR BYTE
ADDR = %01001110 ' dec 78 , hex 4E
CMD VAR BYTE
LCD_CMD VAR BYTE
E VAR LCD_CMD.BIT2
RS VAR LCD_CMD.BIT0
E=0:RS=0
LCD_CMD = 0
PAUSE 1000
MAIN:
I2CWRITE D, C, ADDR, [%00000000] ' bck_lt= off
PAUSE 200
I2CWRITE D, C, ADDR, [%00001000] ' bck_lt=on
PAUSE 200
GOTO MAIN
The I2C address is new.
Now, my LCD has 20 chrs X 4 lines.
The PCF controls the LCD using the upper four bits of its output port.
I have to initialize the LCD in four bit mode , four lines at the required PCF port pins.
How could I do that ?
Thanks
Ambrogio
Initialise is at the end of the second code which you need to include using this code
Code:INCLUDE "LCD_PCF8574A.pbp" ; Init LCD using I2C and PCF8574The files you need are hereCode:; File Name : LCD_PCF8574A.pbp ; Author : Darrel Taylor ; Created : Mon Feb 24 2014 ; Sun Mar 03 2014 ; Updated bit shift. Data is on Lower side, Cmd lines on Upper ; Compiler : PicBasic Pro 3.0.6.x or higher ; Description : Uses PCF8574 Port expander to interface with HD44780 LCD ; ;------------------------------------------------------------------------------- LCD_BuffSize CON 30 LCD_Buff VAR BYTE[LCD_BuffSize] LCD_BuffAddr CON EXT : @LCD_BuffAddr = _LCD_Buff LCD_BuffLen VAR WORD ; Length of data in buffer LCD_Data VAR BYTE ; Data to Send to LCD LCD_Byte VAR BYTE ; Nibbles to Send LCD_RS VAR LCD_Byte.0 ; Register Select bit LCD_RW VAR LCD_Byte.1 ; Read/Write bit LCD_E VAR LCD_Byte.2 ; Enable bit LCD_BackLight VAR LCD_Byte.3 ; Backlight 0=ON LCD_WriteMode VAR BYTE ; 1=LowNibble, 2=HighNibble, 3=Both LCD_CommandMode VAR BIT ; Indicates next byte is a command LCD_Byte2 VAR BYTE ; Same nibble without E bit LCD_Idx VAR BYTE testmode var byte GOTO Over_LCDPCF8574 ;----[Write 1-byte to LCD]--(Input is LCD_Data)--------------------------------- USERCOMMAND "LCD_WRITE" LCD_WRITE_: LCD_E = 1 IF LCD_WriteMode.1 = 1 THEN ; Write High Nibble LCD_Byte = (LCD_Byte & $0F) | (LCD_Data & $F0) LCD_Byte2 = LCD_Byte & $FB I2CWRITE SDA,SCL, LCD_Addr,[LCD_Byte, LCD_Byte2] ENDIF IF LCD_WriteMode.0 = 1 THEN ; Write Low Nibble LCD_Byte = (LCD_Byte & $0F) | ((LCD_Data << 4 )& $F0) LCD_Byte2 = LCD_Byte & $FB I2CWRITE SDA,SCL, LCD_Addr,[LCD_Byte, LCD_Byte2] ENDIF return ASM LCD_WRITE? macro L?CALL _LCD_WRITE_ endm ENDASM ;----[Write contents of buffer to LCD]------------------------------------------ USERCOMMAND "LCD_WRITEBUFF" LCD_WRITEBUFF_: ' The purpose of this routine is to increment through LCD_Buff and ' pass each character to LCD_Data so that it can be written. ' This will loop for LCD_BuffLen which is calculated by ' subtracting the starting address of the buffer from the ' ending address of the buffer. LCD_BuffLen = R5 - LCD_BuffAddr -1 LCD_WriteMode = 3 ; Both Nibbles LCD_CommandMode = 0 FOR LCD_Idx = 0 TO LCD_BuffLen IF LCD_Buff(LCD_Idx) = $FE THEN LCD_CommandMode = 1 : GOTO LCD_ByteDone IF LCD_CommandMode THEN LCD_RS = 0 ' this is a command LCD_CommandMode = 0 ' false, next byte will be data ELSE LCD_RS = 1 ' this is data ENDIF LCD_Data = LCD_Buff(LCD_Idx) LCD_Write IF LCD_CommandMode THEN PAUSE 2 ELSE PAUSEUS 50 ENDIF LCD_ByteDone: NEXT LCD_Idx LCD_CommandMode = 0 RETURN ASM LCD_WRITEBUFF? macro L?CALL _LCD_WRITEBUFF_ endm ENDASM USERCOMMAND "LED_WRITE" LED_Write_: ; Write to the LEDs (this is a test routine) LCD_E = 1 IF LCD_WriteMode.0 = 1 THEN ; Write Low Nibble LCD_Byte = (LCD_Byte & $0F) | (LCD_Data & $F0) LCD_Byte2 = LCD_Byte & $FB i2cwrite SDA,SCL, LCD_Addr2,[LCD_Byte] pause 500 i2cwrite SDA,SCL, LCD_Addr2,[LCD_Byte2] pause 500 endif IF LCD_WriteMode.0 = 1 THEN ; Write Low Nibble LCD_Byte = (LCD_Byte & $0F) | ((LCD_Data << 4 )& $F0) LCD_Byte2 = LCD_Byte & $FB i2cwrite SDA,SCL, LCD_Addr2,[LCD_Byte] pause 500 i2cwrite SDA,SCL, LCD_Addr2,[LCD_Byte2] pause 500 endif RETURN ASM LED_WRITE? macro L?CALL _LED_WRITE_ endm ENDASM Over_LCDPCF8574: ;----[Initialize the LCD]------------------------------------------------------- PAUSE 250 ; LCD Power-on delay LCD_Backlight = 1 ; Backlight OFF LCD_RW = 0 ; Write to LCD LCD_RS = 0 ; Command Register LCD_WriteMode = 1 ;-- Low Nibbles only LCD_Data = 3 ; Reset 3 times gosub LCD_Write_ PAUSEUS 6000 gosub LCD_Write_ PAUSEUS 1000 gosub LCD_Write_ PAUSEUS 1000 LCD_Data = 2 ; Start 4-bit mode gosub LCD_Write_ PAUSEUS 1000 LCD_WriteMode = 3 ;-- Both Nibbles LCD_Data = $28 gosub LCD_Write_ ; Function Set, 4-bit, 2-line, 5x7 LCD_Data = $0C gosub LCD_Write_ ; Display ON LCD_Data = $01 gosub LCD_Write_ ; Clear Screen PAUSE 2 LCD_Data = $06 gosub LCD_Write_ ; Entry Mode PAUSE 2 ; Let command finish
http://support.melabs.com/threads/98...F8574-20x4-LCD
Steve Earl www.datageo.co.uk
Ambrogio are you making any progress?
Steve Earl www.datageo.co.uk
Steve,
I am not able to go on. I am not a software guy...
I do need something very simple just to start from the beginning...
It is hard to me .
I understand that I will never have the I2C lcd as simple as the LCDOUT that I usually use.
Thanks to be patient !
Ambrogio
I will work on something very simple like print "Test" on the LCD as a start.
Unfortunately my problem is everything looks easy to me and I assume everyone sees what I see and understands what I understand and obviously they do not. I can take the lead if you want me to. I just assumed you wanted the fun of solving the problem. Give me a bit of time to write a test program.
Steve Earl www.datageo.co.uk
Thanks Steve.
your assistance is great.
Ambrogio
This is the code to initialise the LCD and send Test. It does not use the LCD_Buff features. Obviously you need to check the OSC and DEFINEs as usual. I do expect this not to work first time!
Code:DEFINE OSC 40 ' 10 MHz XTAL AND X 4 INTERNAL PLL DEFINE I2C_SLOW 1 SDA VAR PORTD.2 ; I2C Data pin SCL VAR PORTD.3 ; I2C Clock Pin LCD_Addr CON 78 'LCD_BuffSize CON 30 'LCD_Buff VAR BYTE[LCD_BuffSize] 'LCD_BuffAddr CON EXT : @LCD_BuffAddr = _LCD_Buff 'LCD_BuffLen VAR WORD ; Length of data in buffer LCD_Data VAR BYTE ; Data to Send to LCD LCD_Byte VAR BYTE ; Nibbles to Send LCD_RS VAR LCD_Byte.0 ; Register Select bit LCD_RW VAR LCD_Byte.1 ; Read/Write bit LCD_E VAR LCD_Byte.2 ; Enable bit LCD_BackLight VAR LCD_Byte.3 ; Backlight 0=ON LCD_WriteMode VAR BYTE ; 1=LowNibble, 2=HighNibble, 3=Both LCD_CommandMode VAR BIT ; Indicates next byte is a command LCD_Byte2 VAR BYTE ; Same nibble without E bit LCD_Idx VAR BYTE testmode var byte ;----[Initialize the LCD]------------------------------------------------------- PAUSE 250 ; LCD Power-on delay LCD_Backlight = 1 ; Backlight OFF LCD_RW = 0 ; Write to LCD LCD_RS = 0 ; Command Register LCD_WriteMode = 1 ;-- Low Nibbles only LCD_Data = 3 ; Reset 3 times gosub LCD_Write_ PAUSEUS 6000 gosub LCD_Write_ PAUSEUS 1000 gosub LCD_Write_ PAUSEUS 1000 LCD_Data = 2 ; Start 4-bit mode gosub LCD_Write_ PAUSEUS 1000 LCD_WriteMode = 3 ;-- Both Nibbles LCD_Data = $28 gosub LCD_Write_ ; Function Set, 4-bit, 2-line, 5x7 LCD_Data = $0C gosub LCD_Write_ ; Display ON LCD_Data = $01 gosub LCD_Write_ ; Clear Screen PAUSE 2 LCD_Data = $06 gosub LCD_Write_ ; Entry Mode PAUSE 2 ; Let command finish goto main LCD_WRITE_: LCD_E = 1 IF LCD_WriteMode.1 = 1 THEN ; Write High Nibble LCD_Byte = (LCD_Byte & $0F) | (LCD_Data & $F0) LCD_Byte2 = LCD_Byte & $FB I2CWRITE SDA,SCL, LCD_Addr,[LCD_Byte, LCD_Byte2] ENDIF IF LCD_WriteMode.0 = 1 THEN ; Write Low Nibble LCD_Byte = (LCD_Byte & $0F) | ((LCD_Data << 4 )& $F0) LCD_Byte2 = LCD_Byte & $FB I2CWRITE SDA,SCL, LCD_Addr,[LCD_Byte, LCD_Byte2] ENDIF return Main: LCD_Data = "T" gosub LCD_Write_ LCD_Data = "e" gosub LCD_Write_ LCD_Data = "s" gosub LCD_Write_ LCD_Data = "t" gosub LCD_Write_ goto main
Steve Earl www.datageo.co.uk
Steve,
Thanks a lot for the intersest.
It does not work. I added the bck_lt flashing in the main loop just to see if the communication is good > the bck_lt comes ond goes correctly.
I am attaching the whole program
Ambrogio
'************************************************* ***************
'* Name : RKPK40 board pic18F452 40 MHz *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 23/06/2014 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
';Program Configuration Register 1H
@ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HSPLL_OSC_1H
';Program Configuration Register 2L
@ __CONFIG _CONFIG2L, _BOR_OFF_2L & _BORV_20_2L & _PWRT_ON_2L
';Program Configuration Register 2H
@ __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
';Program Configuration Register 3H
@ __CONFIG _CONFIG3H, _CCP2MX_OFF_3H
';Program Configuration Register 4L
@ __CONFIG _CONFIG4L, _STVR_OFF_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
';Program Configuration Register 5L
@ __CONFIG _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L & _CP2_OFF_5L & _CP3_OFF_5L
';Program Configuration Register 5H
@ __CONFIG _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H
';Program Configuration Register 6L
@ __CONFIG _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L
';Program Configuration Register 6H
@ __CONFIG _CONFIG6H, _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H
';Program Configuration Register 7L
@ __CONFIG _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L & _EBTR3_OFF_7L
';Program Configuration Register 7H
@ __CONFIG _CONFIG7H, _EBTRB_OFF_7H
DEFINE OSC 40 ' 10 MHz XTAL AND X 4 INTERNAL PLL
DEFINE I2C_SLOW 1
SDA VAR PORTD.2 ; I2C Data pin
SCL VAR PORTD.3 ; I2C Clock Pin
LCD_Addr CON 78
'LCD_BuffSize CON 30
'LCD_Buff VAR BYTE[LCD_BuffSize]
'LCD_BuffAddr CON EXT : @LCD_BuffAddr = _LCD_Buff
'LCD_BuffLen VAR WORD ; Length of data in buffer
LCD_Data VAR BYTE ; Data to Send to LCD
LCD_Byte VAR BYTE ; Nibbles to Send
LCD_RS VAR LCD_Byte.0 ; Register Select bit
LCD_RW VAR LCD_Byte.1 ; Read/Write bit
LCD_E VAR LCD_Byte.2 ; Enable bit
LCD_BackLight VAR LCD_Byte.3 ; Backlight 0=ON
LCD_WriteMode VAR BYTE ; 1=LowNibble, 2=HighNibble, 3=Both
LCD_CommandMode VAR BIT ; Indicates next byte is a command
LCD_Byte2 VAR BYTE ; Same nibble without E bit
LCD_Idx VAR BYTE
testmode var byte
;----[Initialize the LCD]-------------------------------------------------------
PAUSE 250 ; LCD Power-on delay
LCD_Backlight = 1 ; Backlight OFF
LCD_RW = 0 ; Write to LCD
LCD_RS = 0 ; Command Register
LCD_WriteMode = 1 ;-- Low Nibbles only
LCD_Data = 3 ; Reset 3 times
gosub LCD_Write_
PAUSEUS 6000
gosub LCD_Write_
PAUSEUS 1000
gosub LCD_Write_
PAUSEUS 1000
LCD_Data = 2 ; Start 4-bit mode
gosub LCD_Write_
PAUSEUS 1000
LCD_WriteMode = 3 ;-- Both Nibbles
LCD_Data = $28
gosub LCD_Write_ ; Function Set, 4-bit, 2-line, 5x7
LCD_Data = $0C
gosub LCD_Write_ ; Display ON
LCD_Data = $01
gosub LCD_Write_ ; Clear Screen
PAUSE 2
LCD_Data = $06
gosub LCD_Write_ ; Entry Mode
PAUSE 2 ; Let command finish
goto main
LCD_WRITE_:
LCD_E = 1
IF LCD_WriteMode.1 = 1 THEN ; Write High Nibble
LCD_Byte = (LCD_Byte & $0F) | (LCD_Data & $F0)
LCD_Byte2 = LCD_Byte & $FB
I2CWRITE SDA,SCL, LCD_Addr,[LCD_Byte, LCD_Byte2]
ENDIF
IF LCD_WriteMode.0 = 1 THEN ; Write Low Nibble
LCD_Byte = (LCD_Byte & $0F) | ((LCD_Data << 4 )& $F0)
LCD_Byte2 = LCD_Byte & $FB
I2CWRITE SDA,SCL, LCD_Addr,[LCD_Byte, LCD_Byte2]
ENDIF
return
Main:
LCD_Data = "T"
gosub LCD_Write_
LCD_Data = "e"
gosub LCD_Write_
LCD_Data = "s"
gosub LCD_Write_
LCD_Data = "t"
gosub LCD_Write_
pause 5000
i2cwrite sda, scl, LCD_addr, [0] ' back_lt blinking
pause 1000
i2cwrite sda, scl, LCD_Addr,[%00010000]
pause 1000
goto main
Steve,
I have checked the PCF to LCD connection :
bit0 = RS
bit1 =RW
bit2 =EN
bit3 =bck_lt
bit4 =D4
bit5 =D5
bit6 =D6
bit7 =D7
D0 to D3 of the LCD : there is no connection at all.
Regards,
Ambrogio
Steve,
the display has 20 chrs X 4 lines.
Thanks,
Ambrogio
I over simplified the program!
need to add this line
LCD_RS = 1 ' this is data highlighted in red above. This switches from command mode to data. It was in command mode that is why your back_lt instructions worked. An excellent clue for me.
I am not sure about these lines
LCD_Data = $28
gosub LCD_Write_ ; Function Set, 4-bit, 2-line, 5x7
and what the location addresses are to position the cursor at the beginning of each line.
Have you a datasheet for this LCD?
When this simple example is working we can add Command/Data switching which we will obviously need to have. I will follow Darrel's method as close as possible, he uses $FE to indicate the next byte is a command and switches to command mode for one byte then back to data.
Plenty for me to think about.
Steve Earl www.datageo.co.uk
Assuming $80 is line 1/0 then we can add
PAUSE 2 ; Let command finish
LCD_Data = $80
gosub LCD_Write_
to position the cursor. As this is a command it goes before we switch to data mode like this
PAUSE 2 ; Let command finish
LCD_Data = $80
gosub LCD_Write_
PAUSE 2 ; Let command finish
LCD_RS = 1 ' this is data
goto main
Steve Earl www.datageo.co.uk
Dear Steve,
I am not able to findout the detailed spec for the QC2004A display. I can tell it is working well using the standard PBP connection diagram.
I am posting a general spec for LCD addressing ( attached ).
I did a very bad experience with the PCF expander board that was attached to the LCD: the trim pot that should adjust the contrast of the display has the cursor connected to ground and one side connected to 5VDC. I did turn it just to be sure of the contrast setting and I got a short circuit of the 5Vdc to ground when turned fully clockwise. The result is that my ICD2 programmer smoked and it is no longer working. I have attached the photo of the PCF expander to warn about this item: there is a very very gross design error on it.
I am looking to find a new pic programmer to buy: what do you recommand to me ? Is the pickit3 really good ?
I have a pic16f877 to replace on the ICD2 programmer but I do not have any possibiliity to program it with the required bootloader... I will ask someone tomorrow !
I really hope to test your programs soon. I will let you know.
I want to thank you once again for the help you are giving to me .
Regards,
Ambrogio
Ambrogio
I have no experience of programmers as I inherited all of my hardware from my son, he took an electronics course before going to university. I have a Picstart Plus that I have never used.I am looking to find a new pic programmer to buy: what do you recommend to me ? Is the pickit3 really good ?
Please do as you have sparked my interest now and all sorts of bright ideas are formulating in my mind to the point that I am loosing sleep.I really hope to test your programs soon. I will let you know.
Steve Earl www.datageo.co.uk
I have a pickit3 and a pickit2 programmer the pk3 only ever gets used if its the only choice (and it very seldom is) . the gui for the pk2 is just so much better to use . serial debugging is just so easy with the pk2 and its built in comms package . by far the pk2 is my tool of choice for icsp.
I have never bothered to use either of them in command line mode for programming directly from micro code studio although it is fairly easy to do .
I must admit that I have not looked to see if microchip have made a better/upgraded gui for the pk3 for at least a year now , my info may be out of date .
I also wonder if any body has tried the cheap pk2 clones that are on ebay , are they compatible with the microchip pk2 gui ? are they any good?
Last edited by richard; - 30th June 2014 at 08:45. Reason: can't tpye ca'nt spell
Is there a lista of PICs programmable by PICKIT2 ?
Thanks
Ambrogio
not that I can find ,but there is not many that aren't on the supported device list.
you can download the pickit2 program(its free) from microchip site and check out the supported device list if you have specific devices to check
http://www.microchip.com/Development...tDocumentation
Bookmarks