How many pez are in my big pez dispenser?

Thread Starter

jpnine

Joined Mar 8, 2021
10
Here's my goal: I need to know where a spring's end is at any point of it's compression.

So perhaps the drawing may help to visualize what I mean. I need to know where the top of the spring is at any given moment and I need to relay that information to my Arduino Nano so I can output information on a 2 bit 7 segment display. I'm looking for general ideas on how to detect which X it would be at in the drawing (there are actually 30 fixed positions to consider), and I'd like some feedback on the ideas I have now. The room to work in that's available is my main struggle I'm running into, so ideas that are spatially aware are what I'm needing most.

This brought me to my first idea. Since a spring's force can be shown via F = -kx, the position x would be able to be found as long as I had the k constant. To sense the force I could use something like a thin film force sensor and place it in a spot so it gets compressed by the spring to give me a reading. My main concern with this is that the spring will lose it's k constant over time and the force will change. The spring is constantly being compressed and decompressed, so having to update code would be a hassle. Plus, there is roughly 17mm x 30mm of space that I have to work with at the base of the spring and I haven't found a force sensor that small that would be able to handle around 15kg of force.

The alternative I thought of was having some sort of sensor along the X positions. This would likely look like a strip pressure sensor / strip potentiometer. This sounds like a better idea to me, but my spacing is even worse in this predicament. It would need to go the length of the spring (17mm w/ +- 0.5mm of tolerance). Then it also would need to fit in the gap between the spring's top cap and the wall where the X positions are, and that's roughly a thickness of 1.25mm or less. It could be a width of roughly 12.5mm. So it's really tightly packed in and I haven't found any strips with dimensions that fit which makes this idea harder to implement.

Any other ideas or good direction? Maybe you know of the part I need? Might be helpful to know I've have very few projects, so explaining in simple language or links to good explanations would be helpful


1615247249470.png
 

AlbertHall

Joined Jun 4, 2014
12,345
if you could attach a magnet to the top of the spring you could fix reed switches down the outside to detect the position of the magnet.
 

Ya’akov

Joined Jan 27, 2019
9,072
It might be easier to count the number dispensed in a relative way, that is, count each Pez that is delivered, rather than trying to work out a mechanism for absolute measurement.

If you need to do the absolute measurement, I would be inclined to use something resistive—like a potentiometer—or capacitive, like a ladder of parallel caps that is progressively shorted by a wiper. The resistive method could use a literal potentiometer somehow linked to the motion (this seems difficult) or with a resistive strip and wiper which will cause much less friction.
 

LesJones

Joined Jan 8, 2017
4,174
As you are only using a 2 digit display there only be 100 positions, (0 to 99) so it should not be too difficult to make a linear grey code encoder. It would require 7 tracks. (I made an 8 track rotary one many years ago by drawing out the grey code pattern on a large scale and photographically reducing it to the final size.)

Les.
 
Last edited:

Thread Starter

jpnine

Joined Mar 8, 2021
10
if you could attach a magnet to the top of the spring you could fix reed switches down the outside to detect the position of the magnet.
I originally did think of this too, but I decided I wanted to keep the external aesthetics mostly the same with just the display showing with the pez count.
 

Thread Starter

jpnine

Joined Mar 8, 2021
10
It might be easier to count the number dispensed in a relative way, that is, count each Pez that is delivered, rather than trying to work out a mechanism for absolute measurement.

If you need to do the absolute measurement, I would be inclined to use something resistive—like a potentiometer—or capacitive, like a ladder of parallel caps that is progressively shorted by a wiper. The resistive method could use a literal potentiometer somehow linked to the motion (this seems difficult) or with a resistive strip and wiper which will cause much less friction.
I think the absolute measurement is what I would end up going for. If I start with 18 Pez, eat 5, and then put 2 back in I'd like it to constantly give me the number of Pez in the dispenser, not just what's been taken out. Makes the project more difficult, but that's fine. Could use some practice. I've been looking into the strips that you mentioned, and haven't found anything that fits the dimensions I'm looking at. Might end up trying to build a potentiometer with thick film chip resistors. They would be small enough to space out one per each Pez, and I found a simple build that solves for a resistor's value that I could combine with my potentiometer to solve where the spring's position is at. Hardest part will likely be making the potentiometer
 

Thread Starter

jpnine

Joined Mar 8, 2021
10
As you are only using a 2 digit display there only be 100 positions, (0 to 99) so it should not be too difficult to make a linear grey code encoder. It would require 7 tracks. (I made an 8 track rotary one many years ago by drawing out the grey code pattern on a large scale and photographically reducing it to the final size.)

