Use LCD INPUT to turn TRANSISTOR on and off. - Page 1
Forum section: electronics / beginners

author: ptumb
author_rank: Newbie
timestamp: May 15, 2021, 01:04:28 pm
content: Hi,I need a little help. I have purchased an automatic fish feeder. It is a programmable little device with a motor attached. It switches the motor on at the set time and it will rotate the food container allowing some fish feed to fall out in a small hole. It has 5 buttons and an LCD display.I wanted to add wifi smart functionality to the device without going into any programming so the easiest way I can think of is just to add an ESP-01 board and connect a GPIO pin to the "manual feed" button through a diode on the fish feeder PCB. When the GPIO is set LOW it activates the fish feeder. I already completed this part and it works fine.I have tasmota flashed on the ESP-01 and my Alexa speaker finds it as a smart witch. I have changed some settings in tasmota configuration so when I flick on the "smart plug" it stays on for 10ms and it turns itself off. This gives a button press for the fish feeder PCB.And Bob's your uncle...But I have one more thing.The ESP-01 uses power obviously. And if I turn off the fish feeder I want the ESP module to turn off too. There is no physical on/off switch on the device but just a push button.When I turn off the fish feeder All the symbols go away from the LCD display except the battery level indicator. Meaning the display is always powered no matter what.There is no LED or any other status on the device. All information is shown on the LCD itself.I want to get a signal from the LCD to control a transistor to cut power when a symbol on the LCD disappears.Now we getting into an area I have no clue how to achieve.So on the board there are only a few components. 4057a li-ion battery charger, dw01a and 8205a battery protection IC and mosfet, 7530-1 3v voltage regulator, and some resistors and capacitors.There is also a microcontroller with its numbers removed...I only have a multimeter to play with.. I'm a beginner hobbyist. A beginner in between beginners..I have tried to measure everything on the board when it is on on its on and off state but I could not find any difference in voltage anywhere. It seems that the microcontroller is always on and running and there is no change in any legs of the microcontroller.I have then spent a little time online to try to understand how the LCD works and may be I could use that to get a signal. All the pins of the lcd measure 1.5V with my multimeter.So after watching a few videos on youtube now I understand the LCD needs an AC signal and how it's driven from a DC output of the microcontroller.In theory if I hook up another microcontroller all I need to look for is if the actual pins for that symbol on the display I want to "watch" gets a positive voltage in the same time then the symbol is off and if one pin of the two get their voltage pulses inverted the the symbol is on.The problem is I need another microcontroller for that and I don't want to use additional power when the feeder is turned off.The easiest way would be to reprogram the microcontroller to have a signal from one of its legs but this is not possible unless I learn how to code.So here is the big question. Is it possible to switch a transistor based on the LCD symbols shown or not?

author: Terry Bites
author_rank: Super Contributor
timestamp: May 15, 2021, 05:05:24 pm
content: Yes, so long as you dont draw too much current from the LCD segment driver.This circuit employs the dark satanic Miller effect. Beware!Any old, signal diode, npn and the cheapest p-ch mosfet you can find.R2 determines how slowly it turns off, R1, how fast it comes on.

author: ptumb
author_rank: Newbie
timestamp: May 16, 2021, 06:45:50 am
content: Thanks for your reply. The circuit looks great I’ll probably use it at some point but this won’t work with the LCD driver.So let’s just ignore all other pins of the LCD and focus on 2 of them.The ground pin and the pin of the segment I need that state of (on/off).So the way the DC microcontroller drivers them is they apply a square wave form to the ground pin. If you want the segment to be ON you have to drive it with the inverted wave form of the ground pin.But if you wanted that segment to be OFF you have to drive it with the same wave form as the ground pin.Both pins the ground and the segment pin are always driven no matter if the sedment is displayed or not the difference is only in the wave form.For this reason when it’s measured with a multimeter there is always a voltage in all 19 pins of the LCD display regardless of it displaying anything or not.And indeed when I measure the 19 pins the multimeter shows 1.5v on every single one even though only the battery symbol is displayed.As I said I’m a beginner and I know only so little about the topic.I got this info from this video:https://youtu.be/ZP0KxZl5N2oYesterday I was thinking about a method but I don’t know if that would work.So lets call ground pin and the segment pin A and B.I want to connect A to the gate of transistorA. The source would be connected to 3v via a pull up resistor.Drain would be connected to source of transistorB and drain of the second one would be connected to ground. And of course B would be connected to gate of transistorB.So I just connected 2 transistors in series and if both gates pulled high then the 3v pulled voltage on the source would be grounded through the 2 transistors.If the segment is on on the LCD then the g signals from A and B would never occur in the same time so the 3v pulled up signal never goes to ground.If the segment is off then A and B would have the same square wave meaning they would open and close the 2 transistors in the same time and my pull up signal would get grounded every time the wave form is high.May be there would be a measurable difference there. But I’m really not sure.As I said I’m a beginner beginner. No electronic background. Just trying to tinker.Any comments would be appreciated.

