Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Libray for character LCD modules (Busy flag/random pins)
Goto page Previous  1, 2, 3, 4, 5  Next
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here
View previous topic :: View next topic  
Author Message
Plons

Bascom Member



Joined: 24 May 2005
Posts: 435
Location: Hilversum - The Netherlands

netherlands.gif
PostPosted: Sat Jul 12, 2008 3:14 pm    Post subject: Reply with quote

Very good. I tried the code you posted, Luciano. Except for the MCU, since I use a M168.
The result: in the picture

So what is going on ? When I do a manual reset, the result is OK. When I come from a power-down situation, it doesn't.

I have to sort that out. It has to do with the OLED. The AVR generates (using PWM) the contrast voltage. When that voltage is (too) low, something goes wrong in the initialization.

What I can confirm now: Luciano is right, the "Config lcdpin etc"-statement is not needed to make LUC_lcd4busy.lib work. But for the OLED I do need it. I will sort it out and let you know.

Thanks for the support !

Nard

_________________
Bascom AVR ver 2.0.8.6
Dragon-lair: http://www.aplomb.nl/TechStuff/Dragon/Dragon.html
"leef met vlag en wimpel, maar hou het simpel"
Back to top
View user's profile
Plons

Bascom Member



Joined: 24 May 2005
Posts: 435
Location: Hilversum - The Netherlands

netherlands.gif
PostPosted: Sat Jul 12, 2008 4:05 pm    Post subject: Reply with quote

This is a tough one.
I modified the hardware to ensure that the Contrastvoltage is 5V at power on. It didn't do a thing .... Sad
Added wait-statements in several places ... just to sort out what would cure the effect: no deal ....

But: a re-init of the OLED does the trick (just a code-fragment shown here, the rest is as shown in previous posts))

Code:
Config Lcd = 20 * 2
Cursor Off Noblink
Cls

Gosub _init_lcd

LCD "Line 1 1234567890123"
Locate 2 , 1
Lcd "Line 2 1234567890123"

Do
 !NOP
Loop

End

So I found a cure, but still don't understand the cause of the phenomenon.

