LCD 2x16 I2C backlight

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
ule
Posts: 18
Joined: Tue Jan 13, 2015 7:58 pm
Has thanked: 4 times
Been thanked: 2 times

LCD 2x16 I2C backlight

Post by ule »

Hello

I wrote simple program to control backlight on LCD 2X16 I2C. In simulation everything works fine, but in real life not. Backlight is always on. Using arduino nano, push button connected on D2 pin, lcd using i2c in pins C4 and C5.
Attachments
Test backligt.fcfx
(8.5 KiB) Downloaded 259 times

viktor_au
Posts: 354
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 44 times
Been thanked: 62 times
Contact:

Re: LCD 2x16 I2C backlight

Post by viktor_au »


medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: LCD 2x16 I2C backlight

Post by medelec35 »

Hi, ule.
To control the backlight, you will need to right-click on your LCD and select Properties.
Change Use Backlight from No to Yes.
The jumper needs to stay in place for the light to be controlled.
The state of the backlight will be remembered.
With that in mind, if you turn the backlight off, then at a later date when the LCD is repowered, the backlight will remain off.
Martin

ule
Posts: 18
Joined: Tue Jan 13, 2015 7:58 pm
Has thanked: 4 times
Been thanked: 2 times

Re: LCD 2x16 I2C backlight

Post by ule »

Jumper is in, but in settings tab i only see this
Attachments
lcd settings.jpg
lcd settings.jpg (47.92 KiB) Viewed 40624 times

chipfryer27
Valued Contributor
Valued Contributor
Posts: 779
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 186 times
Been thanked: 204 times

Re: LCD 2x16 I2C backlight

Post by chipfryer27 »

Hi

That may have been a "typo".

I was under the impression the I2C LCD wasn't supported until FCv7 but could easily be quite wrong as I don't have any FC on this machine to check and it's been a few years.... I think then backlight control was an option under Component Macro not Properties, being used as per Viktor's link.

In FCv8 I think the backlight is as Martin describes.

I might be typing nonsense of course as I can't check :)

Regards

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: LCD 2x16 I2C backlight

Post by medelec35 »

Hi,
IC2 LCD is supported in v6.
It looks like the enable backlight within properties is not present in V6.
However, it's not required as there is a backlight on/off function.
I have tested the attached project with my I2C LCD and it is flashing the backlight every second.
I have changed the original project to eliminate switch issues
Attachments
Test backlight basic.fcfx
(7.88 KiB) Downloaded 252 times
Martin

viktor_au
Posts: 354
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 44 times
Been thanked: 62 times
Contact:

Re: LCD 2x16 I2C backlight

Post by viktor_au »

Hello
I have a question
Does the BacklightControl macro control the state of on-board of i2c module transistor?
Is it possible to show this macro?
Thanks

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: LCD 2x16 I2C backlight

Post by medelec35 »

hello.
Yes, I believe it does.
It looks like the module's transistor is biased on via a base bias resistor.
One of the outputs from the PCF8574 pulls the base of the transistor low, to turn the backlight off.
Martin

ule
Posts: 18
Joined: Tue Jan 13, 2015 7:58 pm
Has thanked: 4 times
Been thanked: 2 times

Re: LCD 2x16 I2C backlight

Post by ule »

Schematic of i2c backpack interface is something like this. I also tried different versions to turn it off via i2c, but with no success. It does blink, like @medelec35 wrote, otherwise it remain on.
Attachments
PCF8574-I2C-Backpack-Module-for-LCD-1.png
PCF8574-I2C-Backpack-Module-for-LCD-1.png (109.38 KiB) Viewed 40597 times

chipfryer27
Valued Contributor
Valued Contributor
Posts: 779
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 186 times
Been thanked: 204 times

Re: LCD 2x16 I2C backlight

Post by chipfryer27 »

Hi

Back in front of my machine.

