textLCD slow screen refresh??

27 Oct 2010 . Edited: 27 Oct 2010

I'm currently using an mbed in an exhibition demo unit. The unit controls a couple of DC linear actuators (with hall effect for position feedback), has an opto sensor input, a couple of pots in, a load of switches, an alarm out and a 20 x 4 LCD for readout for the HMI. The unit is working and the mbed has been a great tool in getting a fast result  :)

All the lcd functions work, i'm displaying everything correctly, positioning correctly (anywhere on any line), the lcd.cls() works so all is well ....... except for the LCD refresh speed. It takes about 1.5 second to refresh an entire screen which is easily noticeable to the user. 

I'm a newbie to C as have been using pics and assembly language up till now but i have used this screen with a pic before and got much quicker refresh rates out of it.

Has anyone else experienced this? Is it a result of the lcd.printf(). I've imported the textLCD library as files to look through it, i understand some of it but cannot fathom how to speed up the printf (if at all possible).

Is this me?? any help would be greatly appreciated

(in the process of trying to upload a pic as we speak)

27 Oct 2010

Hi, Are you running a lot of interrupts that could be interfering with the LCD? Maybe you could post you code here so we can have a look through it?

27 Oct 2010

Hi Martin,

There are no interrupts running whilst displaying to the screen as it is only addressed when the system is at rest. I'll gladly post the code but as i've said i'm new to C so i may not have created the most effecient code or used the most appropriate code structures as a result its quite long. I'll stick a load of comments in and post it in a while.

I will say thought that i experienced this even when displaying to the screen in the hello world program straight from the cookbook.

hmm, i wonder whether this is a result of using 4 bit data bus rather than 8? :/

I'll post the code shortly.

 

 

28 Oct 2010

Hi Martin (smith),

I posted the original question in my work mates profile, this is the real me!

Sorry for the delay, i've been putting comments in and tidying up the code. As i've said i'm fairly new to this C lark and there were a few repeated sections that i've turned into functions to shorten things a bit, i'm sure its still not ideal by a long shot and any comments on how to improve it (code structures etc) would be welcome.

It seemed a bit long to post it so i've published it here medica_demo_V10

The interrupts used are external:

 2 x hall effect sensor counters that are only active when the actuators are moving and are triggered by a rising edge.

1 x push button in, rising edge

1 x opto sensor in, rising edge

The screen is only addressed when the system is at rest so these interrupts shouldn't have an effect on the refresh rate of the lcd. ie when the screen is addressed the processor is doing nothing else.

By the way did you finish your final year at ARU this year?

simon

 

28 Oct 2010

Hi Simon,

I think your code is basically OK and the problem may be to do with the library for the LCD.

If you go into the library and find the method TextLCD::clock() (in TextLCD.cpp, line 121) you will see that the data is latched onto the data lines and the _enable pin is toggled, but with a 5ms delay for each transisition. To write both nibbles will therefore take 20ms, which means that you can write 50 characters / second.

Most of the time you are refreshing the screen by re-writing every character which will take 80/50 = 1.6 seconds.

You can try speeding this up by reducing the delay in the clock method (infact the mbed will take a few microseconds to transistion a pin anyway, so maybe this isn't needed at all?) but check the data sheet to see what the min delay should be. Also you can try to use the lcd.locate function along with a cls() instead of writing spaces as a way to clear characters.

Let us know how you get on.

Martin

28 Oct 2010 . Edited: 28 Oct 2010

I adjusted to 100uS and have an immediate improvement, below this the display doesn't function correctly.

I do use the lcd.locate at various points but need to clear some characters without doing a lcd.cls() as i want to leave some info on the screen when moving from one screen to another, hence the use of spaces

hanks Martin,

Simon

 

 

 

 

28 Oct 2010

The last line in the above post should read 'Thanks Martin, thats put the finishing touches on an otherwise working project' only this text editor seems to have a mind of its own!!