# Multiplexing for my chess robot

Base over Apex showed to me that the "ghost piece" i was talking about could be fixed this way below.

Oh yeah i am doing this because my shift registers... well something happened...no im doing this.

This is a common problem. The answer is a diode on every switch. You still need to scan the rows and columns individually.

Here's how to kill the ghost:

Make your board with only 16 wires instead of 65.

Ok my question is how does a diode on every switch change the "ghost piece" problem?

and on the multiplexing where does the gnd go?

i am using arduino so it has a built in pull down resistor but idk how this darn multiplexing works.

## Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Arduino has a built in PULL-UP resistor, there's a big difference. :)
ok what ever. any help with my question?
slap

There are no grounds involved in multiplexing. The idea is to use your outputs as either a high signal, or as a ground which can be done in the program itself. I forgot exactly what its called, but basically you can set an output to low which the circuit will use as a ground. Theres no specific ground wire persay.The pullup resistor is used to tie a pin to high? because when you're reading your inputs you wouldnt be able to detect the lows? i think its something like that. try google :P also google charlieplexing

edit: this might in fact be charlieplexing but the two are asimilar.

Hey PM, here's the formula I mentioned earlier:
C = D + (5V - D)×(Rl÷(Rh+Rl))
Where C is the column voltage you read from the analog input, D is the diode voltage (requires testing, probably less than 0.7V), Rl is the low-side resistance (a few kΩ will do), and Rh is the high-side resistance (i.e. the resistance that the particular chess piece has).
I'll write up a table of optimum values tomorrow if you remind me, sadly I'm out of time for today.

Edit: got home a little earlier than expected, so I'll continue.

You can rearrange the above formula to get:
Rh = Rl×((5V - D)÷(C - D) - 1)
If we assume D is 0.7V and Rl is 5kΩ, we get:
Rh = 5,000×(4.3÷(C - 0.7) - 1)
For maximum distance between piece identifier voltages, we'll take a minimum voltage of 1V and a maximum of 4.3V, with 0.3V spacing between each piece. Altogether this gives us the following table:

ID Voltage:       Chess Piece Resistor:
5.0V                            0Ω (i.e. this square has a short circuit!)
4.3V                        972Ω
4.0V                     1,515Ω
3.7V                     2,167Ω
3.4V                     2,963Ω
3.1V                     3,958Ω
2.8V                     5,238Ω
2.5V                     6,944Ω
2.2V                     9,333Ω
1.9V                   12,917Ω
1.6V                   18,889Ω
1.3V                   30,833Ω
1.0V                   66,667Ω
0.7V                          ∞Ω (i.e. this square has nothing on it)

You don't have to be perfect with the resistor values - these are just the 'perfect' ones. As long as they're fairly close to the target value it'll be easy enough for the ADC to tell them apart.

Thanks alot, will buy these ASAP. What diode would be good for this and what value?
Just buy the most generic, boring diodes you can find, IN4148 or something along those lines. They only have to withstand 5V max reverse voltage and less than 1mA forward current.

here are the resistor values i was able to find close to those. Are the close enough?

 RES 910 OHM 1/4W 5% CARBON FILM 0 0.08000 \$0.08 3 1 CF1/41.5KJRCT-ND RES 1.5K OHM 1/4W 5% CARBON FILM 0 0.08000 \$0.08 4 1 CF1/42.2KJRCT-ND RES 2.2K OHM 1/4W 5% CARBON FILM 0 0.08000 \$0.08 5 1 CF1/43KJRCT-ND RES 3K OHM 1/4W 5% CARBON FILM 0 0.08000 \$0.08 6 1 CF1/43.9KJRCT-ND RES 3.9K OHM 1/4W 5% CARBON FILM 0 0.08000 \$0.08 7 1 CF1/45.1KJRCT-ND RES 5.1K OHM 1/4W 5% CARBON FILM 0 0.08000 \$0.08 8 1 CF1/46.8KJRCT-ND RES 6.8K OHM 1/4W 5% CARBON FILM 0 0.08000 \$0.08 9 1 CF1/49.1KJRCT-ND RES 9.1K OHM 1/4W 5% CARBON FILM 0 0.08000 \$0.08 10 1 CF1/413KJRCT-ND RES 13K OHM 1/4W 5% CARBON FILM 0 0.08000 \$0.08 11 1 CF1/418KJRCT-ND RES 18K OHM 1/4W 5% CARBON FILM 0 0.08000 \$0.08 12 1 CF1/430KJRCT-ND RES 30K OHM 1/4W 5% CARBON FILM 0 0.08000 \$0.08 13 1 CF1/468KJRCT-ND RES 68K OHM 1/4W 5% CARBON FILM

Ok, diagram got a little chewed up by the resize, but it's legible enough. The first 2 full rows and the last full row are shown.
D is whatever diode you can find, R is for the resistance of the piece that's on that square (infinite for no piece). The Rows are your digital outputs (active on Row- low, Row+ high), and the Cols are your analog inputs.

Edit: So I don't forget, the rows can be controlled by only 3 outputs by using a 3-8decoder (74HC138) and an octal inverter (74HC240).

ok question. So does the row8- get driven high if im not reading that row?