CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

LCD_flex 2X16 (JHD162 A)
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
kamillas



Joined: 24 Oct 2011
Posts: 50

View user's profile Send private message

LCD_flex 2X16 (JHD162 A)
PostPosted: Sun Feb 26, 2012 12:59 am     Reply with quote

I made a circuit with a 2x16 LCD display, but in the simulation it works well, ie, it displays the word "temp", but in achieving it displays square! I have not resistors connected, and I do not think that's his problem, I connected this way,
/ / D0 enable
/ / D1 rs
/ / D2 rw
/ / D4 D4
/ / D5 D5
/ / D6 D6
/ / D7 D7

As the driver of LCD indicates, knowing that I have not connected DB0 DB1 DB2 DB3.
Where is the problem please !!!
Code:

#include <16F877A.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HS                       //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD                    //No EE protection
#FUSES NOWRT                    //Program memory not write protected

#use delay(clock=4000000)

//#include <onewire.c>
#include <lcd_flex.c>

void main()
{
output_high(PIN_A0);
delay_ms(500);
output_low(PIN_A0);

while (1){

output_high(PIN_A1);

lcd_init();
lcd_gotoxy(1,1);
printf(lcd_putc,"TEMP ");
delay_ms(500);
   
output_low(PIN_A1);
delay_ms(500);}
}
 


http://www.imagup.com/data/1144878275.html
http://www.imagup.com/data/1144878486.html


Last edited by kamillas on Sun Feb 26, 2012 1:35 pm; edited 1 time in total
Ttelmah



Joined: 11 Mar 2010
Posts: 19516

View user's profile Send private message

PostPosted: Sun Feb 26, 2012 3:17 am     Reply with quote

First, have you verified you chip is actually running, and running at the speed you expect?.
Does A0 go high, and low again, and is it high for 0.5 second.
If not:

1) is 4000000 > 4MHz - is HS the right fuse?.
2) Is the MCLR pin pulled high?.
3) Is power connected to the PIC?.
It is almost impossible to tell on your pictures (too blurred), but I cannot see a connection to pin 1 of the chip, in which case MCLR is floating, and the chip won't run. Also I can't see the loading capacitors on the crystal, or a decoupling capacitor right by the PIC supply connections. I can't even see the supply connections to the PIC. There looks to possibly be one connection to pin 12, with a long red wire, but no visible connection to pins 11 31, or 32. Red wire to pin 12, is 'puzzling' since this should be the 0v connection.
I'd suspect you have taken the design from Proteus, and have not realised that Proteus _automatically_ makes the supply connections for you. If there is a rail called '5v', or Vdd in the design, it will connect this for you to the Vdd pins on the PIC, and not show these connections in the drawings. Similarly if there is a 0v or Vss line, this is connected to Vss automatically. Also Proteus treats the MCLR input as a TTL input (which defaults to floating 'high'), while in fact it is a CMOS input, with no such default.
Two examples of why people don't like Proteus.....

As a comment, don't keep initialising the LCD in the loop. This wants to be done _once_.

Best Wishes
kamillas



Joined: 24 Oct 2011
Posts: 50

View user's profile Send private message

PostPosted: Sun Feb 26, 2012 5:11 am     Reply with quote

Ttelmah wrote:
First, have you verified you chip is actually running, and running at the speed you expect?.
Does A0 go high, and low again, and is it high for 0.5 second.
If not:



I connected the VSS and VDD MCLR PIC, also clock and two capacitor 22 P, assembly works, means that the LED lights and A1 Goes out, every 500 ms,PIC , the program runs but it appears in the display of tiles in first line

connection :


/ / D0 ---enable
/ / D1 ----rs
/ / D2 ----rw
/ / D4 ----D4
/ / D5 ----D5
/ / D6 ----D6
/ / D7 ----D7


I saw in that other mounting pin (R / W) is connected to GND, is what is his problem.


