Pages: [1]   Go Down
Author Topic: Potentiometer Connection and Code  (Read 883 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2855
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 549
Posts: 27419
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Can you disconnect it and measure the pot directly?
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the actuators are Thomson Electrak 1SP. The potentiometer is separate from the power source to the actuators.
Code:
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.
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 549
Posts: 27419
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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
}
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: