Don't like ads? Help support the Mercs by becoming a Supporter or Auxiliary Member today!
Official Members also get to use the forum ad-free - so kit up and join us!

 Linear Actuator

  • 6 Replies
  • 902 Views

Kurz


    *
  • *
  • 425
Linear Actuator
« on: Dec 07, 2019, 04:52 AM »
Ok guys, I need your help. I need linear motion and not a big fan of adapting a regular servo. Looking around I found this little guy.
Now, I would like to control it with an arduino nano, has anyone any idea on how this thing work? It has 3 pins so I suppose positive, ground and signal like every servo, but I don't know how to write the code for this one. Any help?

Logged
Cabur Akaata (Protector Battalion) #133
Oribru Akaata (Emergency Battalion) #31
M.V.S. #89
L.O.B. #66

LightningLion


    *
  • 154
  • Electronics are my thing
Re: Linear Actuator
« Reply #1 on: Dec 07, 2019, 10:56 AM »
Reverse searching your image shows that white wire is for signal, yes.

Arduino Servo reference:
https://www.arduino.cc/en/Reference/Servo

Linear actuator project:
http://learn.robotgeek.com/demo-code/118-arduino-linear-actuator-tutorial-analog-direct-control-of-small-linear-actuator.html

Been a few years since I last played with servos amd I'm feeling particularly dense today but...

See the attach() reference in the first link. Servo library has a default minimum and maximum values related to 0 and 180 degrees for a rotary servo. By trial and error, using WriteMicroseconds you might define the new min and max values your lineal servo actually uses (min 1050 and max 2000 in the example)

Then you could map your desired position (0 to 20mm) with you min and max (microseconds values) as the linear example does.

Code: [Select]
//Includes
#include <Servo.h>

#define minServo 1050 //adjust to actual values
#define maxServo 2000 //adjust to actual values

int ServoPos;
int servoPin = 9; //Or whatever it is
int desiredPosition;
Servo MyServo;

void setup() {

MyServo.attach(servoPin, minServo, maxServo);

}

void loop(){

if (desiredPosition <20) {
desiredPosition++;
} else {
desiredPosition = 0;
}

servoPos = map(desiredPostion, minPos, maxPos, minServo, maxServo)

MyServo.WriteMicroseconds(servoPos)

delay(250);
}

This code should advande your servo 1mm every 250 ms until reaching 20mm, then go back to the start and repeat. You can easily write a sequence or control it with a potentiometer/slider.

« Last Edit: Dec 07, 2019, 11:30 AM by LightningLion » Logged

Kurz


    *
  • *
  • 425
Re: Linear Actuator
« Reply #2 on: Dec 07, 2019, 12:38 PM »
Thank you so much! I have pretty simple needs, my code will be
Push button ->max extension
Push button -> min extension
I dont think will have trouble adapting the code you kindly shared. Thank you again

Logged
Cabur Akaata (Protector Battalion) #133
Oribru Akaata (Emergency Battalion) #31
M.V.S. #89
L.O.B. #66

LightningLion


    *
  • 154
  • Electronics are my thing
Re: Linear Actuator
« Reply #3 on: Dec 07, 2019, 04:56 PM »
Np. Like I said that's from the top of my head, withojt testing. Send me a PM if you find any issue.

Logged

Kurz


    *
  • *
  • 425
Re: Linear Actuator
« Reply #4 on: Dec 09, 2019, 07:24 AM »
Thanks Lion! Little guy came in today, didn't expect it was THAT little, even though mesirements were written. Shouldn't be a problem.

Logged
Cabur Akaata (Protector Battalion) #133
Oribru Akaata (Emergency Battalion) #31
M.V.S. #89
L.O.B. #66

DCX13


    *
  • *
  • *
  • 42
  • Somewhere out in the yondersphere...
Re: Linear Actuator
« Reply #5 on: Dec 15, 2019, 07:11 PM »
The signal wire will be the white one. Pos & Neg power are red & black, respectively.

Logged
"The difficult is what takes a little time; the impossible is what takes a little longer." ~Fridtjof Nansen

Kurz


    *
  • *
  • 425
Re: Linear Actuator
« Reply #6 on: Dec 16, 2019, 02:50 AM »
The signal wire will be the white one. Pos & Neg power are red & black, respectively.
Yep, that was covered, thank you. Still working on the code and waiting for the 3d print to make everything work.

Logged
Cabur Akaata (Protector Battalion) #133
Oribru Akaata (Emergency Battalion) #31
M.V.S. #89
L.O.B. #66
 


Don't like ads? Help support the Mercs by becoming a Supporter or Auxiliary Member today!
Official Members also get to use the forum ad-free - so kit up and join us!




Powered by EzPortal