Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 06:53 05 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : [MMBasic]G8JCF Libraries

     Page 2 of 2    
Author Message
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 05:09am 20 Aug 2014
Copy link to clipboard 
Print this post

Peter,

I think I know what the problem is.

I added OR LCDI2C_RSDataMask to the line where you divide by 16 for low nybble (line 282)

I then got a lot of corrupted data but was looking close..

I think because you OR the RS bit with Byte BEFORE you decide which nyble to write to when you do your divide by 16 you not only lose the RS bit setting you corrupt the actual byte because RS is on high order bits, (because you do the OR RSbit on your data before you shift the high order nybble down to the low order position)

I hope that makes sense.. I am very tired and not good at programming anyway but I am fairly confident that is the problem.

Crikey! I just re-read that and it sounds terrible but I cant think at the moment.. Over to you for now.
Regards,

Mick



Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
G8JCF

Guru

Joined: 15/05/2014
Location: United Kingdom
Posts: 676
Posted: 05:31am 20 Aug 2014
Copy link to clipboard 
Print this post

Mick, David

I think I've fixed the bug, so here's V5, hopefully this will work

If you find it works, then I will update my mmbasic website.

Apologies for the bug.

Peter

2014-08-20_153047_LCDI2CLibV5.zip


The only Konstant is Change
 
G8JCF

Guru

Joined: 15/05/2014
Location: United Kingdom
Posts: 676
Posted: 05:33am 20 Aug 2014
Copy link to clipboard 
Print this post

Hi Mick

