Go Down

Topic: New LiquidCrystal library - LCD library (Read 26 times) previous topic - next topic


No apologies needed at all.

As with all good software, you need to arbitrate the usage of shared resources. It is not good practice at all to assume that when you allocate the resources to a particular device/variable, later on someone else has changed it and hence you write it back just in case. Since you are in control of the application, it is up to the application to share a resource and hence to manage it. There are several ways you can do that, for example a software "mux" (a monitor) that reconfigures the IOs before executing a transaction over the share resource.

This is more evident when you work with concurrent systems or multi-threaded environments.


Thanks for the update!

When using a shift register in 2-wire mode, is it possible to control the backlight with bit 1 of the shift register?  My backlight is hooked up according to this schematic.



yes, you can.
While the SR interface code supports both 2 wire and 3 wire modes,
currently only the SR2W interface code has support for backlight control.
From your link to the schematic it looks like you are using a unlatched SR register like the 74LS164 vs using
a 74HC595 in a "non latched" mode (you can see my version of that just a bit lower on the same page
you linked to)

If you look in the header file LiquidCrystal_SR2W.h you will see a detailed explanation
along with ASCII art of how to hook up either SR register for backlight control using bit 1 of the SR.
If you are looking for a simpler anti-flicker circuit, I also included a diagram for simple backlight control circuit that
also removes the flicker. It uses a FET but is simpler
and more power efficient than the one in the schematic you linked to.

The ascii art in the header file needs a bit of an update.
I'm now using 4.7k resistors for all resistors except the current limiting resistor
and the diode is a 1N4148.

--- bill


Hi Bill
Thanks for the quick reply!  Indeed I am using a 74HC595 in 'non-latching' mode.  Thanks for that FPS sketch, it's really neat.  I didn't know you could use if and elif statements for defined objects like that, super cool.

Anyhoo, I made a harness at work that has a 2x16 connector on one end for the LCD and the SR and everything else soldering in the middle, so I'd just have 4 wires going to the controller on the other end.  I used the backlight anti-flicker with the series diodes and transistor but it doesn't seem to be working.  Too bad I heat shrunk it all up before testing...d'oh!  I can just snip off the LCD part though and try out your FET version.

You mention using a 1n4148, but I don't see it in your ASCII diagram:
Code: [Select]
// (LCD BL anode)---[ resistor ]---(vcc)
// (LCD BL cathode)-------------------------------+
//                                                |
//                                                D
//                                                |
// (BL input)----[ 4.7k Resistor ]----+-------G-|-<  (2N7000 FET)
//                                    |           |
//                          (0.1uf)   =           S
//                                    |           |
//                                  (gnd)        (gnd)

Would it go between the 4.7k/0.1uF and the gate of the FET (cathode towards the FET)?


Jun 06, 2012, 07:03 am Last Edit: Jun 06, 2012, 07:07 am by bperrybap Reason: 1
There is quite a bit of "magic" that can be done using the C pre-processor.

Sorry for the confusion. The diode isn't part of the backlight circuit.
The backlight circuit is as shown in the backlight ascii art.
If you look above the backlight ascii art in the header file you will see the ascii art for the 595 circuit.
That includes a diode but it didn't say or recommend one. That is where I'm using a 1n4148.

--- bill

Go Up