Linear Actuator Positioning

Hey guys! I'm a total newbie to this area of programming, so bear with me here while I ask some very basic questions. I want my actuator to begin the program at the lowest setting, then go up in increments. However, when I try out some code written for a hobby servo that is supposed to do the same thing (apparently), my actuator just randomly moves and doesn't even reach its lowest setting! What should I modify to make this work? Thanks so much!

Here is my code -

#include <Servo.h>  // servo library

Servo servo1;  // servo control object


void setup()
{

  servo1.attach(9);
}


void loop()
{
  int position;

  // Change position at full speed:

  servo1.write(0);    // Tell servo to go to 0 degrees

  delay(1000);         // Pause to get it time to move

  servo1.write(180);   // Tell servo to go to 180 degrees

  delay(1000);         // Pause to get it time to move

  servo1.write(90);     // Tell servo to go to 90 degrees

  delay(1000);         // Pause to get it time to move
  
  // Change position at a slower speed:

  for(position = 0; position < 180; position += 2)
  {
    servo1.write(position);  // Move to next position
    delay(20);               // Short pause to allow it to move
  }

  // Tell servo to go to 0 degrees, stepping by one degree

  for(position = 180; position >= 0; position -= 1)
  {                                
    servo1.write(position);  // Move to next position
    delay(20);               // Short pause to allow it to move
  }
}

You should provide details of the actuator, firstly. Maybe it's not one that works like a servo? Some are, not all.

Also show how it's all connected. Do you have enough current available to the actuator from its own supply? Random servo behaviour is often power related.

Thank you so much for the reply! I am using a 100 mm Firgelli mini linear actuator with a RobotGeek sensor shield. I do have the power intake set to VIN, so it should be drawing as much power as it need from my computer, although I'm not sure if that may be the case!

And are you sure your Firgelli is the servo-like version? If my memory serves (but may be wrong) they are the -R versions.

You'll smoke your Arduino that way.

I didn't know that! Thanks so much for telling me!

And are you sure your Firgelli is the servo-like version? If my memory serves (but may be wrong) they are the -R versions.

From what I know, the actual Firgelli actuators are -R versions, bu the mini actuators do work like servos.

HelloCA:
From what I know, the actual Firgelli actuators are -R versions, bu the mini actuators do work like servos.

Ok.

Does the shield you're using have a jumper or switch or something to choose how to power the servos?

It switches between 5V and VIN.

That doesn't make a whole lot of sense to me: Vin afaik is just a straight-through of the input which can be up to 12V.

To me it makes more sense to have a sort of Vext where you can supply power to the board and thus the servos from an independent supply.

What I would do is, take the board out. Connect the servo control wire to whatever pin on the Arduino, and provide external power to the servo power wires. Link the -ve of the servo/power to the Arduino ground.

Firgelli makes many different actuators, each one has a different part number that distinguishes it from all the others.
What is the part number on YOURS?

My product code is the L12-S.

HelloCA:
My product code is the L12-S.

There's your answer then. As I said yesterday, the -R versions are the servo ones. Your -S is a reversible DC motor with limit switches.

manor_royal:
There's your answer then. As I said yesterday, the -R versions are the servo ones. Your -S is a reversible DC motor with limit switches.

Ah, that would explain my confusion! Everything I saw on the mini actuators said that these were just like servos. What would I do differently to code these? Thanks so much!

HelloCA:
What would I do differently to code these?

It's totally different to code, and needs you to have an h-bridge in order to reverse direction. So the first thing you need to do, I'd say, is procure a driver chip/board/shield. Have a look here for instance, where there's a range to suit different voltage and current combos.

Then have a search for how to wire limit switches.

The logic would be something along the lines of move "out" if you press button "A" but stop if it hits the outer limit switch. Then move "in" if you press button "B" (or "A" again maybe?) and stop when it hits the inner limit switch.

I will definitely look into those! I only need my actuator to go in one direction, though, and only retract if it hits a predetermined limit (basically like an automated syringe). Would I still need the h bridges, or would I be able to work without them?

Thanks so much for all your help, by the way! I was extremely confused before this and you have helped me out a lot :slight_smile:

Surely retraction is the second direction?

You have to reverse the motor polarity, and the only way to do that is with an h-bridge (afaik, anyway).

Hey everybody,

Just a quick note to clear up a couple of things. I'm with Actuonix Motion Devices, FORMERLY Firgelli Technologies. We rebranded in July of last year and you will no longer find us associated with the name Firgelli. No change in ownership, we made this change to differentiate ourselves from Firgelli Automations, an entirely different company.

That said, HelloCa is correct that our R series linear servos are compatible with arduino, not the S.

  • Mike

actuonix:
That said, HelloCa is correct that our R series linear servos are compatible with arduino, not the S.

Surely not strictly true to say the -S is not compatible, although not plug and play like a -R which is just a servo and can be handled by the standard servo library.

It would be easy to hook up a -S: needs an h-bridge to do the polarity reversal, and obviously need to read the limit switches, but it is compatible, just with a bit more work.

You are correct, I should have been more clear. In the past, there has been little value in using an S series actuator with Arduino, as we offered all of our devices in an R series which is much simpler to use. In the last 18 months we've released the P16 rod and T16 track actuators, both of which are not offered as an R, thus using them would require an H-bridge as you indicated.

Thank you for the clarification.