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 support@ccsinfo.com

Reset LCD

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Pipo
Guest







Reset LCD
PostPosted: Mon Nov 23, 2009 12:42 pm     Reply with quote

There is some way to reset an LCD from software?

Because of some high electrical noise, the LCD sometimes hangs up, but if I short the ENABLE pin to ground for some time (less than a second) the LCD go back to normal.

So I need to do this by software. I try output_low(PIN_B0) (enable pin) for some milliseconds but nothing happens.

If I look with an oscope the enable pin, when the high noise is present and the LCD hangs up, the waveform of the ENABLE pin seems to be inverted, for example:


Normal: ______-_____-_____-______

When hang up:-------_--------_--------_-------


What can I do?

Thanks!
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Nov 23, 2009 1:04 pm     Reply with quote

Your question sounds confuse. The enable pin is controlled by the software, so a unusual waveform at this pin
doesn't contain an information about the LCD controller state. You may be right about a necessary controller reset anyway.
Clearly pulling down the enable pin does not reset the controller.

The full initialization sequence, including the setup of bus width from an possibly unknown state, can always reset a
standard Hitachi compatible LCD controller according to my experience. A power supply cycle of course can, too.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Nov 23, 2009 2:33 pm     Reply with quote

You could have the PIC switch the power to the LCD on/off.
Look on page 22 (page 26 in Acrobat reader) of the PicDem2-Plus (Rohs)
board. It shows a transistor which switches power on/off to the LCD.
The transistor is controlled by a PIC pin.
http://ww1.microchip.com/downloads/en/DeviceDoc/51275d.pdf
I probably would have included a pull-down resistor on the PIC pin
so that if the pin is floating, the transistor base is guaranteed to be
held low. That may not be necessary, I'm not a transistor designer,
but I try to be cautious.
Guest








PostPosted: Mon Nov 23, 2009 2:38 pm     Reply with quote

Thanks for you answer... I know its confusing... but thats the problem... and i can't reset the controller.

If I, after a hang up, execute the init_lcd() function nothing happens.

If I (with a small wire) connect the enable pin to ground, the LCD continues with the execution.

When a noise pulse is present, the LCD goes into a "pause" state... showing the information on the moment of the noise pulse... if, a second noise pulse is present, then, the LCD continues working ok.

I don't know what can I do.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Nov 23, 2009 3:03 pm     Reply with quote

The real solution is to analyze and cleanup the fundamental noise
problem. Use grounded metal shielding for the board. Carefully filter
the incoming power. Anything else is just doing band-aids on the
problem. There are appnotes on this:

Designing Microcontroller Systems for Electrically Noisy Environments
http://ecee.colorado.edu/~mcclurel/iap125.pdf
Guest








PostPosted: Mon Nov 23, 2009 3:12 pm     Reply with quote

Yes, you are right.

The main problem is that the enclosure is ABS plastic... so I can't do a faraday cage or something like that.

I try shielding the LCD pins on a metal grounded cage, but still the same problem.

The LCD pins are connected direct from the pic with metal pins.
Guest








PostPosted: Mon Nov 23, 2009 8:46 pm     Reply with quote

Problem solved... BY SOFTWARE.

The LCD library has a while loop on the send byte function. If in the moment that the pic is entering that while receive a NOISE PULSE, then, the pic get stuck on that while forever!, so I put a "timed while" to prevent that.

Conclusion, the LCD never hang up again.

I know that this is a band-aid, but solves the problem. The entire circuit is in a VERY noisy environment. I'm sure the PCB is designed correctly, I even put a grounded shield for the LCD pins... The noise then became lower... but that does not solve the problem.
Code:

void lcd_send_byte( BYTE address, BYTE n ) {
   int i=0;
      lcd.rs = 0;
      while ( bit_test(lcd_read_byte(),7) )
         {
         i++;
         if(i>200)goto ENDWHILE;
         }
      ENDWHILE:
      lcd.rs = address;
      delay_cycles(1);
      lcd.rw = 0;
      delay_cycles(1);
      lcd.enable = 0;
      lcd_send_nibble(n >> 4);
      lcd_send_nibble(n & 0xf);
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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