How to make a sensor / potentiometer using a metal / iron ball

Hi there,

For an artistic project, I’m trying to make a sensor, like a potentiometer to get 0-1024 values, using a metal or an iron ball. I’ve made a sketch to explain it (attached jpeg file). On the sketch, it’s a line, but in fact, the ball will have to turn around a circle of 190 cm of circumference (with a stop at both ends).

What I’m looking for is the best way to build it, to get enough resistance in the GND to 5v loop to generate a 0 to 1024 value that can be interpreted by the arduino. It’s like making a sensor with graphite and reading the value true the A0 pin.

I tried with different materials:

  • cutting wire (for resistance); it becomes to hot, but I do have my values, even in 5V with high amperage. And if I’m using low amperage, such as the 5V output of an arduino, it doesn’t work (maybe I did’nt use it well),
  • conductive vinyl; the idea is nice, but I get some weird values (it’s not stable),
  • graphite or bare conductive; could do the job, but it will wear out quickly for an intense use.

Any idea of materials ?

Thank you for your help !

Could you have the ball roll or press against a pressure sensitive linear resistor?

https://www.sparkfun.com/products/9674

Barth: - cutting wire (for resistance); it becomes to hot, but I do have my values, even in 5V with high amperage. And if I'm using low amperage, such as the 5V output of an arduino, it doesn't work (maybe I did'nt use it well),

I'm not sure what you mean by "cutting wire" - do you mean "nichrome wire"?

If so, you are on the right track with that; likely with the 5V output on the Arduino it either was drawing too much current and tripping the regulator, or the signal was too small to be read.

So - you need to find out what the resistance of the length of each wire is; if the resistance is very small, then the regulator would see a virtually dead short (lotsa current), and overload. If the resistance is very high, little current, and no signal.

Hopefully, you find out that it's the latter. If that is the case - then you could use an op-amp (connected to the output of the improvise voltage divider - what you have labeled "A0" right now), and the output of the op-amp connected to A0 of the Arduino. Basically, add some voltage gain to the circuit.

If it is the former case, though - then you're going to need to figure out a way to increase the resistance. One way would be to increase the length of the wire, by wrapping it around a non-conductive part (like a length of nylon plastic or something) - but nichrome wire doesn't really like that (it can be brittle).

Potential alternative option (this will take some investigative research and learning):

Can your "track" consist of two concentric "plates" or flat "rings" - with the ball in between (but not touching the plates)?

If so - then you might have a form of a rudimentary air-gap plate capacitor; such a capacitor could be used to change the output of an oscillator, which could then be fed into a frequency to voltage convertor - and that output (scaled properly) to the Arduino. Heck, it might even work with your setup as is, provided there was a gap between the steel ball and the "rails"...

retrolefty: Could you have the ball roll or press against a pressure sensitive linear resistor?

Hi Retrolefty, Your idea is a good idea; but no, I'm afraid, I can't get enough pressure on the ball to use a sensitive linear resistor...

cr0sh: I'm not sure what you mean by "cutting wire" - do you mean "nichrome wire"?

Hi crOsh ! Thanks for your answer... :-)

Yes, I'm mean "nichrome wire" :-)

cr0sh: If so, you are on the right track with that; likely with the 5V output on the Arduino it either was drawing too much current and tripping the regulator, or the signal was too small to be read.

Good to read you on that point.

cr0sh: So - you need to find out what the resistance of the length of each wire is; if the resistance is very small, then the regulator would see a virtually dead short (lotsa current), and overload. If the resistance is very high, little current, and no signal.

Hum... well, I think it's more overload than a very high resistance. I need to try with a long wire, to be sure. The final length of the wire for the installation is 190 cm. I only tried with a 20 cm wire... Maybe, I need (also) change my nichrome wire to another one, bigger or smaller ? Mine is actually Ni80% dia 0.70.

cr0sh: Potential alternative option (this will take some investigative research and learning):

Can your "track" consist of two concentric "plates" or flat "rings" - with the ball in between (but not touching the plates)?

If so - then you might have a form of a rudimentary air-gap plate capacitor; such a capacitor could be used to change the output of an oscillator, which could then be fed into a frequency to voltage convertor - and that output (scaled properly) to the Arduino. Heck, it might even work with your setup as is, provided there was a gap between the steel ball and the "rails"...

I think it's to complicated for my installation, that need to be simple. Moreover, I think that capacitor will not be a "fast" enough sensor, because the ball can move quickly (it is pushed by the hand).

