Pages: [1]   Go Down
Author Topic: Read servo position (not called)  (Read 2131 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi I'm new and I don't know lots of things so I have a problem smiley-confuse.

I am building a measuring tool with arduino some sensors and servos.
I want to make a servo move until a sensor detects something and then stop and measure the angle of the servo.
The  different read() read the last value called, how can I read the current angle of the servo?

Thanks for your help in advance.
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your code is setting the position of the servo, so you know what the angle is.
Logged

Illinois, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 124
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There is a lot of variability from one servo to another, so the same command will not result in the same position. If this is within you tolerance for error, then that is all you need.

If you need more accuracy:

You can calibrate your servo. In general, they will be repeatable and linear, until they start to wear out. In other words, If you record the command to move to the zero position and the command to move to 90 degrees, you can assume that the positions in between will be linear with the command (i.e. 50% of the way between 0 command and 90 command will be 45 degrees).

You can add a position sensor to the servo. A variable resistor or encoder would be easy to interface and relatively inexpensive.

Depending on the encoder you may get the absolute position in multiple digital inputs or you may get X pulses per revolution.

You can add switches at certain points in the servo travel and use them to calibrate the position. The sketch will record the command when the first switch opens and the command when the second switch closes and use linear interpolation to calculate the command / position in between.

Steve
Logged

Offline Offline
Sr. Member
****
Karma: 6
Posts: 429
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Read the internal Pot.

Logged

Pages: [1]   Go Up
Jump to: