Go Down

Topic: Potentiometer Connection and Code (Read 947 times) previous topic - next topic

Melsimo77

Hello,

I have a linear actuator with a potentiometer within it to give feedback to the position of where the actuator is. the range is from 0-10K ohm (fully extended). There are three wires red white and black. I assume the white is the wire that goes into the analog input and red and black are +5 and gnd accordingly. I tried just reading the analog value and printing it to the serial screen, but it showed up as 0 even when the actuator is moved.

Can anyone help me get the potentiometer values to work?

Thanks in advance.

RuggedCircuits

Quote
There are three wires red white and black. I assume the white is the wire that goes into the analog input and red and black are +5 and gnd accordingly.


That's a good assumption but not necessarily true. Is this a powered device or just a passive pot? If the latter then it's really a question of what the center "wiper" terminal is. Do you have a part number or datasheet we can reference?

Seeing your sketch would be helpful too.

--
The Aussie Shield: breakout all 28 pins to quick-connect terminals

CrossRoads

Can you disconnect it and measure the pot directly?
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Melsimo77

the actuators are Thomson Electrak 1SP. The potentiometer is separate from the power source to the actuators.
Code: [Select]

float Pot;
void setup()
{
Serial.begin(9600);
}

void loop()
{
    Pot = analogRead(0);
    Serial.print("Resistance:   ");
    Serial.print(Pot);
}


And I have been able to read the potentiometer value directly using a multimeter so I know for a fact it works properly.

CrossRoads

Try setting it up like the Reference page example
Analog reads are only 10 bits, use int instead of float, value readings will be 0 to 1023 representing 0 to 5V.

Also: It takes about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second.
So your loop is likely going way too fast.



Example
Code: [Select]

int analogPin = 3;     // potentiometer wiper (middle terminal) connected to analog pin 3
                      // outside leads to ground and +5V
int val = 0;           // variable to store the value read

void setup()
{
 Serial.begin(9600);          //  setup serial
}

void loop()
{
 val = analogRead(analogPin);    // read the input pin
 Serial.println(val);             // debug value
}

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Melsimo77

Thanks for the help, I got it to work!  :) I am getting values 1023 when fully retracted and 400 when fully extended.

Go Up