Barth: I tried with different materials: - cutting wire (for resistance); it becomes to hot, but I do have my values, even in 5V with high amperage. And if I'm using low amperage, such as the 5V output of an arduino, it doesn't work (maybe I did'nt use it well),

Either use thinner wire to get higher resistance, or reduce the voltage on the wire. For example, set the Arduino to use the internal 1.1V voltage reference, use an op amp and a transistor to buffer the output, and drive the wire from that. This will reduce the heating by a factor of about 20.

Barth: - conductive vinyl; the idea is nice, but I get some weird values (it's not stable),

Try that again, with a 0.1uF capacitor connected between the analog input and ground.

Another option would be to wrap the nichrome with a small airgap between turns around a form to put more resistance in the circuit. You can wrap the nichrome simultaneously with some other wire to act as a spacer and then remove the spacer.

Perhaps the better solution would be to utilize an opamp to read the voltage divider at very low current and drive the Arduino with the opamp output?

Hi there !

Hurray ! I've made more tests with the Nichrome wire (not with a thinner), and I think I get lucky, because it works perfectly with the 5v output of the Arduino, if I use a very long wire (about 200 cm); and this is pretty cool cause I need this length for my installation.

Surprisingly, the signal I get with the ball, is very, very, clean and stable... so, it's perfect.

But, if I'm using less than 150 cm of Nichrome wire, the arduino seems to be overload. So, as you all said, I will have to use a thinner wire or / and an opamp to get a clean signal (but this is not the case here as I need a 190 cm rail for the ball, so 190 cm of Nichrome wire)...

Thank you for your help !

Is sounds to me that tour wire is still drawing quite a lot of current from the +5V line. I suggest you reduce it, by reducing the voltage on the wire. if you are not using analog inputs for reading any other voltages, here is a simple way of doing that:

  1. Measure the resistance of the wire with a multimeter.

2, Connect one end of the wire to ground, and the other end to +5V through a resistor. The value of the resistor should be somewhere between the resistance of the wire (this value wood reduce the wire voltage to 2.5V), and four times the resistance of the wire (which would reduce the voltage to 1V). Use a resistor with a high enough power rating - you can work this out when you know the wire resistance, but I am guessing that you will need 0.5W or perhaps even 1W.

  1. Change your sketch to make a call to analogReference(EXTERNAL) in setup(), before ahy calls to analogRead, and upload the new sketch.

  2. Connect the junction of the wire and the resistor to the Aref pin. Optionally, also connect a capacitor (e.g. 0.1uF) between this point and ground.

You will get the same readnigs as you do now, i.e. between 0 and 1023 depending on the position of the ball.

Hi DC42 :-)

Thanks a lot for your answer. But I'm not sure I understood everything.

My wire still using a lot of current, but only when the wire is less than 100 cm. For my work, the wire should have a length of 190 cm. So, this reduces a lot the voltage of the wire. For a 190 cm wire, I got values between 1,5v and 2v; so I do have my values between 0 and 1023, and the signal is clean and stable.

My question is; do I really have to reduce the voltage ? Or, if it works like that, without reducing voltage, can I work "like that" ? Do you think it will change something for the arduino / reading the value ?

By the way, I will use the other analog inputs for reading other voltages; I guess I will need to change all the voltages to have the same analogReference(EXTERNAL) if I'm using your suggestion ? (I never worked with external analog reference).

Thanks again for your help.

Barth: For a 190 cm wire, I got values between 1,5v and 2v; so I do have my values between 0 and 1023, and the signal is clean and stable.

That's a rther narrow voltage range. It suggests that the wires between the Arduino and the ends of the nichrome wire in the track have a lot of resistance. Or are you using the same nicrome wire all the way back to the Arduino?

Barth: My question is; do I really have to reduce the voltage ? Or, if it works like that, without reducing voltage, can I work "like that" ? Do you think it will change something for the arduino / reading the value ?

That depends on how you are powering the Arduino. If you power it with USB power from a PC, then you may well overload the USB port. If you power it form the barrel jack, you will probably overheat the voltage regulator. You should either measure the current going through the nichrome wire, or measure its resistance, so that we can work out the current from that.

Barth: By the way, I will use the other analog inputs for reading other voltages;

That makes it tricky! If the current draw of the nichrome wire is too high to be safely drawn from the power supply, then you have a few options:

  • use thinner wire (which will have more resistance, hence draw less current)
  • use a series resistor and then an op amp to amplify the signal
  • use a series resistor, and use the 1.1V internal reference when reading the position of the ball, and the +5V rail as reference for reading other sensors. I don't recommend this when using USB power, because it will be sensitive to the voltage ratio between the 5V power supply and the 1.1V internal reference, and 5V USB power is not very stable.

Hi dc42,

Thank you for your answer. I'm not on this part of the project right now, and I think I will not have enough time to work on it before 2014. But everything is clear, and I will try what you propose as soon as I can and let you know what solution works the best with the projet :-)

Thanks again !