Uncategorized

colour pegs

Sensor to distinguish between different types of pegs on a pegboard

Ask QuestionAsked 2 days agoActive todayViewed 2k times81

I have a project that is essentially a pegboard with 4 different types of pegs. Each peg fits into every hole, but when one is inserted, I’d like to digitally record its type and position. There are a total of 120 pegs, 30 of each type. The board itself is a square grid, with at most 40mm between holes. The size and design of the pegs and holes hasn’t been decided yet.

The simplest and cheapest idea I could come up with was a switch at the bottom of every hole and a separate input method to declare the type: eg. 4 buttons somewhere on the side, which you could push afterwards to tell the system that type A was just inserted. This has a large effect on the user interface, one I’d like to avoid.

I could design the hole to be asymmetrical, wire 4 switches to the bottom and have each peg have 4 prongs with one being longer than the others. That would mean soldering a lot of very tiny things together and a more delicate final product, though.

Cost is also an issue, as it’s a hobby project.

Is there some sort of sensor I could use for this?

Edited to add: I should have probably said this to start off with, but I tried to slightly generalize the question to maybe make it more useful: the project is a board game. The idea is to have up to 4 players capture territory on a board and have the board itself handle all the necessary bookkeeping in real time.sensorshareedit  follow  flagedited 5 hours agoasked 2 days agoCelos18944 bronze badges New contributor

  • 1One suggestion is the following: (1) “Load” the 4 types of peg with different weights, eg, Type 1 peg = 10 grams, Type 2 = 20 grams, (2) buy 102 cheapy weight sensors (US$5 for 5 pieces): aliexpress.com/i/32669458593.html, (3) put each sensor at the bottom of the hole, and connect it with a fixed value resistor to form a voltage divider. (4) Now when a peg is inserted, the weight changes resistance of the weight sensor and therefore the voltage of the voltage divider, (5) Arduino ADC pins can be used to measure the voltage and therefore know which type of peg is inserted. – tlfong01 2 days ago    
  • 2PS, we don’t need 120 Arduino ADC pins to measure 120 voltage signals. Usually we EE guys use a matrix keypad like to “scan” the keys to tell which key is pressed. Eg 12 x 12 I/O lines can scan 144 binary keys. But of course “weighted” analog keys/pegs might make my suggested design very complicated. But to us EE engineers, nothing is impossible. Instead of matrix scanning, we can also consider demux analog selectors connected to cheapy 8 channel MCP3008 ADC modules. Just brainstorming, cheers. – tlfong01 2 days ago   
  • 4Analog synthesisers did this in the early 1970s … possibly inheriting their plugboards from ENIAC-era computers. Look for “plugboards” and if you cat’t find any, just buy a thousand jack sockets and make your own. Fit one of 4 different resistor values in each plug. – Brian Drummond 2 days ago
  • 2What is the position of the board? Is it in horizontal position, as over a table, or vertically fixed in the wall? – mguima 16 hours ago
  • 1@mguima the original idea was horizontal, although now that I think about it, it should work both ways. – Celos 5 hours ago

add a commentstart a bounty

7 Answers

ActiveOldestVotes19

Use a multi-pole jack plug.

enter image description here

Figure 1. Random 4-pole, 3.5 mm jack plugs from Wish.com.

schematic

simulate this circuit – Schematic created using CircuitLab

Figure 2. Plugs can be encoded by shorting out the tip, ring 1, ring 2 to sleeve pins in a binary code pattern.

You can’t use code 0 as this will be the same as no plug inserted. That leaves you with seven possibilities and you only need four. Colour-coding the plugs to indicate their numerical value seems a good idea to me.

schematic

simulate this circuit

Figure 3. Preventing cross-feeds. 1N4148 diodes should be small enough to fit two into a plug.

As pointed out by @A.I.Breveleri the addition of diodes in the plug allows the use of a keyboard scanning solution. In this type of arrangement the diodes prevent cross-feeds when multiple keys are pressed. The same arrangement would work here.

enter image description here

Figure 4. Keyboard matrix example. Image source: Gammon.com.

See the linked article for an explanation.shareedit  follow  flagedited 2 hours agoanswered 2 days agoTransistor124k99 gold badges125125 silver badges280280 bronze badges

  • 3Alternatively, use sockets with break contacts. This would allow you to detect when a plug is inserted, independently of its binary code. Then TRS plugs could be used to give a 2-bit code. It may come down to what is the cheapest option, given the number of plugs and sockets needed. – Simon B 2 days ago
  • 7Or use a mono one with different resistors… – Chris Stratton yesterday
  • 2I had considered that but that means a load of ADC work. This solution is purely digital. – Transistor yesterday
  • 2Finding enough ADC inputs for one side of a matrix isn’t hard, and they don’t have to be good ADCs, just able to distinguish 0/1K/10K/100K… capacitor RC time constant could work. – Chris Stratton yesterday 
  • 4While this is a great idea, note that the plug will intermittently short out various combinations of contacts during insertion and removal, so there needs to be a mechanism to filter this out. With some luck (depending on the internal design of the sockets used), one can perhaps use the tip and sleeve for insertion sensing and only rely on the two rings for the one-of-four identification. – TooTea 21 hours ago

