reading data off of pots (using firgelli actuators)

Hi all,
First post, sorry if i waste your time. I'm struggling a bit with understanding how to stop my actuators within certain values. For example, i would like to have my actuator stop going forward after it extends about 1/2 of it's length. The issue i'm having is that it is fully extended, or fully reversed, nothing in between.

I've got two sabertooth 2x5's in simplified serial with slave setup. I've confirmed this works (not confirmed with pots connected). I know my pot voltage is changing as well, with the voltage decreasing as the actuator extends.

I've attached my code below:

#include <SoftwareSerial.h>

/*****************************************************
 * DIP Switches as per the wizard:
 * - NiMh Battery
 * - TTL RS232
 * - Simplified Serial Mode
 * - Two Saberteeth connected
 * - 9600 baudrate
 *
 * Pin 1 - ON
 * Pin 2 - OFF
 * Pin 3 - ON
 * Pin 4 - OFF
 * Pin 5 - ON
 * Pin 6 - OFF
 ****************************************************/

// Labels for use with the Sabertooth 2x5 motor controller

// Digital pin 18 is the serial transmit pin to the 
// Sabertooth 2x5
#define SABER_TX_PIN               18

// NOT USED (but still init'd)
// Digital pin 19 is the serial receive pin from the 
// Sabertooth 2x5
#define SABER_RX_PIN               19

// Set to 9600 through Sabertooth dip switches
#define SABER_BAUDRATE             9600

// Simplified serial Limits for each motor
//64 is soft stop
#define SABER_MOTOR1_FULL_FORWARD  127
#define SABER_MOTOR1_FULL_REVERSE  1
//192 is soft stop
#define SABER_MOTOR2_FULL_FORWARD  255
#define SABER_MOTOR2_FULL_REVERSE  128


// Motor level to send when issuing the full stop command
#define SABER_ALL_STOP             0


SoftwareSerial SaberSerial = SoftwareSerial( SABER_RX_PIN,
                                             SABER_TX_PIN );
                                             
// Setting up the actuator pots, connected to a8-a11:
//analogRead(Actuatorx) reads in the value from the pin. 

int Actuator1 = A8;    // selects the input pins for the actuator potentiometer
int Actuator2 = A9; 
int Actuator3 = A10; 
int Actuator4 = A11; 

// places to store actuator loaction values
int Actuator1Value = 0;
int Actuator2Value = 0;
int Actuator3Value = 0;
int Actuator4Value = 0;
//setting up select pins. 52 in motor controller 1, 53 is motor controller 2

int MC1 = 52;
int MC2 = 53;

   
void initSabertooth( void )
{
  // Init software UART to communicate 
  
  
  
  // with the Sabertooth 2x5
  pinMode( SABER_TX_PIN, OUTPUT );

  SaberSerial.begin( SABER_BAUDRATE );     

  // 2 second time delay for the Sabertooth to init
  delay( 2000 );

  // Send full stop command
    SaberSerial.write(byte(SABER_ALL_STOP));
  
  //setting up pinmodes for select pins
  pinMode(MC1, OUTPUT);
  pinMode(MC2, OUTPUT);
 
  // setting pinmode for analog pins, is this needed?
  //pinMode(Actuator4,INPUT);
  /*pinMode(Actuator2,INPUT);
  pinMode(Actuator3,INPUT);
  pinMode(Actuator4,INPUT);
  
  */
}

void setup( )
{
  initSabertooth( );
}

void loop ( )
{
  // setting a halfway position
  //LOW disables both motor controllers
  //HIGH enables both motor controllers
  // only using one MC right now
    digitalWrite(MC1, LOW);  
    digitalWrite(MC2, HIGH);
 
//Experimenting with act #3
  Actuator3Value = analogRead(Actuator3);
  if (Actuator3Value > 500)
//  {
    SaberSerial.write(byte(SABER_MOTOR1_FULL_FORWARD));
 //  }
   
  
   
}

Thanks for the input.

I think you need to post a link to the actuator, and show a schematic showing how stuff is connected.

Here is the link to the actuator:

This is a schematic on how it is connected to the arduino mega that is attached below.

The entire project is wired as shown below.

Actually, i modified my wiring below, as the simple act of getting the schematic uploaded made me realize i had gnd attached to one of my MC's that wasn't supposed to be. I modified my code below to get it to stop once it reached a certain threshold. Is there a better way/ more efficient way to code this? Apparently i'm prone to miss obvious stuff :slight_smile:

void loop ( )
{
  // setting nuetral position
  //LOW diables both motor controllers
  //HIGH enables both motor controllers
    digitalWrite(MC1, LOW);  
    digitalWrite(MC2, HIGH);
  //setting up nuetral based off of actuator1, will need to expand
  Actuator3Value = analogRead(Actuator3);
  delay(10);
  if (Actuator3Value < 500)
  {
    SaberSerial.write(byte(SABER_MOTOR1_FULL_REVERSE));
    delay(15);
  }
  else
 {
    SaberSerial.write(byte(SABER_ALL_STOP));
    delay(15);
  } 
  
   
}

  Actuator3Value = analogRead(Actuator3);
  delay(10);
  if (Actuator3Value < 500)
  {
    SaberSerial.write(byte(SABER_MOTOR1_FULL_REVERSE));
    delay(15);
  }
  else
 {
    SaberSerial.write(byte(SABER_ALL_STOP));
    delay(15);
  }

Why are you twiddling your thumbs after reading the potentiometer?

Where do you drive the actuator forward? If you are using a variable speed motor controller, sneaking up on the exact position you want is allowed. Full throttle is not the only supported mode.

The delays were thrown in there in an effort to see if i wasn't allowing the motorcontoller enough time to respond. Good catch on that. Full throttle is actually preferred for what i'm trying to implement. This is actually going to be a joint in a robot that will act much like a hip/pelvis, adjusting a metal support plate to certain angles to make the upper body bend. Right now, we only want it to go it's fastest speed.

Thanks for all your help! I see your very active on these forums, offering sound advice. Let me know if you have any other input.

Those delays are eliminating any chance for control. You can let that loop run as fast as possible to minimize overshoot.

How far can your acuator move in 2 delay(15)? They are not needed.

Yep, As Paul pointed out. I had those in there in a desperate attempt to TS something that wasn't even the problem. They have since been removed. Once i get all 4 of my actuators working, i'll post my code in it's entirety for the sake of posterity and others working on stuff like mine.