Go Down

Topic: Positional Feedback  (Read 166 times) previous topic - next topic

kamaj5

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.
https://www.progressiveautomations.com/media/catalog/pdf/Heavy_Duty_Linear_Actuators_PA-17.pdf

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



Code: [Select]
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
}

kenwood120s

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?
[gumby]I've got my head stuck in the cupboard[/gumby]

jremington

#2
Aug 11, 2017, 05:22 pm Last Edit: Aug 11, 2017, 05:22 pm by jremington
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!

kamaj5

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!

jremington

#4
Aug 11, 2017, 07:10 pm Last Edit: Aug 11, 2017, 07:12 pm by jremington
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?

johnwasser

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.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

edgemoron

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

jremington

#7
Aug 12, 2017, 11:29 pm Last Edit: Aug 12, 2017, 11:30 pm by jremington
Yellow = +5V, White=GND, Red=wiper and assuming 10K pot:

5*531/10000 = 0.27V

5*2910/10000 = 1.46V

Go Up