add a comment  |  show 8 more comments18

Use a two-contact plug like a 3.5mm mono TR (tip-ring), or a 6.5mm if you have the space and prefer a slightly easier-to-handle peg. Connect different resistor values between the tip and ring in each plug, and set up voltage dividers going through each jack in the pegboard, connected to an MCU’s ADC pin through multiplexers.

With, for example, fixed 10K resistors in the dividers, and 0 ohm, 5.1K ohm, 15K ohm, and 91K ohm options in the plugs, you’d get roughly 0.0, 0.3, 0.6, or 0.9 of the reference voltage at the ADC pin, which should be easy for the MCU to distinguish.

This doesn’t require any particular orientation of the plug, unlike mechanical and optical solutions. You can use off-the-shelf plugs and jacks. On the down side, it takes a fair amount of force to insert and extract the plugs.

The biggest challenge is designing the multiplexing circuit to allow all the jacks to be scanned from a single controller.

grahamj42 suggests:

How about using 1-4 diodes in series in the plugs and detecting the voltage drop? You could then do away with diodes in the matrix.

This would work also. With a 3.3V ref ADC, and diodes with 0.7V drop, you’d see 2.6, 1.9, 1.2, and 0.5V, with each step being nearly 20% of full-scale. There would be more total parts even including the savings in the matrix, though: 300 diodes instead of 150 resistors + 120 diodes (assuming 120 holes in the board.)shareedit  follow  flagedited 19 hours agoanswered yesterdayRussell Borogove87711 gold badge66 silver badges1515 bronze badges

  • 1Indeed. And use the bigger old 1/4 inch plugs for durability and ease of wiring. Of all the ideas floated, I think this one is the most readily made practical in the sense that it can be designed and proven on a small scale and then it’s just a matter of buying more parts and wiring up the big board. – Chris Stratton yesterday 
  • 2The muxing isn’t really complicated, many MCU’s have enough distinct ADC inputs to read all of the column lines, and you just (slowly) drive the row lines one at a time. Just as with a keyboard, each cell/socket needs a diode. – Chris Stratton yesterday
  • 1I vaguely seem to remember that one of the UK electronics magazines from the mid-to-late 70s had a project involving different-valued resistors inside 3.5mm plugs. – TripeHound yesterday
  • 2How about using 1-4 diodes in series in the plugs and detecting the voltage drop? You could then do away with diodes in the matrix. – grahamj42 19 hours ago
  • 1I’d much rather have some diodes on the main board of my project than try to cram multiple diodes into the shell of a jack plug (even a 1/4 inch one) – Peter Green 18 hours ago

add a comment12

I expect the cheapest option is to point mobile phone you already own at the board and use coloured pegs along with writing some image processing software.

And as the phone is a “sensor”, I think this solution keeps to the spec.shareedit  follow  flag answered yesterdayIan Ringrose33011 silver badge99 bronze badgesadd a comment5

Make the 4 kinds of pegs out of different colors of clear plastic, say red, green, blue, and yellow.

At the bottom of each hole, mount a white LED that shines through the peg (or empty space) and frost the other side so that the light diffuses through the case.

Sprinkle a few red, green, and blue sensors around inside the case.

Have an arduino rapidly light each hole in turn using row/column addressing, and use an A/D on the sensors to determine what color of peg the light is shining through.

This way, the only thing you have to do 120 times is cut a rod to make a peg, and the soldering is not so bad using row/column addressing. Just make sure you put the resistors on the row or column lines so you don’t need a separate one per LED.

You may need a demultiplexer if you don’t have enough individual pins for the rows and columns.shareedit  follow  flag answered yesterdayMatt Timmermans58222 silver badges55 bronze badgesadd a comment4

One suggestion is the following, using the smart pegboard below as an example illustration:

smart pegboard

(1) “Load” the 4 types of peg with different weights, eg, Type 1 peg = 10 grams, Type 2 = 20 grams,

(2) Buy 102 cheapy weight sensors (US$5 for 5 pieces, see Appendix A below for more details),

pressure sensor

(3) Put each sensor at the bottom of the hole, and connect it with a fixed value resistor to form a voltage divider.