I could not find any I2C Display in v6 and seem to have found a "hidden feature" of FC which I'm glad to say is no longer. In Global Options you need to check a box to see everything in a category.....

Unknown Feature.JPG
Unknown Feature.JPG (60.83 KiB) Viewed 40584 times

Quite why this was the case is beyond me but no doubt a reason at the time. I can only hope I had that ticked when I used v6 or I might have upgraded to v7 needlessly :) (v6 only on this machine for historical reasons).

From the schematic it looks like with jumper inserted it would be on permanently until the pin went Low. Have you tried sending "0" using the component macro as per Medelec's chart? That should switch it off permanently or until a "1" is sent.

Regards

ule
Posts: 18
Joined: Tue Jan 13, 2015 7:58 pm
Has thanked: 4 times
Been thanked: 2 times

Re: LCD 2x16 I2C backlight

Post by ule »

Medelec35 chart does only blinking (1s-on/1s-off). I use this before for warnings, but in normal condition the lcd backlight was on. Now I want to backlight stay off until the button is pressed. I posted flowchart with this function in first post, but it only work in simulation mode.

chipfryer27
Valued Contributor
Valued Contributor
Posts: 779
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 186 times
Been thanked: 204 times

Re: LCD 2x16 I2C backlight

Post by chipfryer27 »

Hi

I might have an I2C kicking around to try, but if your hardware is blinking using Medelec's chart with the jumper inserted, then your hardware setup is fine, you would just need to modify to your needs.

If I find the display I'll see what happens for me with the codes posted.

Regards

viktor_au
Posts: 354
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 44 times
Been thanked: 62 times
Contact:

Re: LCD 2x16 I2C backlight

Post by viktor_au »

Hello
Please have a look at the attached file.
I am not sure if that what you are after.
Attachments
Test backlight_4.fcfx
(12.91 KiB) Downloaded 271 times

chipfryer27
Valued Contributor
Valued Contributor
Posts: 779
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 186 times
Been thanked: 204 times

Re: LCD 2x16 I2C backlight

Post by chipfryer27 »

Hi Viktor

Works for me in Sim and I'm sure if implemented in HW it will work there too.

Regards

ule
Posts: 18
Joined: Tue Jan 13, 2015 7:58 pm
Has thanked: 4 times
Been thanked: 2 times

Re: LCD 2x16 I2C backlight

Post by ule »

@viktor_au: yours flowchart works in sim and hardware to. I only had to change i2c data line from C3 to C5. Thank you.

viktor_au
Posts: 354
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 44 times
Been thanked: 62 times
Contact:

Re: LCD 2x16 I2C backlight

Post by viktor_au »

Glad it works.

ule
Posts: 18
Joined: Tue Jan 13, 2015 7:58 pm
Has thanked: 4 times
Been thanked: 2 times

Re: LCD 2x16 I2C backlight

Post by ule »

Well, if I put viktor_au last sample code into my project it does not working as is should. I wrote some other sample code (i think is better, because it does not affects on whole flowchart, because of delay function). Attached code is working in simulation mode and on hardware. But.... :? I figured out, if i put any kind command via i2c to lcd, the display will put the backlight on and will remain on (only if I test on hardware, in simulators works fine).
Attachments
Test backlight_4(1).fcfx
(7.71 KiB) Downloaded 251 times

ule
Posts: 18
Joined: Tue Jan 13, 2015 7:58 pm
Has thanked: 4 times
Been thanked: 2 times

Re: LCD 2x16 I2C backlight

Post by ule »

I used different approach. I cut the trace on pcb of i2c backpack, between the PCF8574 and transistor. Remove pull up resistor from base of transistor. On my pcb i added pull down resistor to D6 on arduino and connected wire to base of transistor. Everything working as i want.
Attachments
Test backligt.fcfx
(7.13 KiB) Downloaded 243 times
backpack.png
backpack.png (1.52 MiB) Viewed 40403 times

Post Reply