Reading Tri-direction Scan Switch (C&C TPC Series)

AI Thread Summary
The discussion focuses on understanding how to read the state of a C&K TPC series tri-direction scan switch using a GPIO port expander in an I2C setup. Users suggest connecting the switch pins to specific port bits and applying voltage to decode the switch's positions, emphasizing the need to handle all possible states to prevent crashes. A more efficient approach involves using internal pull-ups on the GPIO chip instead of external resistors, which is beneficial for space-constrained projects. Participants also advise conducting continuity checks to clarify the ambiguous wiring in the datasheet. The overall goal is to integrate the switch into a modified Wii Nunchuck for additional controls as a USB HID device.
Jiggy-Ninja
Messages
309
Reaction score
1
I'm trying to figure out a bit of a http://www.ck-components.com/tpc/navigation,10475,en.html. Data sheet is in the Literature box marked "Download TPC catalog pages".

The electrical sketch on page two is what's confusing me. How would I read this switch to figure out what its state is? This switch is going to be on the far side of an I2C connection along with a few other buttons, so I was thinking about using a GPIO Port Expander like the chip I linked to to read it, but I'm confused about how to do that.

Would it even be possible to deduce the state of the switch from a single reading? Or would I have to take multiple readings, fiddling with the input/output settings of the bits to figure it out?

EDIT: That should be C&K in the title. Could a mod please correct that?
 
Last edited:
Engineering news on Phys.org
Well the switch looks like it has six positions
and with three bits you can decode eight states..

Datasheet shows three switches that connect four terminals, see "electrical sketch" on page 2.
If you applied voltage to one pin, maybe pin 1-
The other three pins would decode to switch position.
Presumably you can read in a word from that port expander and examine the individual bits.

Be sure the program handles all eight states - you don't want it to crash if the switch breaks and gives you one of the two missing codes.
 
None of that tells me anything I didn't already know. This switch configuration looks quite unorthodox, and I've never dealt with it before and have no idea how to deal with it. I was looking for more specific advice on a configuration or sequence of steps I could use to read the switch state.

If something other than a generic GPIO port expander is necessary to do that, I could work with that. Component count needs to be kept to an absolute minimum though. I2C is also required.

The actual project I'm looking to do with a switch like this is modifying a Wii Nunchuck to add some extra controls and interface it to a computer as a USB HID device. This is one switch I was looking at to act as a mouse scroll wheel.
 
I was looking for more specific advice on a configuration or sequence of steps I could use to read the switch state.
Connect switch pins 0,1,2,3 to port bits 0,1,2,3 .
connect +5V to pin 1.
Read the four bits, pin high = 1
Initial = 0101
Scan Left = 1100
Scan Right = 0100
Select Left = 1101
Select Right = 0111
Select mid = 1111

Note the drawing itself is ambiguous about select left & right
http://www.mouser.com/ds/2/60/TPC_31aug10-23106.pdf page 2
but a simple continuity check with multimeter will show for sure how it's wired.

I was unable to discern from datasheet whether you'll need pulldown resistors,

If that's not the answer then i misunderstood the question.
 
That is exactly what I was looking for, thank you.

A more optimal solution, especially since this would be used in a space-constrained project, is to ground pin 1 (or 2, since it's symmetrical) and use the internal pullups on the GPIO chip, instead of requiring 3 external pulldowns.
 
Jiggy-Ninja said:
That is exactly what I was looking for, thank you.

A more optimal solution, especially since this would be used in a space-constrained project, is to ground pin 1 (or 2, since it's symmetrical) and use the internal pullups on the GPIO chip, instead of requiring 3 external pulldowns.

YES ! I knew that you knew and just needed to be convinced of it !

Thanks for that reponse.

BUt work it out on paper - be sure each position gives a unique code, and remember to handle the impossible ones so program won't bomb on stuck switch.
I usually declare 'impossible' code to be same as 'off', so user sees switch malfunction as failure to respond.

old jim
 
Last edited:
Back
Top