Simply moving a Linear servo

Hello,
sorry for the probably easy question, but it seems that I find answers just to more complex problems.
I need to move forward and backward a linear servo, no position control.
I have:

  • the microcontroller Arduino 1 board
  • a linear servo Actuonix l16 50 150 6R
    https://docs.rs-online.com/54e3/0900766b81682dc0.pdf
  • buttons, wires, and the like.
    Wiring:
    The linear servo goes to a 9v battery, to the breadboard GND and to digital pin 3. The battery GND goes to the breadboard. The breadboard is connected to the Arduino 1 GND and 5V.
    The code
    #include <Servo.h>

Servo s;

void setup() {
s.attach(3);
}
void loop() {
s.writeMicroseconds(2000);
delay(1000);
}

But nothing happens: any help appreciated!

What happens when you run an example from the servo library?

What hardware troubleshooting have you done? For example, are you sure that the 9V battery has enough power to drive the servo, and is fresh? Can you post images of your "buttons, wires, and the like"? Verbal descriptions almost always fail.

yes, that one works if I try it out with the arduino servo

What about this?:

On standard servos a parameter value of 1000 is fully counter-clockwise, 2000 is fully clockwise, and 1500 is in the middle.

Note that some manufactures do not follow this standard very closely so that servos often respond to values between 700 and 2300. Feel free to increase these endpoints until the servo no longer continues to increase its range. Note however that attempting to drive a servo past its endpoints (often indicated by a growling sound) is a high-current state, and should be avoided.

Running servo power through a breadboard is asking for trouble. When the servo demands an amp of current through a bread board, expect the unexpected.

These are near the top of the 9V square battery list:

Posted rated capacity of 500mAh, tested to deliver considerably less.

When you are posting about how you circuit runs fine for some minutes but then starts to do the weird thing and, finally, quits,. Remember someone mentioned that those 9V square batteries, to run a project from, are poo.

michael_nm:
yes, that one works if I try it out with the arduino servo

We don't charge by the word, you are allowed to say enough to make things clear.

Does "that one" means the Sweep example recommended? Or your original code? And does "the arduino servo" mean your linear servo? Or do you mean the micro servo that comes in most Arduino kits?

BTW that specification you linked to says that the -R model runs on 6V. Have you checked that 9V won't kill it?

Steve

Sorry, I attach the photo.
The code that @aarg linked works fine to me when I use the arduino 1 kit rotary servo. The linear actuator that I bought is stated to take Red – Power (+6 VDC), so I suppose that the 9v battery should be fine. The battery is new, although not the best brand.

void setup() {
  s.attach(3);
}
void loop() {
  s.writeMicroseconds(2000);
  delay(1000);
}

Looking at loop function. I got a question for you.

When the servo reaches the position of 2000uS what does that program you wrote in loop() tell the servo to rotate too? So if the servo is at 2000uS and it is told to rotate to 2000uS what will the servo do? Why it will rotate to 2000uS. 2000uS-2000uS= amount of total movement of servo, 0.

If you want to move the servo to different positions, the program should be programmed in a way that causes different torque values to be applied at different times.

Look in your examples in the IDE and find the servo sweep sketch, Run that sketch if you want servos to move.

michael_nm:
The linear actuator that I bought is stated to take Red – Power (+6 VDC), so I suppose that the 9v battery should be fine.

No, it wants 6V, not more. Probably it's pulling enough current from your worthless battery to dip the voltage the actuator actually sees, but if you actually give it 9V from a power supply, you may damage it.

Ok, with the actuator directly attached to the breadboard and the timing set to s.writeMicroseconds(2000), it works! Now I will try to figure out how to pull it back. thank you!

Hello, thanks all. :wink: I solved the linear servo with the following code, which allows it to move forward and backward.
:wink:
#include <Servo.h>
Servo actuator; // create a servo object named "actuator"

void setup() {
// put your setup code here, to run once:
actuator.attach(9); //attach the actuator to a PWM pin in Arduino
actuator.writeMicroseconds(2000); //this ms pulse extract the arm by actuator specifications (1000us = 1ms)
delay(30000); // the actuator takes >>1s to extend/retract when loaded - give it plenty of time
}

void loop() {
// put your main code here, to run repeatedly:
actuator.writeMicroseconds(1000);// 1ms pulse to extend the arm
delay(30000);
actuator.writeMicroseconds(2000); // 2ms pulse to retract the arm
delay(30000);
}