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

Click For Summary

Discussion Overview

The discussion focuses on understanding the operation of a tri-direction scan switch from the C&K TPC Series, particularly how to read its state using a GPIO Port Expander in an I2C configuration. Participants explore the switch's electrical sketch and its implications for interfacing with other components in a project, specifically modifying a Wii Nunchuck.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Experimental/applied

Main Points Raised

  • One participant expresses confusion about how to read the switch's state from the electrical sketch provided in the datasheet.
  • Another participant notes that the switch has six positions and suggests that three bits can decode eight states, proposing a method to apply voltage to one pin and read the other pins to determine the switch position.
  • A participant requests more specific advice on the configuration or sequence of steps needed to read the switch state, indicating a need for minimal component count and I2C compatibility.
  • One suggestion involves connecting specific switch pins to port bits and reading the bits to determine the switch state, while also noting the ambiguity in the datasheet regarding certain switch configurations.
  • A later reply proposes an alternative approach to ground one of the pins and use internal pull-ups on the GPIO chip to optimize space in the project.
  • Another participant emphasizes the importance of ensuring each switch position gives a unique code and suggests handling impossible codes to prevent program crashes.

Areas of Agreement / Disagreement

Participants express varying levels of understanding and seek clarification on specific configurations. While some suggestions are made regarding how to read the switch, there is no consensus on a definitive method, and the discussion remains somewhat unresolved.

Contextual Notes

Participants mention limitations in the datasheet and the need for further clarification on the switch's wiring and configuration. There are also concerns about handling potential switch malfunctions in programming.

Who May Find This Useful

This discussion may be useful for electronics hobbyists or engineers working on projects involving GPIO Port Expanders, I2C communication, or similar switch configurations, particularly in space-constrained applications.

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:

Similar threads

Replies
12
Views
3K
Replies
10
Views
5K
  • · Replies 14 ·
Replies
14
Views
6K
  • · Replies 14 ·
Replies
14
Views
7K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 11 ·
Replies
11
Views
6K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 2 ·
Replies
2
Views
8K