author: ledtester
author_rank: Super Contributor
timestamp: May 16, 2021, 07:35:01 am
content: A single XOR gate might be the simplest way to go, one input from the "ground" pin and the other from the segment pin:https://www.onsemi.com/pdf/datasheet/nl17sg86-d.pdfAnother idea which seems to simulate correctly:The output (taken at the drain of the MOSFET) will be oscillating if the gate and source are out of phase and 3.3V if they are in phase.

author: newbrain
author_rank: Super Contributor
timestamp: May 16, 2021, 08:39:29 am
content: A silly question:Can't you tap the on/off button as you did with the feed one?I don't know if the ESP-01 has got deep sleep modes and wake up from a pin, but even if not it's still easier to concoct a toggle from a button than from an LCD segment.

author: Ian.M
author_rank: Super Contributor
timestamp: May 16, 2021, 09:29:36 am
content: *IF* its a static drive LCD, I believe Ledtester is on the right track with using an XOR gate. However you probably need to drive a high side P-MOSFET to switch power to the ESP-01, so need to generate an active low gate drive signal. The simple XOR gate's output is low when its inputs match (i.e. LCD segment off), so you need to invert that. The simplest solution is to use a dual XOR gate e.g.74LVC2G86with one input of its second gate tied high to make an inverter. The LCD drive waveforms may not be perfectly in-phase/antiphase, so the XOR gate is going to generate glitches at the edges, so you also need a RC low pass filter between it and the inverter e.g. 10K and 10nF for a time constant of 100uS, then the second gate output can drive the MOSFET gate through a 100R resistor. The same arrangement will work for a linear regulator with an active low enable pin, omitting the 100R resistor. If its active high, the single XOR will probably work, with the glitch filter between its output and the enable pin, but if the enable pin levels or input impedance don't 'play well' with the glitch filter, use the dual XOR with the second input of the second gate strapped low to make it a non-inverting buffer.However, this all depends on the LCD being static drive (i.e. only one common pin). If its multiplexed the waveforms get *MUCH* more complex and a simple XOR wont be able to extract the segment state. Seehttps://www.edn.com/how-an-lcd-controller-drives-an-lcd-glass/Getting a valid 'segment on' signal out of that mess is likely to involve a differential amplifier, then amplitude detection of the result, with averaging over a long enough period to stop it pulsing at the multiplexing frame rate, then thresholding. That's likely to be a total mess to implement and Newbrain's suggestion of doing something with the power button signal is likely to be the only viable option, even though there's a risk of the ESP-01 power state getting out of sync with the original MCU firmware's power mode.

author: Zero999
author_rank: Super Contributor
timestamp: May 16, 2021, 01:10:48 pm
content: Quote from: Terry Bites on May 15, 2021, 05:05:24 pmThat won't work, because the MOSFET is upside down.

author: Ian.M
author_rank: Super Contributor
timestamp: May 16, 2021, 01:19:05 pm
content: Also, the segment is certain to be driven with AC to prevent degradation of the LCD due to sustained DC bias, so its unlikely that a single segment state can be detected with Terry Bites circuit, even if its a static LCD, as it doesn't sense the voltage with reference to the LCD common.

author: ptumb
author_rank: Newbie
timestamp: May 19, 2021, 05:27:17 pm
content: Uh ohh..Thanks for the very detailed reply.I do believe it is a multiplexed display with 4 common pins.I would probably try to go ahead with using a XOR gate but I'll skip the other option...That sound like a too big bite for me.Yes the power button tapping would work but they could do get out of sync and this is my very fear.I think I will just go with a less elegant option here and install a rocker switch somewhere on the case to power the ESP-01 module separately.This will be a lot more time efficient and economical way of doing it and since I only need the fish feeder once or twice a year while we go on holiday this low tech option makes more sense.However I do appreciate your time and I definitely did learn something from it.Thanks again