![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #1 |
|
Hi every one! this is my first post here.. Im trying to send from the pic a line text " hello" to the LCD. My first try was successfull with PIC SIMULATOR IDE. I programmed the code and used the LCD simulator..and it showed: "Hello". Today I programmed the code using Micro code studio plus and Pic basic pro. This is an extract from Micro code studio Help about LCDOUT PICBasic asumes the LCD is connected to specific pins unless told otherwise. It assumes the LCD will be used with a 4-bit bus with data lines DB4 - DB7 connected to PICmicro PORTA.0 - PORTA.3, Register Select to PORTA.4 and Enable to PORTB.3. It is also preset to initialize the LCD to a 2 line display. so iīve used this diagram with the exeption that i connected ra4 directly to RS pin in LCD, and iīve connected to MCLR with Vdd with a 10k resistor, the capacitor for contrast in the LCD is a 10k one, the vss pin in the micro is connected directly to ground and vdd pin directly to +5v: ![]() this is my code: pause 1000 loop: High PORTB.2 ' turn on a Led pause 500 LCDOUT $FE, 1, "Hello" low PORTB.2 ' turn off the led pause 500 goto loop end i didnīt use DEFINE coz according to the LCDOUT statement iīve showed to you, from Microcode studio help. The diagram and the code are just what i need. Just for the record: iīve read all the info in the internet about interfacing pics and LCD The LCD isnīt showing anything. But the led is actually working. Can anybody help me??? Last edited by evilsent; 11th October 2006 at 04:50 AM. | |
| |
| | #2 | |
| Quote:
Mike. | ||
| |
| | #3 |
|
No i havenīt included the resistor, is it mandatory in order to make things right??? and if itīs so..itīs a 4700 = 4.7k resistor??. Iīm gonna try with this resistor. Thanks 4 the advice. Is anything else wrong with my project??? Thanks 4 the help Mike. | |
| |
| | #4 |
|
Yes, you need the resistor. 4700Ω =4.7kΩ but anything around that value will work (2k to 20k). Mike. | |
| |
| | #5 |
|
Hi, please try this: ' Set LCD Data port DEFINE LCD_DREG PORTB ' Set starting Data bit (0 or 4) if 4-bit bus DEFINE LCD_DBIT 4 ' Set LCD Register Select port DEFINE LCD_RSREG PORTB ' Set LCD Register Select bit DEFINE LCD_RSBIT 1 ' Set LCD Enable port DEFINE LCD_EREG PORTB ' Set LCD Enable bit DEFINE LCD_EBIT 0 ' Set LCD bus size (4 or 8 bits) DEFINE LCD_BITS 4 ' Set number of lines on LCD DEFINE LCD_LINES 2 pause 100 lcdout $fe,1,"Hello" end LCD Connection Pin1=Vss: connect to ground Pin2=Vdd: connect to Vcc=5V Pin3=Vo: connect to middle pin of the POT(20K) to control brightness Pin4=RS(register select): connect to micro pins that specify in the software(RB1) Pin5=RW(Read/Write): connect to ground because we want to only write Pin6=E(Enable): connect to micro pin that specify in the software(RB0) Pin7 to 10: No connection Pin 11 to 14: connect to RB4 to RB7 Pin15: connect to Vcc with a resistor(100 or 200 ohm resistor is good) Pin16: connect to ground. pin 16 and pin 16 are for backlights the other two pins of pot should connect to VCC and ground and you should connect the MCLR with a 4.7K or 10K resistor to the VCC. Last edited by amindzo; 11th October 2006 at 08:11 AM. | |
| |
| | #6 |
|
Hi, Please try this, Answer the question that was asked. Mike. | |
| |
| | #7 |
|
Thank you guys for helping me...iīll try your suggestions when i get home...and iīll let you know what happened. greetings | |
| |
| | #8 |
| Code: ' Set LCD Data port DEFINE LCD_DREG PORTA ' Set starting Data bit (0 or 4) if 4-bit bus DEFINE LCD_DBIT 0
__________________ Bill Home of the Firefly PIC Tutor Inchworm ICD2 http://www.blueroomelectronics.com | |
| |
| | #9 |
|
william, you said that the schematic that i used, uses the lower 4 bits of porta. What does it mean?? i Thought that when you set: ' Set starting Data bit (0 or 4) if 4-bit bus DEFINE LCD_DBIT 0 it means that you wanna use DB0-DB3 as data bus. Or it really means the pins at the port specified. PORTA.0, PORTA.1.......,PORTA.3 in the PIC????? Because now i followed the schematic im my breadboard and nothing happened..well the led works fine....and the LCD at least turns on all lines showing almost transparents squares. Is because of the code???? And if its my code..can anyone show me a code for this schematic that actually works? Thank you all! Last edited by evilsent; 12th October 2006 at 01:09 AM. | |
| |
| | #10 |
|
It should work as it is. Here is the example code from http://www.melabs.com/resources/samples/pbp/lcd.bas Code: ' PicBasic program to demonstrate operation of an LCD in 4-bit mode
'
' LCD should be connected as follows:
' LCD PIC
' DB4 PortA.0
' DB5 PortA.1
' DB6 PortA.2
' DB7 PortA.3
' RS PortA.4 (add 4.7K pullup resistor to 5 volts)
' E PortB.3
' RW Ground
' Vdd 5 volts
' Vss Ground
' Vo 20K potentiometer (or ground)
' DB0-3 No connect
Pause 500 ' Wait for LCD to startup
loop: Lcdout $fe, 1 ' Clear LCD screen
Lcdout "Hello" ' Display Hello
Pause 500 ' Wait .5 second
Lcdout $fe, 1 ' Clear LCD screen
Lcdout "World"
Pause 500 ' Wait .5 second
Goto loop ' Do it forever
Mike. | |
| |
| | #11 |
|
im sure that the wiring between lcd and the pic is correct, im sure my code is correct as the one mike posted. The thing is that when the pic start to work..the lcd show me the 2 lines with all the pixels "on" in all of the 16 positions. What i did next was to disconect the wires from LCD...except the ground, +5v, and contrast. And the LCd just show one line with all the pixel "on" . IS it normal??? or my LCD is damaged?? I dont know what else to try.... ![]() edit: i tried the code above and nothing the same thing happened :'( Last edited by evilsent; 12th October 2006 at 03:57 AM. | |
| |
| | #12 |
|
It looks like your LCD is OK. The reason you only see 1 line with only power connected and 2 lines with the pic connected is that the pic is initializing the LCD to be a 2 line unit. Can you adjust the contrast from all black through to all light? Mike. | |
| |
| | #13 |
|
IT WORKS!!!!!!!! the reason that it wasn working was coz the 10k POT was defective..i tried to adjust the contrast and nothing happened...i change te pot and everything goes fine!!!!!!!!! Thank you people for all the help u gave me!!! Thanks mike! thanks william at the blue room and to amindzo | |
| |
| | #14 |
|
Hi every body, the lcd connection that pommie siad is a default one(that don't need any define in software) and if you want to connect lcd to PORTB or PORC and so, on you should define the lcd parameters as i said befor. it is better to make a 100 or 150 ms delay to make the lcd ready befor you want to write on lcd. Last edited by amindzo; 12th October 2006 at 06:00 AM. | |
| |
| | #15 |
|
can i groung the vss pin3 ,then what will be the result of lcd brightness?
| |
| |
|
| Tags |
| 16f84a, 16x2, hitachi, lcd |
| Thread Tools | |
| Display Modes | |
| |