I also used a second display LCD2X16, he posted the tiles![
kamillas



Joined: 24 Oct 2011
Posts: 50

View user's profile Send private message

lcd2x16
PostPosted: Sun Feb 26, 2012 1:29 pm     Reply with quote

I find in another forum the solution to this problem, but where is the solution (mode 4 bit...)? In the driver lcd_flex,




http://forums.futura-sciences.com/electronique/474012-affichage-lcd-un-p18f4550.html
kamillas



Joined: 24 Oct 2011
Posts: 50

View user's profile Send private message

Always the same problem
PostPosted: Sun Feb 26, 2012 4:51 pm     Reply with quote

Although I used the driver flex_lcd, applied here in the library, and I've connected to pins correctly, and I change with another display lcd2x16, the program works. The microcontroller executes the instruction, the evidence I've tested all the pins connected with lcd, are identical with the simulation, it shows why the tiles!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Feb 26, 2012 7:25 pm     Reply with quote

Quote:
where is the solution (mode 4 bit...)? In the driver lcd_flex,


It's right there in the comments for the Flex lcd driver. See below:
Quote:
int8 const LCD_INIT_STRING[4] =
{
0x20 | (lcd_type << 2), // Function set: 4-bit, 2 lines, 5x8 dots
0xc, // Display on
1, // Clear display
6 // Increment cursor
};


The most likely reason for the flex driver not working is that you
have incorrect connections. Or the contrast voltage is not correct.
kamillas



Joined: 24 Oct 2011
Posts: 50

View user's profile Send private message

!!!
PostPosted: Thu Mar 01, 2012 1:19 pm     Reply with quote

Quote:

The most likely reason for the flex driver not working is that you
have incorrect connections. Or the contrast voltage is not correct.




sir,
I have connected every point, even I tested all outputs peak, he very well with the LEDs, means that all outputs are fine, but when I run the circuit I see that the tiles this is not a problem connecting, even I change LCD display 03 different types! this is not normal! really, I want you to help me

http://www.hostingpics.net/viewer.php?id=386127DSC02499.jpg

http://www.hostingpics.net/viewer.php?id=280131DSC02498.jpg
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Mar 01, 2012 1:37 pm     Reply with quote

Post a schematic of your connections to the LCD. Here's an example:
http://www.extremeelectronics.co.in/pictutorials/images/pic_lcd_interface_schematic.gif
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

ALL LCD's are NOT equal
PostPosted: Thu Mar 01, 2012 4:45 pm     Reply with quote

You're making it very difficult for us, again. This thread's going nowhere fast.

We need ACCURATE & CONCISE information including a schematic.

You're not telling us what your V0 voltage is.

You need to be VERY VERY careful with LCD modules.

I got caught out with the 1602 series parts, even etched a PCB wrong.

They are NOT all the SAME.

They may LOOk the same, BUT have DIFFERENT pinouts & V0 requirements. Start by verifying the part No.

You have to be VERY careful, double check, then check AGAIN, AGAIN, and AGAIN......

On a positive note:-

I applaud your use of white boards. I think they are great. Your layout, however, is ATROCIOUS. You need to keep ALL connections SHORT, NEAT & TIDY, just as you should on a PCB.

AND you MUST pay particular attention to decoupling caps and crystal circuits (they go in first, everything else fits around them).

I only learn ONE thing from your .jpg; the appearance of your LCD. NOTHING else is of value.

Mike
kamillas



Joined: 24 Oct 2011
Posts: 50

View user's profile Send private message

Picture
PostPosted: Thu Mar 01, 2012 6:47 pm     Reply with quote

PCM programmer wrote:
Post a schematic of your connections to the LCD. Here's an example:
http://www.extremeelectronics.co.in/pictutorials/images/pic_lcd_interface_schematic.gif


PICTURE :

http://www.hostingpics.net/viewer.php?id=134402lcd.png

I connected and reconnected the pins quite a few times, I replaced by another LCD but still the same problem. I add my program in a flashing LED on RA0 to whether or not the program executes, then the LED operates normally but the display always shows the tiles! But when I removed all the pins and I removed the voltage for the pic, and I left the LCD connected to 03 pin's (VCC, VSS, VEE) [I have to say I left that these 03 pins connected] tiles still does not go out more, then or is the problem!! Is that if I am going to change by another LCD 1x16 function it?

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!it's tiring

connection's :
Code:

#define LCD_DB4   PIN_B3
#define LCD_DB5   PIN_B2
#define LCD_DB6   PIN_B1
#define LCD_DB7   PIN_B0

#define LCD_E     PIN_D3
#define LCD_RS    PIN_D1
#define LCD_RW    PIN_D2


Code:

#include <16F877A.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)

#include "flex_lcd.c"
   
//==========================
void main()
{
lcd_init();  // Always call this first.
while(1){

lcd_putc("\fHello World\n");
lcd_putc("Line Number 2");
output_high(PIN_A0);
delay_ms(500);
output_low(PIN_A0);
delay_ms(500)

}
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Mar 01, 2012 7:02 pm     Reply with quote

Do some experiments. Edit the lcd_init() function in flex_lcd.c and
increase the delay times by a lot.

1. For example, increase first delay of 15 ms so it is 100 ms. Yes, a lot.

2. Then, in the for() loop, increase the delay of 5 ms so it is 25 ms.

3. There is one more delay near the end of the function for 5 ms. Make it 25 ms.

If that doesn't fix the problem, then edit all the delay_cycles() statements
and change them to delay_us(10).

These are big delays, much more than should be needed, but as a test
it's worth doing, to see if it fixes the problem.
masterat



Joined: 17 Jul 2010
Posts: 26

View user's profile Send private message

PostPosted: Thu Mar 01, 2012 7:11 pm     Reply with quote

Try to insert 20ms delay time before initLcd may be done.
Some LCD working slower than pic MCU.
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Thu Mar 01, 2012 7:18 pm     Reply with quote

Hi,

Is that really how your crystal is wired? Because as shown it's wrong!

Can you blink an LED at a predictable rate?

John
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

LCD Black Squares
PostPosted: Fri Mar 02, 2012 7:23 am     Reply with quote

This topic, or similar, surfaces at regular intervals.

Do a search for either 'square' or 'squares'.

You'll get loads of results, including an odd one less than a week old!

Mike
temtronic



Joined: 01 Jul 2010
Posts: 9228
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Mar 02, 2012 8:09 am     Reply with quote

Like others trying to help. here's a few things I've learned during the past 20 years of using PICs.

1) white boards are fine to use,I've got 16F877s running 20MHz no problem for the past 20 years....18F4550s at 48MHz!

2) buy some 10 conductor, 22ga solid wire cable.Cut off the sheath, and use the 10 wires for neat and tidy interconnections.You'll have all 10 colours !

3) when wiring try to match wire colour to PIC pin( PIC pin 37 =purple, pin 36 = blue,etc.) Always use Black for ground, Red for V+.

4) If possible for the LCD wiring ,use PIC pins = to LCD pins( ie, RB7 -> LCD db7, RB6 -> LCD db6) This is easy to remember, easy to follow.

5) for my testbed, I use 2 whiteboards. the lower one has the 40 pin PIC(16F877, 18F4550) mounted in the far left postion.It's easy to remove for programming. A 16x2 LCD is mounted in the far right postion,this allows easy,clean wiring of LCD pins to PIC. The upper whiteboard has 'peripherals' like MAX232,RTC,sensors,LEDs,opamps,etc. This way it's very easy to rewire the project to use different PIC pins for various functions.

6) all wiring should be neat and tidy.Always add 100mfd filter caps to each whiteboard on the +5, gnd bus lines.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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


Powered by phpBB © 2001, 2005 phpBB Group