(4) Now when a peg is inserted, the weight changes resistance of the weight sensor and therefore the voltage of the voltage divider,

(5) Arduino ADC pins can be used to measure the voltage and therefore know which type of peg is inserted.

(6) To determine the position of the peg, there are many method, as briefly described below:

(6.1) Matrix keypad with keys pressed or released

The common method is to use 12 x 12 GPIO pins wired as a matrix. As soon as a key is pressed, Arduino will be notified. Arduino will “scan” the keys row by row, and if the row with a key pressed, Arduino will then scan the keys.

(6.2) Matrix keypad with keys pressed with different pressure levels

The approach is similar to the digital on/off keypad above. But now the Arduino uses its ADC (Analog to Digital Conversion) pins to measure the pressure level of the keys.

(7) Combinations of matrix keypad and multiplexed ADC devices

Since Arduino or Raspberry do not have enough GPIO/ADC pins to go around, we can use 16 channel GPIO expanders. Two MCP23017 can make a 16 x 16 matrix and so can scan up to 256 keys.

Arduino’s ADC pin is only 8 bit resolution. If using 10/12/16/24 bit resolution ADCs (evan a 10 bit ADC can detect 2^10 = 1024 values or 0.1%), it is easy to differentiate among pegs with as little as less than 1 gram difference. So if 120 pegs have unique weights differ by small quantity not noticeable by humans, Arduino can actually tell which one of the 120 holes/pegs is inserted (but of course in this case it is which hole, not which peg we need to know.

(8) Combination of ADC and Analog multiplexors.

Popular but cheap 10/12/16 bit ADCs such as MCP3008, MCP3208, ADS1115 has 8 channels. There are also unidirectional/bidirectional analog multiplexors to make the matrix wiring much simplified


References

(1) High Accuracy Resistive Weighing/Pressure Sensor – US$3.15 (5 pieces)

(2) A Futuristic Pegboard, Turns Boring Rehab Into a Game – Rapael,2018jan17

(3) Smart Pegboard Video – Rapael,2018jan17

(4) A peg board with 24 colorful cylinder pegs and removable inner pegs helps children with perceptual motor development and finger dexterity.

(5) Haljia 5Pcs BX120-3AA High Precision Resistance Strain Gage Strain Gauge GAGE Full Bridge Used for Pressure Weighing Sensor

(6) Adafruit TCS34725 RGB Sensor Demo – 2018mar25

(7) Adafruit Color Sensors

(8) AliExpress Hall Effect IC and Module Catalog (A3144E, SS49E etc)

(9) AliExpress Tiny Magnets Catalog

(10) SS49e Magnetoresistive Linear Hall Effect Sensor Datasheet – Honeywell

(11) Allegro A3144 Datasheet

(12) TCS230 TCS3200 Color recognition module Color sensor module – US$4.6


Appendices

Appendix A – Pressor Sensor Spec

HALJIA 5Pcs BX120-3AA High Precision Resistance Strain Gage Strain Gauge GAGE Full Bridge Used for Pressure Weighing Sensor

pressure sensor

Price: £6.99 (£1.40 / Item)

Made of constantan foil, fully enclosed structure.

Temperature self-compensation and creep self-compensation can be realized simultaneously.

The strain gauge is attached to the measured object to make it expand with the strain of the measured object, so that the metal foil inside the strain gauge can extend or shorten with the strain.

The resistance of many metals changes when they are mechanically elongated or shortened. The strain gauge is used to measure the strain by measuring the change of resistance.

In general, the sensitive grid of strain gauge is made of copper-chromium alloy, whose resistance variation rate is constant and proportional to strain.

Specifications for this item Brand Name HALJIA Item Weight 5.00 grams

Feature:

Made of constantan foil, fully enclosed structure.

Temperature self-compensation and creep self-compensation can be realized simultaneously.

The strain gauge is attached to the measured object to make it expand with the strain of the measured object, so that the metal foil inside the strain gauge can extend or shorten with the strain.

The resistance of many metals changes when they are mechanically elongated or shortened. The strain gauge is used to measure the strain by measuring the change of resistance. In general, the sensitive grid of strain gauge is made of copper-chromium alloy, whose resistance variation rate is constant and proportional to strain.

Resistance Value(Ω): 1002Ω ± 0.1

Sensitivity Coefficient: 2.0±1%

Base Dimension: 7.3mm x 4mm x 1mm

Wire Grid Dimension: 3*3.1mm

Room Temperature Strain Limit: 20000um/m

Room Temperature Insulation Resistance: 10000MΩ

Backing Material: Modified Phenolic


Appendix B – Hall Effect Sensors and Tiny Magnets Specification

(1) AliExpress Hall Effect IC and Module Catalog (A3144E, SS49E etc)

(2) AliExpress Tiny Magnets Catalog

a3144 1
ss49e

shareeditdeleteflagedited 8 mins agoanswered yesterdaytlfong0195844 silver badges77 bronze badges

  • 2+1 for the thoroughly well documented answer, and for talking about those cheap weight sensors that I didn’t know but now I’m going to order a batch just to play with. I’m afraid that the proposed solution needs a board in horizontal position, I don’t know if OP wants to fix the board in the wall. – mguima 16 hours ago 
  • Well, when I read the OP’s question, I noticed that he uses the word “bottom”. In my mother tongue, “bottom” usually, but not always, is relative to the top. So my instinct was that the peg must be in up right position. I did notice that every one else is assuming the pegboard is sort of hanging a wall. Actually I have never met this word “pegboard“ in my life. I vaguely remember I once read about using a hammer to hit a wooden peg into the ground, when setting up a tent in a country side. I did have a couple of other suggestions, but / to continue, … – tlfong01 6 hours ago   
  • those need to know more than Ohm’s Law and voltage divider, and the sensors are a little bit more expensive, about US$4 each peg. I hesitate to suggest that which can use peg boards fixed in any orientation, horizontal or vertical, top down or bottom up (yes, pegs won’t fall down), actually even floating in the air, like inside a spaceship where everything dead or alive, is floating in the air. But because I usually try it out first before telling it. Anyway, I think I first experiment and then report back. Stay tuned, … Cheers. – tlfong01 6 hours ago   
  • 1@tlfong01, I clarified the project in the question, but you were spot on with your assumptions. Thank you very much for taking the time to research and answer this! – Celos 5 hours ago
  • @Celos. Thank you for your clarification. So it is sort of a board game, and the peg board is placed one table. Perhaps you might also like to let us know if you have any preferred requirements on the pegs, say (made of wood, or paper can also do, not more than 5cm tall, and hole not more than 4cm deep etc. Of course we don’t allow any wireless electronic stuff hidden inside the peg. Earlier I suggest to load the pegs with weights. My other suggestions uses tiny magnets, one tiny magnet insert in green peg, two stacked up magnets for blue magnet, and so on, – tlfong01 4 hours ago    
  • I will give some more details in an appendix at the end of my answer. Cheers. – tlfong01 4 hours ago   
  • @mguima, I have updated my appendices with characteristics summary of two Hall effect sensors. Only Honeywell SS49E is LINEAR Hall effect sensors. It would be nice if the OP can finalize his board design, with peg size etc, then we can see which tiny magnets we can use to fit his peg. For Hall effect sensors, I would recommend Honeywell SS49E chip or module. We can also try colour sensors (Ref 12), but they are a bit expensive. Cheers. – tlfong01 3 mins ago    Edit   

add a comment3

There are a total of 120 pegs, 30 of each type

That means there are four different peg designs so think of them like a key that goes in a lock and design the 4 different pegs to have 4 different physical profiles just like a door key but simpler.

You might use transparent coloured pegs and use light to determine the peg’s colour. So each hole would need a white LED emitter and an RGB photodiode circuit. Or you might decide to make the peg grooved; one groove is the fattest and is used to force the user to place the peg in the correct orientation (the reference angle). It would have another groove that could push on a microswitch. This second groove’s position would be different for each peg design.

Or you could have notches arranged as a two-bit number (representing 4 values) and use light detectors to read the 2-bit binary value of the peg.

Just a few thoughts.shareedit  follow  flag answered 2 days agoAndy aka304k1717 gold badges236236 silver badges536536 bronze badgesadd a comment3

It would take some serious engineering, but I bet you could do some sort of matrix scheme where each of the X and Y wires had a few turns coil wound around each peg socket, and the pegs had a core made of ferrite of different permitivity.

It wouldn’t be too hard with a dedicated circuit per hole, the challenge would be making it work as a matrix. Possibly you could do something with a distinct circuit for the AC inductance measurement capacitor coupled to each cell, and then have the matrix drive diode switches to cut off all but one cell at a time?

Or build effectively magnetic core memory, but make the pegs be of different coercivity and test to see how hard you have to drive them to get them to flip.

That said, while the idea of avoiding a dependence on electrical contact is quite enticing, getting one of these schemes to work at all is going to be a lot more effort than a phone plug type solution which could be soundly proven in an hour or two and then scaled up. This would be more like a “new improved version 2.0” to be pursued only in the shadow of a “safe” contact design.shareedit  follow  flagedited yesterdayanswered yesterdayChris Stratton28.7k33 gold badges3333 silver badges7979 bronze badgesadd a comment


Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.