How to reset a Z80 cpu with a touch pad module (TTP223)? - Page 1
Forum section: electronics / projects

author: Rita Graça
author_rank: Contributor
timestamp: December 14, 2023, 04:29:07 pm
content: Hello Everybody.The conventional way of resetting a Z80, is putting a momentary switch between the /reset pin and ground.I would like to use a more elegant way of doing this, using this touch sensor (TTP223):This is for a ZX Spectrum (schematics):https://www.retroisle.com/sinclair/zxspectrum/Technical/Hardware/ZXSpectrumIssue4ab-Schematics.gifThe TTP223 module is powered with the GND and VCC pins. When the touch sensor is activated, VCC is connected to the IO pin.Would it be possible to use this module to implement a reset switch. If yes, how?SOLUTIONS BASED ON THE REPLIES TO THIS THREAD (For future reference):(For more details, check their replies)By MrAl and RoGeorge :By pqass:By themadhippy: Optocoupler instead of the NPN transistor.RoGeorge: "They all should work: either with the series diode, or with the optocoupler (with a series resistor for its LED), or with the bipolar transistor with a series resistor in its base, or with a digital MOSFET, or with just a mechanical press button, whatever you happen to have available."

author: coromonadalix
author_rank: Super Contributor
timestamp: December 14, 2023, 05:48:41 pm
content: https://www.instructables.com/Tutorial-for-TTP223-Touch-Sensor-Module-Capacitive/you have pcb jumpers to play with until you find what you needbut a simple switch would have been better ... if you touch the sensor by error you do a reset ??

author: Rita Graça
author_rank: Contributor
timestamp: December 14, 2023, 10:10:50 pm
content: Quote from: coromonadalix on December 14, 2023, 05:48:41 pmThank you for your reply.I know how to configure the module using the A and B jumper pads.My doubt is on how to use the module as a momentary switch. Which pins do I connect to the /reset pin?

author: SiliconWizard
author_rank: Super Contributor
timestamp: December 14, 2023, 10:25:52 pm
content: You would configure it as: momentary, low output. And connect the output (I/O) to the reset line.The problem with this module (at least as far as I can tell) is that the output is a push-pull (totem pole) output. So if there is any other device connected to the reset line and it tries to pull it low, it will conflict with this module idling high.Ideally you'd want an open drain output instead. The TTP223 IC actually *has* an open drain output pin (at least from its datasheet), which is separate from the totem-pole output, and is probably not connected in the package used on this board. So you have no access to it. That I can tell anyway.It may not be a problem if there isn't anything else connected to /RESET, except a pull-up resistor (which is fine). But if you add another device for resetting, including a mechanical switch, it will just short the TTP223 if you happen to press it and the TTP223 's output is high. If it can be a problem though, you could either try finding another touch sensor module with an open drain output (active low), or configure this one to active high and add a NMOS so that you effectively get an open drain output.As coromonadalix said, I don't think it's that good an idea anyway either, you don't want something too easy to actuate for a 'reset', but that's your choice.

author: MrAl
author_rank: Super Contributor
timestamp: December 15, 2023, 10:34:46 am
content: Quote from: Rita Graça on December 14, 2023, 04:29:07 pmHello there,Wow, a blast from the past ... a Z80 CPU, wow.I had a Sinclair computer long time ago which was based on the Z80 CPU.I later got a TRS80 which was also based on the Z80.I built a controller board from scratch based on the Z80.It was one of my favorite CPU's back then.If you have a problem with a push pull output in that you need just a momentary low while sharing the line with other signals, you can 'try' placing a Schottky diode between the switch and the board. The cathode goes to the switch, so when the switch goes low, the line goes low, and when the switch goes high, the line goes to high impedance not an active high.This does assume that the switch 'high' signal goes just as high as the boards 'high', so if the board is 5v then the switch has to be 5v, otherwise you would have to use a transistor or two which is also not that difficult to do.

