Actuonix L12-R linear servo

Hello, g'mrng everyone, hope we are all good

Please, I want to use an actuonix L12-R linear servo for a project, since its a servo, its uses the servo library, but, how do I program the stroke in my arduino code

Thanks in Advance
Ceejay. :slight_smile:

Go find the servo sweep tutorial and try it out.
I suspect that you will quickly see how it works. If not, come back here and ask more questions.

The examples in sweep and knob are for rotary Servos, not linear

This is the code for the linear servo, but I don’t understand y they used those linear values

//Includes
#include <Servo.h>

//Defines
#define LINEARACTUATORPIN 9 //Linear Actuator Digital Pin

const int button1Pin = 1; // the number of the pushbutton pin
const int button2Pin = 2; // the number of the pushbutton pin
const int button3Pin = 4; // the number of the pushbutton pin

// variables will change:
int button1State = 0; // variable for reading the pushbutton status
int button2State = 0; // variable for reading the pushbutton status
int button3State = 0; // variable for reading the pushbutton status

Servo LINEARACTUATOR; // create servo objects to control the linear actuator

int linearValue = 1500; //current positional value being sent to the linear actuator.

void setup()
{
//initialize servo/linear actuator objects
LINEARACTUATOR.attach(LINEARACTUATORPIN, 1050, 2000); // attaches/activates the linear actuator as a servo object

// initialize the pushbutton pin as an input:
pinMode(button1Pin, INPUT);
pinMode(button2Pin, INPUT);
pinMode(button3Pin, INPUT);

//use the writeMicroseconds to set the linear actuators to their default positions
LINEARACTUATOR.writeMicroseconds(linearValue);

}

void loop()
{

// if the pushbutton is pressed set the linear value
button1State = digitalRead(button1Pin);
if (button1State == HIGH) {
// set the position value
linearValue = 1300;
}

button2State = digitalRead(button2Pin);
if (button2State == HIGH) {
// set the position value
linearValue = 1500;
}

button3State = digitalRead(button3Pin);
if (button3State == HIGH) {
// set the position value
linearValue = 1700;
}

//use the writeMicroseconds to set the actuator to the new position
LINEARACTUATOR.writeMicroseconds(linearValue);

}

The width to the pulse in the servo signal dictates the requested servo position. 1500 microseconds (us) is the pulse width for center on a servo, 1300 us is towards one end of travel and 1700 us for the other end. So for the linear servo the pulse width is a percent of travel instead of degrees. You can find, experimentally, the range of pulse widths versus percent of travel for your servo.

The only difference between a rotary servo and a linear servo is the type of motion. They both have a motor, gear train, feedback element (potentiometer) and control electronics.

Wow, thanks very much groundFungus, this has been a great help.

One more thing, from the datasheet, I saw the retraction signal is 1.0 ms, while extension is 2.0ms, now, I understand, I’m very grateful, thanks. :slight_smile: :slight_smile:

Something that your example code shows is the optional MIN and MAX values on the attach command to set the range.

 LINEARACTUATOR.attach(LINEARACTUATORPIN, 1050, 2000);      // attaches/activates the linear actuator as a servo object

If you omit those and just attach(pinnumber) then the default range is set to something like 540 and 2400.
I would make sure to use their attach with the defined range unless you know the linear servo can accept a larger range without binding.

Alright brother, thanks a bunch

retraction signal is 1.0 ms, while extension is 2.0ms

Those may be nominal (not calibrated) values. Your mileage may vary. I would confirm them, experimentally, and apply the values as vinceherman suggests.

Alright boss, thanks