I am new to programing and my question may seem basic to you. For a project I need to control a linear actuator to drive an exact position (let say target 1) and wait (delay) and drive again to a new position (target 2) and keeps moving between these two set points for a certain amount of times. I am using an Arduino UNO, LAC board (Firgelli) to control a p-series linear actuator from Actuanix (L12-P Micro Linear Actuator - Stroke: 100 mm- force/speed combinations : 50:1 & 6 vdc). The LAC board (H-bridge circuit) has 4 built-in potentiometer that control the speed, accuracy, retract and extend status of the actuator and it is directly getting the power from a DC power supply. The PWM pin of my Arduino; pin 9, is connected to RC pin (Hobby Servo input signal) of the LAC board.
I modified the servo sweeping code, however I noticed random movement of the actuator. It seems I can't correlates each angle to a certain distance which is a fraction of full stroke.
I don't know how to get position feedback from the board to make command to the Arduino. I appreciate your input.
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards
float x = 0.4;
//float pos; // variable to store the servo position
bool done = false;
float full_length = 100;
float pos = x * full_length;
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
int counter = 0;
void loop() {
if (counter < 2) {
for (pos = 0 ; pos <= x * full_length; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(30); // waits 15ms for the servo to reach the position
}
done = true;
for (pos = x * full_length; pos >= 0; pos -= 1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(30); // waits 15ms for the servo to reach the position
}
done = true;
counter = counter + 1;
}
}