Spectra symbol SOFTPOT & servo

Hello All,

TO DO:
I want to control 180deg servo motor with linear 50mm Spectra symbol SOFTPOT.

WORKING:
I have used servo knob code, servo motor moves as i move my finger on softpot.

PROBLEM:
When I remove finger from softpot it come to some end.
Motors shakes during working

SO, How can I control & RETAIN positions of servo motors by using softpot? (Change positions with softpot and retain it to perticular position)

Thanks to All.

Sounds like there may be an issue with the softpot gizmo, or it has random output when the finger is removed.

or it has random output when the finger is removed.

That's the one.

When the finger is removed the wiper on the softpot is floating, therefore all the analogue input picks up is noise, hence the jittering.
The simple cure is to add a pull down resistor. About 100K to ground should do it.
This means when you remove your finger you will get a reading of close to zero. You might want to add software that stops the servo from going back to zero at that point.
Note if it is a circular softpot you can short the two ends together if you are not careful where you press.

Thanx Mike,

It almost stop jittering... Helped Alot \m./

But still I am unable to retain the position of servo while i remove the finger from softpot :~

well first of all Is it possible to retain the position while we remove finger from softpot as it's resistance comes to zero ?? :roll_eyes:

My applications is I need to move track with softpot (first i used to adjust it with 10k standard knob pot), Now to adjust the position of track, I want to use softpot (slide finger front to move track to front most position)

Thanks again to all.... :slight_smile:

Can you write your code to "ignore" the pot reading you get when your finger is not on the softpot?

What I'm thinking is something like this pseudo code

if (softPotVal > noFingerVal) {
   // use the value as normal
   // save it in a variable for use elsewhere
  // if the IF test fails the saved value won't change
}

...R

Yes ignoring the readings is a good simple method.
It has the disadvantage of having a range of the pot where even if you are pressing is ignored.

They way round that is to detect when the finger iss off, this is a bit more involved.
Wire the ends of the pot to two digital outputs. Take two readings one with one output high and the other low, and another with these reversed. The two readings should be the complement of each other if a finger is pressing. That is
Reading1 should equal 1023 - Reading 2
It won't exactly be equal there will be a bit of jitter but take cair of that in the code.

Grumpy_Mike:
Yes ignoring the readings is a goo simple method.
It has the disadvantage of having a range of the pot where even if you are pressing is ignored.

This is just a follow up to gain more information ...

I presume you mean "halving" and I don't understand why you say that. I had assumed you would just lose a little bit at one end of the range.

...R

I presume you mean "halving"

No I mean having.
If it reads zero when your finger is off and that is the value you ignore. Then it will also ignore zero when your finger is on and you slid down to the bottom.

I'd try putting a high value resistor from the gizmo wiper to ground. This should control any floating activity on the wiper.

Grumpy_Mike:

I presume you mean "halving"

No I mean having.
If it reads zero when your finger is off and that is the value you ignore. Then it will also ignore zero when your finger is on and you slid down to the bottom.

Thanks, sorry for misunderstanding. What you say about getting zero when you touch that point and when you don't touch anything is what I was assuming. I think I would be happy to waste (say) the bottom 5% of the range in return for the simplicity.

...R

zoomkat:
I'd try putting a high value resistor from the gizmo wiper to ground. This should control any floating activity on the wiper.

How is that different from my reply #2?

Grumpy_Mike:

zoomkat:
I'd try putting a high value resistor from the gizmo wiper to ground. This should control any floating activity on the wiper.

How is that different from my reply #2?

Shorter, more straight to the point.

Hey guys,

To retain the position of motor after removing the finger from soft pot I tried one code mentioned below. But its not working
can anybody suggest any correction in it?

#include <Servo.h>

Servo myservo;

int potpin = 0;
int softPotVal;
int noFingerVal;
int val;

void setup()
{
myservo.attach(9);
}

void loop()
{
softPotVal = analogRead(potpin);

if(softPotVal > noFingerVal) {
val= softPotVal;
val = map(val, 0, 1023, 0, 179);
myservo.write(val);
noFingerVal=softPotVal;

}
delay(15);
}

Thanks to All ........

When this is reached:-

if(softPotVal > noFingerVal) {

The variable noFingerVal has not been given a value. It needs to be initialized before it is used in a comparison.

Which value shall i assign? I tried putting noFingerVal=0 before ......if(softPotVal > noFingerVal) but it isnt working.

It is the noFinger variable that must be set to the value you FET with no finger, what is that is it zero?
Then why do you do this

 noFingerVal=softPotVal

That is just going to ramp up the value you consider it is not pressed and anything lower will be ignored.

Try noFingerVal = 250. And don't change the value anywhere in your code.

If that works try reducing it in steps until you get a satisfactory number.

If it doesn't work, double it and try again. If that doesn't work there is some other problem.

...R

One thing that may also help you is to put a capacitor between the wiper and the ground. It should keep your value. But, they also discharge with time. The rate of discharging can be diminued by taking capacitor with bigger value.