Servo controlled with a Pot. Approach 2?

Ive got so far with my Servo control fiddlings, and now have kind of returned to “servo 101, step 1, book 1” :grin:

the “controlling a servo with a potentiometer”
in V1, the position of the Pot, is reflected on the servo.

in V2, i was hoping to use it slightly differently, but its late and my head hurts, so i thought i would throw the question to the floor. :sleeping:

Premise

Assume the servo is in the central position
the Pot is also in the central position.

I want to program it so that turning the Pot to the right, makes the servo turn to the right. However, turn it further to the right, and the servo turns to the right faster! return the Pot to central, and the servo stops where it is.
to get it back central, you have to turn the pot to the left.
Kind of like steering a car?
Hope that makes sense.

Proposal:

I am assuming i’m going to need to play with the { value ++; } code?
but maybe achieve different speeds by multiplying the ++ by the value on the servo?
ie:

map the Pot as -10 to 10, with 0 being central, then move the servo: “if the pot shows a value other than 0, increase the servo position value by the set increase (1?), multiplied by the value taken from the pot”

does that sound like a reasonably plan? Im not really sure how the value++ part of the code works, so im not entirely sure how best to use it…

any comments would be greatly appreciated.

OllyR: I want to program it so that turning the Pot to the right, makes the servo turn to the right. However, turn it further to the right, and the servo turns to the right faster! return the Pot to central, and the servo stops where it is. to get it back central, you have to turn the pot to the left. Kind of like steering a car? Hope that makes sense.

That isn't a standard unmodified servo. It sounds like you want to modify the servo to do continuous rotation. Here is one such article that mentions how to do the modification: http://www.societyofrobots.com/actuators_modifyservo.shtml. You can also buy modified servos from various robot shops. For example, http://www.pololu.com/catalog/product/536.

I believe a modified servo uses 90 to stop, and 0..89 for rotation in one direction, and 91..180 in the other, which sounds like the behaviour you are seeing.

I assume you have a normal servo where you control the position.

You want your pot to control the servo's speed. The simplest way is to process the position of the pot at regular intervals. Each time, you measure the position of the pot, calculate the deflection away from the neutral position, calculate the servo speed associated with that deflection and add a corresponding amount to the servo position.

The relationship between pot position and servo speed doesn't have to be linear - you can arrange for it to have a deadband around the 'at rest' position and you can control how quickly the speed increases as you move away from there.

Actually, I lied. The simplest approach is to replace your standard servo with a continuous rotation servo and then you can get the effect you wanted without changing the sketch at all.

I suppose continuous rotation is the motion i would be looking for, except without the continuous rotation servo.i will have a fiddle with your suggestion peter. Thanks

to get it back central, you have to turn the pot to the left. Kind of like steering a car? Hope that makes sense.

That's not like a car. A car will self centre. Unless it's broken.

Just being pedantic. Carry on.

Jimmy60: That's not like a car.

Good point. In a conventional car, the position of the steering follows the position of the control. Trying to steer a car by controlling the [u]speed[/u] of the steering wheel movement would be a nightmare.

I did it :)

1: created an integer for the position.

2: Its a spring loaded pot, (nicked from an xbox controller). So using the serial monitor i found it idles at a value of around 450. physical slack in the springs etc meant when the pot was released it could sit anywhere 30 units either side of this. so for nice round numbers, i made it so that "if the pot value is greater than 500, steadily increase the position integer, if less than 400, steadily decrease it.

3: write integer to servo

Loop.

Quite chuffed with myself, not least because it only took me half an hour or so (and i still find this game a bit of a struggle)

now im going to fiddle with it so that it can work as an analogue stick, so further push means faster movement. bit unnecessary for my purpose, but might as well just out of interest.

I would paste the code, but my computer is a muppet and doesn't seem to be able to copy or cut from the IDE.

still, thought i would share.