(Note: found a problem in the fuse-setting: the boot-vector was enabled .... instead of the reset-vector. But oh well, it wasn't causing the problem, but still ... I should have noted it before)

Nard

_________________
Bascom AVR ver 2.0.8.6
Dragon-lair: http://www.aplomb.nl/TechStuff/Dragon/Dragon.html
"leef met vlag en wimpel, maar hou het simpel"
Back to top
View user's profile
Plons

Bascom Member



Joined: 24 May 2005
Posts: 435
Location: Hilversum - The Netherlands

netherlands.gif
PostPosted: Sun Jul 13, 2008 12:51 am    Post subject: Reply with quote

I removed the pull-downs on E and R/W ....
Supply the board from a lab-supply ...
Increased delays in luciano's lib .....
Updated Bascom to 1.11.9.2 ...

... and learned a bit more: that Config lcdpin in Options - Compiler - LCD is not as harmless as I (and maybe you ... ) thought: when not overruled by a Config lcdpin in the program, it still sets the DDR-bits as dictated by the Options - Compiler - LCD - setting. Yikes. Never realised that ....
I discovered it because the OLED contrast should be fine even when the PWM-output-pin is configured as input. But the OLED was very dim. (not in the pictures btw)

So: I am stuck. Puzzled. Can fix it with that extra Gosub _init_lcd, but would like to know the WHY ...

I have some other LCD's, but need to make a different cable for those. Sounds like a sundaymorning thingie.

Cheers !

Nard

_________________
Bascom AVR ver 2.0.8.6
Dragon-lair: http://www.aplomb.nl/TechStuff/Dragon/Dragon.html
"leef met vlag en wimpel, maar hou het simpel"
Back to top
View user's profile
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Sun Jul 13, 2008 12:56 pm    Post subject: Reply with quote

Hi Nard,

The routine "_Init_LCD" present in LUC_lcd4busy.lib will set the data
direction of the used pins. The routine _Init_LCD is called when you
call the first LCD command in your code. (In my sample, Cursor Off Noblink).
The routine _Init_LCD present in LUC_lcd4busy.lib overrides the settings
present in the Bascom Options-Compiler-LCD whatever they are.

At power-up, during the hardware initialization performed by the Bascom
initialization code, the data direction of the pins selected from
"Options/Compiler/LCD" is set. To avoid that, just select the radio
button "Data mode = bus". By doing that, no data direction register will
be changed by the Bascom initialization code to support the LCD so that
you will save some program space. If you go back to the Bascom internal
LCD routines, then you must remember to set "Data mode = pin".
Again, the routine _Init_LCD present in LUC_lcd4busy.lib overrides the
settings present in the Bascom "Options/Compiler/LCD" whatever they are.


Best regards,

Luciano


Last edited by Luciano on Fri Aug 13, 2010 7:18 pm; edited 3 times in total
Back to top
View user's profile
Plons

Bascom Member



Joined: 24 May 2005
Posts: 435
Location: Hilversum - The Netherlands

netherlands.gif
PostPosted: Sun Jul 13, 2008 4:25 pm    Post subject: Reply with quote

Finally, finally ....

I had an original HD44780 display, 16*2, and that showed the same problem. And that made no sense. The OLED has a clone of the 44780, so I could imagine some incompatibility there. But this old display should work !
I took another AVR-board, and tested with *several* displays. They all worked fine.

So what is wrong with the OLED-controllerboard ?? It's a straight forward design, in which I had connected the lower datalines D0 - D3 to ground.
And that caused this weird behaviour !!

Mystery solved. Thanks for your support, Luciano. Since PM is disabled on this forum, would you pls. contact me on "2 times my nickname here, no spaces, no capitals, the curl, and then gmail etc" Not to ask you for more support, just want to send you a present.

Nard

_________________
Bascom AVR ver 2.0.8.6
Dragon-lair: http://www.aplomb.nl/TechStuff/Dragon/Dragon.html
"leef met vlag en wimpel, maar hou het simpel"
Back to top
View user's profile
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Sun Jul 13, 2008 6:58 pm    Post subject: Reply with quote

Hi Nard,

You're welcome!
Your "thank you" was more than enough.

Best regards,

Luciano
Back to top
View user's profile
enniom

Bascom Member



Joined: 20 Oct 2009
Posts: 537

PostPosted: Thu Oct 22, 2009 2:55 pm    Post subject: LUC_lcd4busy ... a question Reply with quote

Luciano,

After all this time, lcd_busy is still one of the most innovative solutions for working with LCD's. Congratulations.

If I wanted to use lcd_busy to drive a 40*4, would that be as simple as toggling the E2 line separately via a program-based PORT/PIN Set/Reset just prior to sending the Lcd "Text" command - or - would that interfere with the E toggle built into the lcd_busy.lib?

If the approach above is not possible, how difficult would it be to modify lcd_busy.lib to include the E2 toggle function?

Grazie.
Ennio
Back to top
View user's profile
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Sun Oct 25, 2009 2:14 pm    Post subject: Reply with quote

Hi Ennio,

it should be quite simple to write a library which checks the state of the busy flag of an
LCD with two HD44780 controllers (4x40 LCD). See the original Bascom libraries "Lcd4e2.lib"
and "lcd4busy.lib".

If you have questions about how to do that, please start a new thread in an appropriate section
of the forum.

* * *

Here is a sample how to use the Bascom library "Lcd4e2.lib".
http://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&p=31687#31687
(Busy flag not used).

Best regards,

Luciano
Back to top
View user's profile
Neill

Bascom Member



Joined: 08 Dec 2008
Posts: 50

newzealand.gif
PostPosted: Sun Jan 31, 2010 11:10 am    Post subject: Thanks very Much. Reply with quote

Thanks so much Luciano for your library. It has helped me very much.

Writing to a 4 line by 20 char display is now very fast and means that I can have real time events happening exactly when I need them to, every 50mS and I don't have to worry about how long it is taking to update the LCD.

Grazie,
Neill
Back to top
View user's profile
Aleksandr

Bascom Member



Joined: 29 Jul 2010
Posts: 15
Location: Russian Federation

russia.gif
PostPosted: Sun Aug 01, 2010 6:50 pm    Post subject: Reply with quote

Hi, Luciano!
For me does not work "LUC_lcd4busy.lib".
In what a problem?
My code:
Code:

$crystal = 8000000
$regfile = "m8def.dat"
$hwstack = 64
$swstack = 40
$framesize = 40
Dim X As Byte

$lib "LUC_lcd4busy.lib"

Const _lcddb4_portx = Portb                                 'Valid values: PORTA, PORTB, PORTC, PORTD, PORTE.
Const _lcddb4_ddrx = Ddrb                                   'Valid values: DDRA, DDRB, DDRC, DDRD, DDRE.
Const _lcddb4_pinnumber = 0                                 'Valid values: 0, 1, 2, 3, 4, 5, 6, 7.

Const _lcddb5_portx = Portd                                 'Valid values: PORTA, PORTB, PORTC, PORTD, PORTE.
Const _lcddb5_ddrx = Ddrd                                   'Valid values: DDRA, DDRB, DDRC, DDRD, DDRE.
Const _lcddb5_pinnumber = 7                                 'Valid values: 0, 1, 2, 3, 4, 5, 6, 7.

Const _lcddb6_portx = Portd                                 'Valid values: PORTA, PORTB, PORTC, PORTD, PORTE.
Const _lcddb6_ddrx = Ddrd                                   'Valid values: DDRA, DDRB, DDRC, DDRD, DDRE.
Const _lcddb6_pinnumber = 6                                 'Valid values: 0, 1, 2, 3, 4, 5, 6, 7.

Const _lcddb7_portx = Portd                                 'Valid values: PORTA, PORTB, PORTC, PORTD, PORTE.
Const _lcddb7_ddrx = Ddrd                                   'Valid values: DDRA, DDRB, DDRC, DDRD, DDRE.
Const _lcddb7_pinx = Pind                                   'Valid values: PINA, PINB, PINC, PIND, PINE.
Const _lcddb7_pinnumber = 5                                 'Valid values: 0, 1, 2, 3, 4, 5, 6, 7.

Const _lcde_portx = Portd                                   'Valid values: PORTA, PORTB, PORTC, PORTD, PORTE.
Const _lcde_ddrx = Ddrd                                     'Valid values: DDRA, DDRB, DDRC, DDRD, DDRE.
Const _lcde_pinnumber = 1                                   'Valid values: 0, 1, 2, 3, 4, 5, 6, 7.

Const _lcdrw_portx = Portb                                  'Valid values: PORTA, PORTB, PORTC, PORTD, PORTE.
Const _lcdrw_ddrx = Ddrb                                    'Valid values: DDRA, DDRB, DDRC, DDRD, DDRE.
Const _lcdrw_pinnumber = 3                                  'Valid values: 0, 1, 2, 3, 4, 5, 6, 7.

Const _lcdrs_portx = Portb                                  'Valid values: PORTA, PORTB, PORTC, PORTD, PORTE.
Const _lcdrs_ddrx = Ddrb                                    'Valid values: DDRA, DDRB, DDRC, DDRD, DDRE.
Const _lcdrs_pinnumber = 2                                  'Valid values: 0, 1, 2, 3, 4, 5, 6, 7.

Config Lcd = 16 * 2
Cursor Off Noblink


Main:


Cls

Lcd "Line 1 1234567890123"
Locate 2 , 1
Lcd "Line 2 1234567890123"

Waitms 2000


Goto Main
End
Back to top
View user's profile
Ross_ValuSoft

Bascom Member



Joined: 20 Nov 2005
Posts: 275
Location: Melbourne, Australia

australia.gif
PostPosted: Mon Aug 02, 2010 11:37 am    Post subject: Reply with quote

Do you realise that you are trying to write a 20 character string onto a 16 character screen?

Also ... see if allowing the screen to clear first helps.

Code:

Cls

waitms 500

Lcd "Line 1 1234567890123"
Locate 2 , 1
Lcd "Line 2 1234567890123"

Waitms 2000

 


Cheers,

Ross
Back to top
View user's profile
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Mon Aug 02, 2010 5:35 pm    Post subject: Reply with quote

Hi,

Before testing your program, make sure you disconnect the ISP programmer first.
(The ISP programmer uses the pin PB3).

Best regards,

Luciano
Back to top
View user's profile
Aleksandr

Bascom Member



Joined: 29 Jul 2010
Posts: 15
Location: Russian Federation

russia.gif
PostPosted: Mon Aug 02, 2010 6:03 pm    Post subject: Reply with quote

Thanks, Ross_ValuSoft. Why I have not guessed?)))
Luciano, I certainly disconnect isp prrogrammer.



Thanks all for the help
Back to top
View user's profile
Frankeman

Bascom Member



Joined: 11 Aug 2004
Posts: 948
Location: the Netherlands

netherlands.gif
PostPosted: Mon Aug 02, 2010 7:28 pm    Post subject: Reply with quote

Hi,

Write a little test program that toggles every used pin which is connected the the LCD.
Do this pin by pin and measure al the connections on the display.
This way you are sure that every connection is correct and a short circuit can be found.
Back to top
View user's profile
Aleksandr

Bascom Member



Joined: 29 Jul 2010
Posts: 15
Location: Russian Federation

russia.gif
PostPosted: Mon Aug 02, 2010 8:00 pm    Post subject: Reply with quote

Frankeman, i used multimeter for testing connection to LCD.
All connections is good. Changed controllers, without result.
There are at someone else ideas? Idea
May be "LUC_lcd4busy.lib" not for all kontrollers?
Mr.Luciano! On what controllers you have checked up "LUC_lcd4busy.lib"?



Best regards
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here All times are GMT + 1 Hour
Goto page Previous  1, 2, 3, 4, 5  Next
Page 2 of 5

 
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
You cannot attach files in this forum
You cannot download files in this forum