Positional Feedback

I have written a simple code to read the position of a linear actuator. When I run it, i am only getting values between 13 and 33.Should I not receive a reading of 0 and 1023 at the extreme positions? What is wrong?

For reference, i am using a heavy duty linear actuator with a 6" stroke and a built in potentiometer.

I am using an arduino uno and a MegaMoto Plus.

Currently I have the potentiometer wired as:

  • White: GND
  • Yellow: 5V
  • Red:A5, analog in
int EnablePin1 = 13;
int PWMPinA1 = 11;
int PWMPinB1 = 3;
const int PotPin = A5; //Sets the input pin [1] for the potentiometer, Analog pin

int startvar = 0; // variable to be assigned to start program via serial monitor
char rx_byte = 0;
int currentposition=0; 

unsigned long StartTime = millis();


void setup() {
  Serial.begin(9600);
  pinMode(EnablePin1, OUTPUT);//Enable the board
  pinMode(PWMPinA1, OUTPUT);
  pinMode(PWMPinB1, OUTPUT);//Set motor outputs


}//end setup

void loop() {
  if ( Serial.available () > 0) {   //See if input avalible
    rx_byte = Serial.read();        // retrieves input character provided by user

    if ((rx_byte > '0') && (rx_byte < '2'))  {  //Checks if input recieved to start. 1 is required entry
      Serial.println ("Input Recieved, Starting"); // singals program is starting, commence loop


        currentposition = analogRead(PotPin);
        Serial.print("Position Readout (0-1023): ");
        Serial.println(analogRead(PotPin));
        
 
    }//end if
  }//end main loop
}

What's the voltage on the pot wiper as read with a voltmeter, at the extremes? Maybe the pot doesn't move over its whole range?

As a check, use a multimeter to measure the resistance between red (wiper) lead, and the yellow and white leads, for fully extended and retracted.

Let us know what you find.

Nice actuator!

Thanks for the replies!

Using the multi meter, i have the following voltages while retracted:

  • Red lead and yellow lead: 9450 ohms
  • Red lead and white lead:531 ohms

Using the multi meter, i have the following voltages while fully extended:

  • Red lead and yellow lead: 7060 ohms
  • Red lead and white lead:2910 ohms

Thank you, its a pretty big unit!

Then the voltages appearing at the red lead should be 0.26 (retracted) and 1.45 (extended), or about 55 and 297 on analogRead().

Did you connect the grounds?

The analogRead() values you SHOULD be getting:

Retracted:
9450/(9450+531) = 9450/9981 = 0.9468 * 1024 = 970

Extended:
7060/(7060+2910) = 7060/9970 = 0.7081 * 1024 = 725

Since you are getting 13 to 33 something must be wired incorrectly.

OP says YELLOW +5V, WHITE GND, RED wiper, so JR's numbers should be right? :confused:

Yellow = +5V, White=GND, Red=wiper and assuming 10K pot:

5*531/10000 = 0.27V

5*2910/10000 = 1.46V