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 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.
Just buy the most generic, 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.
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).
Yep, the idea is that if you’re going to read row number ‘N’ then you set RowN+ high and RowN- low, and all other Row+ low and all other Row- high. If you want to read Row6 for example then you set Row6+ high and Row6- low, and the rest are reversed.
As RowN+ and RowN- are always the opposite of each other, the octal inverter IC I mentioned previously allows you to just use 8 input lines, since you can have the inverter control all the RowN+ lines by using the inputs from the RowN- lines. If you use a 3-8 decoder IC then you only need 3 inputs, and only 1 of the decoder’s outputs will ever be low at a time.
Edit: There was a minor error in the first diagram, but I can’t edit the post now so I’m posting the updated one here:
ok i wired this circuit up ok i wired this circuit up and here are some things im finding. One that you do not want to make the other circuits all HIGH because then you read those too. But its best to not do anything with the ones your not reading. A single resistor is giving a different value on different squares. What does that mean? finally one resistor on a single row makes all the analog inputs equal to that one value. Thats deffinetly not good. What does this mean when it comes to the circuit? im sure the first thing you will ask me is if i have the analog inputs perpendicular to the rows im driving HIGH and i do. The columns are driven hight to read and the rows are the analog inputs.
you know what nvm. It isnt you know what nvm. It isnt quite as a problem as i thought. It is a small i guess noise problem like a value of 189 would make the square next to it read about 100 but we will see if any resistors have that value of the noise and if not then it wont be too big of a problem. And about the resistor value being different on different squares is wrong too.
Are you driving the Row+ Are you driving the Row+ high and the Row- low? If you have both of those going it should almosst completely wipe out any interference from other squares on the same row.
As much as I hate to add more diodes back into the circuit, this may be the easiest way to cut out interference from adjacent pieces. Unfortunately the original design is not as resistant to that as I had thought.
oh wow. Im not too sure if i oh wow. Im not too sure if i can do that. Um things are starting to become permanent in place. Ill see how the first circuit goes. If it does not work then i will do this but i am not ready yet to change it.