Les.
From what I was able to find, there wasn't anything that fits the length I need. But I also could be looking at the wrong thing since I've never heard of a linear grey code encoder
 

Jon Hoover

Joined Oct 10, 2019
34
You still may want to look into using a force transducer but you would have to come up with a procedure for periodic recalibration. It seems like the most non-intrusive way to sense how many PEZ you have left. I'm just wondering how many times your spring will be compressed and expanded before it's force changes enough to need recalibration. It might be 50 times, it might be 50,000 times.....
 
Last edited:

Ya’akov

Joined Jan 27, 2019
9,072
I think the absolute measurement is what I would end up going for. If I start with 18 Pez, eat 5, and then put 2 back in I'd like it to constantly give me the number of Pez in the dispenser, not just what's been taken out. Makes the project more difficult, but that's fine. Could use some practice. I've been looking into the strips that you mentioned, and haven't found anything that fits the dimensions I'm looking at. Might end up trying to build a potentiometer with thick film chip resistors. They would be small enough to space out one per each Pez, and I found a simple build that solves for a resistor's value that I could combine with my potentiometer to solve where the spring's position is at. Hardest part will likely be making the potentiometer
By absolute, I meant discrete count. Even with the method I suggested putting them back would reset the count. The mechanics might be a little difficult, but it should work.
 

Thread Starter

jpnine

Joined Mar 8, 2021
10
You still may want to look into using a force transducer but you would have to come up with a procedure for periodic recalibration. It seems like the most non-intrusive way to sense how many PEZ you have left. I'm just wondering how many times your spring will be compressed and expanded before it's force changes enough to need recalibration. It might be 50 times, it might be 50,000 times.....
I suppose I could have a reset system. Maybe something that reads the force when the the dispenser is full and when it's empty, and it could divide the difference to find the positions since spring force is a linear function. I'd mainly be hesitant because I'm also trying to keep this consistent and durable in case I gave this as a gift. Not everyone would know how to or be willing to recalibrate their Pez dispenser counter. Really been learning that cooler and more user friendly means more initial work.
 

LesJones

Joined Jan 8, 2017
4,174
I have no idea what a pez dispenser is so this suggestion is probably no use. I was thinking about a helipot (This is a multi turn potentiometer.) with a thread wrapped round the shaft (Or a drum on the shaft.) You would also need a torsion spring on the shaft to provide tension on the thread. As the thread was pulled off the shaft it would rotate the shaft.

Les.
 

Thread Starter

jpnine

Joined Mar 8, 2021
10
I have no idea what a pez dispenser is so this suggestion is probably no use. I was thinking about a helipot (This is a multi turn potentiometer.) with a thread wrapped round the shaft (Or a drum on the shaft.) You would also need a torsion spring on the shaft to provide tension on the thread. As the thread was pulled off the shaft it would rotate the shaft.

Les.
The suggestion was fitting! I also considered something just like you described. The issue I would run into though is when the spring gets completely compressed, there wouldn't be much room to have any components. Spacing is my biggest fight in this project, so I came here to see if there could be some small and seemingly magical component that would further my quest.
 

Jon Hoover

Joined Oct 10, 2019
34
Or, go really low tech and just use a clear tube for the PEZ and put black lines on it every 5 PEZ and let the user do a little counting.... LOL! But, where's the challenge in that?
 

Reloadron

Joined Jan 15, 2015
7,501
While I have fond memories of pez dispensers I can't tell you the travel of full to empty. Obviously as we load we compress the spring. If I wanted to just look at travel full to empty I would likely use a simple linear potentiometer as a position sensor. Similar to these but you don't need something that expensive. A Google of "linear potentiometer Arduino" will give you some ideas.

Be it a linear pot or load cell the big obstacle, I see, is how you mount it on the dispenser. :)

As to spring force. A decent spring can remain compressed for decades and not lose any of its force. I have plenty of rifle and pistol magazines which have had springs under compression for years and nothing changes. The problem is going to be again in the mounting. You want to mount a tiny button load cell (compression type).



Ron
 
Last edited:

djsfantasi

Joined Apr 11, 2010
9,156
Just blue skying... No guarantee that a workable idea is contained herein.

Make a flexible PCB with paired pads at equidistant (one Pez height) locations. Have each level connected to the next with an SMT resistor in the corner.

Modify the dispenser so the platform clears the flexible PCB. create small depressions into which the SMT resisters nestle. Also, add a metal-clad edge to the platform to complete a circuit at each level.

The rest is left to solve as an exercise.
 
Top