Controlling a linear servo

I am trying to control a firgelli L12-30-50-6-R (30 mm, 50:1 gearing, 6 volts) but im having issue with its position. Im attempting to control it with the arduino servo library but can seem to write the correct values. other servos typically go from 0 to 180 degrees i tried this as i though 0-180 could be the 0-30 mm but mapped differently. writing 0 to the servo made it fully retract but is sounded like it was trying to retract further than its limit. while writing 180 made it extend and again it sounded like it tried to extend it further than its limit. i tried writing a code where it would write 0 then 1 then 2 etc. every 2 seconds the value it was trying to write i had displayed on a screen. when i ran this nothing happened until it got to 22 where it retracted and then nothing happened again until it got to the 40's.

I just need to know what values i should be using to move the servo. i dont need the full motion in my application i need to move over a distance of 17mm ideally it will be fully retraced at 0 and partially extended at 17mm. and I need it to get to the position and stop rather than waiting a second as it tries to move past its limit.

I am waiting on the actual power source to come in, so right now it inst getting a lot of amps. i dont think this is an issue as it does move. when hooked to the right power source it would just move faster or more forcefully. but this is a position problem so i dont thing the lack of amps the issue.

I did contact firgelli but they couldn't help as it is a code issue and they arn't familiar with Arduino code. I was only got wireing instructions and that i can use the servo library.

Matt

A 1.0 ms pulse commands the controller to fully retract the actuator, and a 2.0 ms pulse signals full extension.

You can signal a servo with better resolution and timing accuracy using the servo.writeMicroseconds(time); function. So retract would be servo.writeMicroseconds(1000);

That does work for me but when it gets to full extension or retraction is sounds like it it is trying to push past its limit. is this normal then? i though this might be bad for the servo. tested out myservo.writeMicroseconds(1500); and that extends it 15mm(1/2 of its range) and it doesn't make the noise when it gets there.

will try to use myservo.writeMicroseconds between 1100 and another value to get the 17mm of travel without it making the noise. probably going to set a function so i can call it with a distance in mm and have it mapped to the appropriate time to call in microseconds.

Thanks

Matt

#include <Servo.h>

 
Servo myservo;  
                

void setup() 
{ 
  myservo.attach(12); 
} 

void loop() 
{ 
 
      servo(3);
      
      delay(6000);
      
      servo(20);
      
      delay(6000);
  
}
 void servo(int a)
  { 
    int b;
  b = map(a, 0,30,0,1000) +1000;
  
   myservo.writeMicroseconds(b);
  
 }

This is what i came up with to test it. it seems to have issue with lower numbers. using servo(0) through servo(2) had the same effect trying to move past fully retracted. at servo(3) it would stay retracted but not make those sounds. the code above resulted in 19mm of travel rather than the intended 17mm as far as i can tell due to issues with low numbers of travel.

Matt

b = map(a, 0,30,0,1000) +1000;

b = map(a, 0,30,3,1000) +1000; Change the desired lower bound to 3 and it won't go any lower.

  b = map(a, 0,30,110,1000) +1000;

Good idea. played around with the value and the lowest i got it without it making the noise was 110. so now “a” from 0-17 results in a 17mm movement.

the 0 position is a little different though. when it makes the noise it is 7mm from the collar and when not making the noise (at 110) is is 9mm from the collar. just means i have to make a minor adjustment to where i mount it.

Thanks for the help

Matt