author: RoGeorge
author_rank: Super Contributor
timestamp: December 15, 2023, 11:32:19 am
content: Power the touch sensor from GND and +5V (preferably taken from the ZX Spectrum), then connect a diode between Q (pin 1 of the touch sensor) and the \$\overline{\text{RESET}}\$ (from the ZX Spectrum), with the cathode of the diode (the ring, or the bar drawn on the diode's body) to the touch button side, and the anode of the diode to the ZX Spectrum \$\overline{\text{RESET}}\$ side.The series diode will make the module to be seen as open-collector/open-drain from the ZX Spectrum side. A Schottky diode would be preferable (e.g. MBR0520). Any other diode should work as well (e.g. 1N4148), but I didn't try.

author: Rita Graça
author_rank: Contributor
timestamp: December 16, 2023, 01:39:05 am
content: Thank you for all your replies, SiliconWizard, MrAl and RoGeorge.What if I used a relay, who's coil is controlled by a 5V tension? Then I could connect the coil to the I\O pin of the module and the relay switch to the /Reset pin on the Z80 and GND.Would this work?(I attached this image, just in case)I reckon like this, if a device attached to the edge connector (e.g.) tried to used the /Reset pin, it would be possible to do so. Also I can power the module by connecting it to the LM7805 of the Spectrum's power circuit.

author: pqass
author_rank: Super Contributor
timestamp: December 16, 2023, 02:18:28 am
content: According tothisdatasheet the TTP223 can only sink 8mA (or source -4mA) so very unlikely to be able to drive a relay. Also, you're missing aflyback diodeacross the coil to prevent high voltages from destroying the module.To turn thepush-pulloutput of the touch module into anopen collectoroutput, use almost any small signal NPN transistor (like a 2N3904) and 2.2K (up to 10K) base resistor. Then connect the collector to the /RESET input line (and of course, GND). See attached. Instead of an NPN transistor, you can substitute an N-MOSFET like a 2N7000 and 100R.Q:Why is an open collector needed here?A:Because you want your alternate reset to work with the existing power-on-reset logic which consists of a cap C27 and resistor R31. When on, the NPN transistor can only ground the /RESET line. When off, it doesn't inject any voltage at all onto the /RESET line just like a momentary button.

author: Rita Graça
author_rank: Contributor
timestamp: December 17, 2023, 12:41:09 am
content: Quote from: pqass on December 16, 2023, 02:18:28 amI reckon that flyback diode is internal do the relay?QuoteThis is why I was using a relay. I did not want the module to inject 5V constantly to the /Reset pin: an external device might try to reset the system, and potentially a short circuit 5V to GND might occur. I did not realise that although the I\O pin is 5V, its current might not be enough to create a magnetic field that activated the relay's armature.Would this implementation be ok:https://imgur.com/a/efdmtOY

author: pqass
author_rank: Super Contributor
timestamp: December 17, 2023, 01:26:14 am
content: Quote from: Rita Graça on December 17, 2023, 12:41:09 amMost do not have a flyback diode. But I'm sure some manufacturer does somewhere. BTW if you check the digikey link below, you can search for "Diode" as a feature. Only 6 are returned starting >$100! If they do come with a diode, they'd have to tell you the polarity of the coil leads.Quote from: Rita Graça on December 17, 2023, 12:41:09 amRelays are power hungry. For example,thisminiature relay needs 28mA@5Vto energize the coil. They alsobouncelike a momentary button.Quote from: Rita Graça on December 17, 2023, 12:41:09 amYes.Also, with the NPN arrangement, you have the ability to power the touch module from a 3.3V button cell; ie. Vcc can be different to that of the 5V computer. Only the GND and the NPN collector needs to be connected to the computer if the module has it's own power source.

author: themadhippy
author_rank: Super Contributor
timestamp: December 17, 2023, 02:15:08 am
content: instead of a relay how about an opto coupler,even the bog standard 4n35 should work well enough with only 4ma

author: Rita Graça
author_rank: Contributor
timestamp: December 17, 2023, 09:53:21 pm
content: Will the IO pin of the module be able to drive the optocoupler?

author: Rita Graça
author_rank: Contributor
timestamp: December 17, 2023, 10:08:53 pm
content: Quote from: RoGeorge on December 15, 2023, 11:32:19 amIs this implementation OK, also:

author: RoGeorge
author_rank: Super Contributor
timestamp: December 17, 2023, 10:34:47 pm
content: YesQuote from: Rita Graça on December 17, 2023, 10:08:53 pmYes, should work. Of course, it must be a common GND, so there must be a second wire, from the GND of the ZX Spectrum (or of the Z80) to the GND of the touch-button module.They all should work: either with the series diode, or with the optocoupler (with a series resistor for its LED), or with the bipolar transistor with a series resistor in its base, or with a digital MOSFET, or with just a mechanical press button, whatever you happen to have available.

author: SiliconWizard
author_rank: Super Contributor
timestamp: December 17, 2023, 11:11:12 pm
content: Yes a diode in reverse like this will also work, if you have only that available. That was a rather common way of implementing a AND function witthout a logic gate.Don't forget to connect GND and VCC of the touch pad board to the GND and +5V of the computer respectively too. Otherwise that's not going to work.

author: MrAl
author_rank: Super Contributor
timestamp: December 18, 2023, 10:31:53 am
content: Quote from: Rita Graça on December 17, 2023, 10:08:53 pmHi Rita,As per reply #4, I recommend using a Schottky diode if you have one. The logic levels are slightly compromised when we use diodes, but not that bad with this stuff. A Schottky diode has a lower forward voltage drop. A regular Si diode has more drop but higher reverse resistance.

author: Rita Graça
author_rank: Contributor
timestamp: December 18, 2023, 03:31:09 pm
content: Quote from: MrAl on December 18, 2023, 10:31:53 amUpdated the diagram. Thanks!

author: Rita Graça
author_rank: Contributor
timestamp: December 18, 2023, 03:33:43 pm
content: Quote from: SiliconWizard on December 17, 2023, 11:11:12 pmThe module will be powered from the LM7805 in the Spectrum's mainboard or a similarly suitable location.I didn't connect the GND and the Vcc just to make the diagram less "crowded".

author: Rita Graça
author_rank: Contributor
timestamp: December 18, 2023, 03:38:16 pm
content: Quote from: RoGeorge on December 17, 2023, 10:34:47 pmThanks for listing all the solutions. I will edit the original post and put them there, so that this thread can serve as reference.

author: Rita Graça
author_rank: Contributor
timestamp: January 08, 2024, 10:55:41 pm
content: One last question.Shall I put a resistor in series with the diode? I am concerned that a short might occur when the module is activated. I reckon R31 should prevent that, but maybe just in case?Here is the schematics (Z80 on top right):https://www.retroisle.com/sinclair/zxspectrum/Technical/Hardware/ZXSpectrumIssue4ab-Schematics.gif

author: SiliconWizard
author_rank: Super Contributor
timestamp: January 18, 2024, 10:15:54 pm
content: Well, it's a bit running in circles - I mean, if it's guaranteed that nothing else will ever be connected to the /RESET signal that what we can see on this schematic, so a 220k pull-up resistor to +5V, and the output of your touch pad module, then even the diode can be done without.The risk, when adding this series diode, is only if anything else could be connected to the /RESET signal *and* this something else could force a positive voltage (> diode drop) with a low impedance - in this case, yes, it could damage your module if this happens while your module outputs a low level. I think this would be very unlikely, as even additional expansions are unlikely to force the /RESET signal of the CPU to a high level.But if you're really afraid of that, yes, you can add a series resistor with the diode. 1k should be fine. Since R31 is 220k, the low level will still be low enough, and 1k would limit the current in the worst case to < 5mA.

author: RoGeorge
author_rank: Super Contributor
timestamp: January 19, 2024, 10:15:49 am
content: Quote from: Rita Graça on January 08, 2024, 10:55:41 pmR31 is not to prevent short circuits. R31 is to charge the reset capacitor, C27/1uF, when the computer is powered up (and to discharge C27 when the power is removed).When the computer is plugged to power, C27 is discharged, has 0V, and it will start to charge slowly, through R31. It will take a few hundreds milliseconds to charge, and during this time the processor is kept in reset mode, and the power reaches a stable 5V and all other circuits are ready to run. Then the C27 voltage keeps growing, until the processor will read it as a logic '1', which means no longer reset, so it will start running normally.R31 together with C27 are making a delay circuit. Otherwise, if the processor is let to run while the other components are not yet ready, it might end in an unpredictable state (might not boot).About short-circuiting a 1uF charged to 5V with a diode and a transistor, should be no problem with such a small capacitor, but add a series resistor if you want to be safe.1k, as suggested already, should be fine. If it doesn't work (max VILfor Z80 is 0.8V), make the series resistor even smaller.