3
\$\begingroup\$

I am working on a project that includes a scanning switch matrix. It also includes a joystick with an integrated push button. I am out of IO pins on the micro, but there are gaps in my switch matrix, so I would like to integrate the push button into the matrix. However, the button is permanently internally connected to the ground pin of the joystick.

I am pretty sure I can use an NPN transistor to connect the signal line from the push button across the matrix pins like I would a regular push button, but I want to make sure I'm not missing something important.

I sketched out something I think might work. R3 is the internal pull-up resistor in the micro-controller. For the other switches in the matrix, Q1 would be replaced by a N.O. switch with with series diode connected between ground and the output. I feel like my proposed circuit is backwards and will actually only activate when my push button is NOT pressed, but I think that would just need another transistor to invert that signal.

enter image description here

This is what the circuit looks like for a normal switch in the matrix (note that neither pin is locked to GND as is the case for the switch I am now trying to integrate).

enter image description here

The matrix scanning works by setting a single column low and the rest are tri-stated. Then all the rows are read in. It then switches to the next column and reads in again.

Does anyone have any better suggestions or corrections?

\$\endgroup\$
  • \$\begingroup\$ Can you change your scanner to tri-state the column, instead of pulling it high? \$\endgroup\$ – Phil Frost Feb 1 '13 at 2:51
  • \$\begingroup\$ I just reviewed my code. Looks like I had misremembered my scanning procedure and I am in fact already tri-stating the column. \$\endgroup\$ – ben Feb 1 '13 at 5:33
1
\$\begingroup\$

If you could change your scanning code to either pull the column high, instead of low, then you don't need to do anything special to read this switch. Connect the column input to R2 and read the switch from the junction of R2 and the switch. You'd also want to enable the internal pull-up resistor on the column inputs, instead of the row inputs.

If that's not possible, then your circuit should work. Be sure you tri-state the column, rather than pulling high, otherwise you might reverse-bias the base-emitter junction too much and Q1 might not like it. You could also use a PNP for Q1, which will invert the logic (I think you want that anyway). In the PNP case you can also dispense with R2.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ It sounds like my circuit is indeed going to act as the inverse of what I want (input is low, Q1 will look open, input open, Q1 will pull low, instead of the other way around). Would the problem with R2 be remedied if it were connected to the other side of R1? \$\endgroup\$ – ben Jan 31 '13 at 18:31
  • \$\begingroup\$ @ben it wouldn't be a problem, but I'm not entirely sure why you'd want to do that. Maybe I'm not really understanding you question. Perhaps you could draw a schematic with all the components involved? \$\endgroup\$ – Phil Frost Jan 31 '13 at 20:52
  • \$\begingroup\$ The input is either GND or open, so I figure I need a pull up resistor (R2). \$\endgroup\$ – ben Jan 31 '13 at 21:31
  • \$\begingroup\$ @ben if that's the case, why bother with the transistor at all? I must not be understanding your problem. \$\endgroup\$ – Phil Frost Jan 31 '13 at 21:57
  • \$\begingroup\$ I tried to clarify my question a bit and included the schematic I am trying to replicate and improved the schematic I proposed to better reflect the true functionality. \$\endgroup\$ – ben Jan 31 '13 at 22:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.