Your analysis is correct, (thought you said you weren't a programmer !) and V5 has that fix in it

73

Peter

PS, what time is it down under ?

Edited by G8JCF 2014-08-21
The only Konstant is Change
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 11:00am 20 Aug 2014
Copy link to clipboard 
Print this post

Peter,

This time you have hit the jackpot.. IT WORKS Beautifully.

Great work Peter, I like the way you do your coding.. `relatively' easy to understand (well I struggle a bit but it was well laid out and easy to read).

As to Me programming, well I was DE-Programming, I couldnt fix the problem. And as to time here, I posted my message at 1:09am it is now 7am and off to an all day meeting so I will be more or less out of touch today.

Great lib functions the keypad function is brilliant and no key repeat.. I love the way the INT worked on it to..

Are there limitted interrupt pins? I was under the impression all IO could be used at interrupt?

Mick


Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
G8JCF

Guru

Joined: 15/05/2014
Location: United Kingdom
Posts: 676
Posted: 11:17am 20 Aug 2014
Copy link to clipboard 
Print this post

Hi Mick

Great News, thanks for the positive report.

The 28 pin uMite can only have Interrupts on pins 2,3,4,5,6,7,9,10,14 (see page 6, uMite Manual) and unfortunately NONE of these pins are 5V tolerant - I use a potential divider when I have to feed a Non 5V tolerant pin from a 5V source, 5VLogiC--33K--+--47K---0V.

Anyway, I hope you have a great day.

Thank you for your kind words, I shall publish the LCD and Keypad libraries later on tonight/tomorrow

Take care

Peter
The only Konstant is Change
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 12:43pm 25 Aug 2014
Copy link to clipboard 
Print this post

I don't know if this has been covered yet... I loaded the I2C LCD library and connected a typical 1602 with the "typical" I2C back pack. Ran the code and viola, everything worked out of the box.

Tried another one with a different Chinese backpack and nothing worked. Did a little homework and found that it needs to be init'ed like this...

LCD_INIT &H20, 0, 6, 4, 7
with backlight on = 0 and off = 1 - worked great!!!

The first one worked fine from the library init as...

LCD_INIT &H27, 1, 0, 2, 3
with backlight on = 1 and off = 0

Both modules from ebay.

Hope this helps someone who got the same one I did.
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1133
Posted: 01:23pm 25 Aug 2014
Copy link to clipboard 
Print this post

In the past I have used the i2cLCDguesser.zip to determine the I2C LCD parameters (PCF8574, for Arduinos). Worked fine for me.

I got this results for Chinese backpack PCF8574 modules:

lcd(0x20, 4, 5, 6, 0, 1, 2, 3, 7, NEGATIVE) for mjkdz I2C-modul

uint8_t en =4;
uint8_t rw =5;
uint8_t rs =6;
uint8_t d4 =0;
uint8_t d5 =1;
uint8_t d6 =2;
uint8_t d7 =3;
uint8_t bl =7;
====================================================
lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE) for NON-mjkdz I2C-modul

uint8_t en =2;
uint8_t rw =1;
uint8_t rs =0;
uint8_t d4 =4;
uint8_t d5 =5;
uint8_t d6 =6;
uint8_t d7 =7;
uint8_t bl =3;


@Peter
Thx a lot for your valueable work!

MichaelEdited by twofingers 2014-08-26
 
G8JCF

Guru

Joined: 15/05/2014
Location: United Kingdom
Posts: 676
Posted: 01:54pm 25 Aug 2014
Copy link to clipboard 
Print this post

Hi

Well I guess that the variability of I2C LCD I/F's proves that the library is sufficiently flexible. Perhaps I need to add functions to make the setting of the various pins really simple ?

@Michael, Thank you for your kind words. But, I'm sorry I don't understand the code which you have posted, sorry.

Peter
The only Konstant is Change
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 01:58pm 25 Aug 2014
Copy link to clipboard 
Print this post

  Quote  
Well I guess that the variability of I2C LCD I/F's proves that the library is sufficiently flexible. Perhaps I need to add functions to make the setting of the various pins really simple ?


I think you already did that...

Thanks again for a great library!!!
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1133
Posted: 02:54pm 25 Aug 2014
Copy link to clipboard 
Print this post

@Peter

  Quote  But, I'm sorry I don't understand the code which you have posted, sorry.

It's shows not a code! It's only intended to show different connections to the I2C back pack modules, for example. Used on Arduinos! Perhaps we could someday convert the i2cLCDguesser to MMBasic.

Michael
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 05:46pm 25 Aug 2014
Copy link to clipboard 
Print this post

Hi Lads,

Just to add to the configurations,

The correct setting for my IO Panel (based on the lets make robots.com module and JMans code) is:

LCDI2C_Init &H20,0,4,7,5

With Backlight ON=1 and OFF=0.

When I designed the pinout I looked at many modules and there are many different layouts.. so I feel the LIB needs to be flexible enough (and it seems to be) to handle them all.

I have not found any that have the data nybbles split over the hig/low nybble boundary.. so I feel the way Peter wrote his library is good for that. I think though we probably need a config for whether the backlight is 1 or 0 for ON as it looks like no standard pattern there either.

Mick

Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
G8JCF

Guru

Joined: 15/05/2014
Location: United Kingdom
Posts: 676
Posted: 09:55pm 25 Aug 2014
Copy link to clipboard 
Print this post

Ah, OK, I'll add some code to enable specification of Backlight mode.

Add an extra parameter to LCDI2C_Init, ie BacklightInv. If set to 1 LCDI2C_BackLight(1) would mean backlight OFF, if set to 0 or omitted then LCDI2C_BackLight(1) would mean backlight ON, ie as currently.

More formally


' LCDI2C_Init I2CAddr,NibPos,RSBitNo,ENBitNo,BLBitNo,BLInv
'
' Where I2CAddr is the I2C Address
' NibPos=0 use low 4 bits ie P0~P3, NibPos=1 use high 4 bits ie P4~P7
' RSBitNo is PCF8574 bit number for RS 0~7
' ENBitNo is PCF8574 bit number for EN 0~7
' BLBitNo is PCF8574 bit number for Backlight control 0~7
' BLInv specifies Backlight is turned ON by a 1 or ON by a 0
' If BLInv=0 or is ommitted, then LCDI2C_BackLight(1) turn ON backlight
' If BLInv=1 then LCDI2C_BackLight(0)will turn ON backlight


That should do the trick I think. I'll release a new version of the Lib later on today

73

Peter
The only Konstant is Change
 
G8JCF

Guru

Joined: 15/05/2014
Location: United Kingdom
Posts: 676
Posted: 11:36pm 25 Aug 2014
Copy link to clipboard 
Print this post

Hi

I've update the LCDI2CLib to cater for inverted Backlight Control, ie 0 turns it ON. The updated library is available for download from http://www.g8jcf.dyndns.org/mmbasic/

Extra (optional) parameter, BLInv, added to LCDI2C_Init which specifies if backlight control is Inverted or not.


' LCDI2C_Init I2CAddr,NibPos,RSBitNo,ENBitNo,BLBitNo,BLInv
'
' Where I2CAddr is the I2C Address
' NibPos=0 use low 4 bits ie P0~P3, NibPos=1 use high 4 bits ie P4~P7
' RSBitNo is PCF8574 bit number for RS 0~7
' ENBitNo is PCF8574 bit number for EN 0~7
' BLBitNo is PCF8574 bit number for Backlight control 0~7
' BLInv specifies if Backlight turned ON by a 1 (default) or ON by a 0 (inverted)
'


NB, calls to LCDI2C_BackLight(State) remain unchanged, ie specify State=1 to turn backlight ON, and 0 to turn it OFF, the library will set the appropriate backlight pin state depending on BLInv.

Could someone who has a real Inverting Backlight control please test the Lib and let the group know the results ? I've tested it as best I can, all my LCDs have NON-inverting backlight control, so the best I can do is set BLInv=1, and check that LCDI2C_BackLight(1) turns it OFF and LCDI2C_BackLight(0) turns it ON.

73

Peter
The only Konstant is Change
 
     Page 2 of 2    
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024