Show Posts
Pages: [1]
1  Topics / Product Design / Re: Need help getting started. on: September 02, 2012, 08:30:17 pm
I guess you're building some type of robotic cleaner based on your post, but you basically need a micro-controller (arduino) a motor controller (because the payload is 6 pounds you probably need a powerful one (go with a sabertooth motor driver) some type of frame with electric motors. The electric motors should connect to the motor driver and the motor driver should connect to the micro-controller (arduino), then its just tweaking and simple programming from there.
2  Using Arduino / Motors, Mechanics, and Power / Re: Sabertooth motor control - tank styled Please help young engineers! on: September 01, 2012, 01:39:48 pm
thanks
3  Using Arduino / Programming Questions / Re: Sabertooth motor control - tank styled programming on: September 01, 2012, 01:39:09 pm
yeah that would be nice
4  Using Arduino / Programming Questions / Sabertooth motor control - tank styled programming on: August 29, 2012, 06:13:31 pm
instead of keychars for steering i was wondering if someone could place working buttons inputs in their place.

Code:

#include <SoftwareSerial.h>
#define SABER_TX_PIN 13
#define SABER_RX_PIN 12
#define SABER_BAUDRATE 9600
#define SABER_MOTOR1_FULL_FORWARD 127
#define SABER_MOTOR1_FULL_REVERSE 1
#define SABER_MOTOR1_FULL_STOP 64
#define SABER_MOTOR2_FULL_FORWARD 255
#define SABER_MOTOR2_FULL_REVERSE 128
#define SABER_MOTOR2_FULL_STOP 192
#define SABER_ALL_STOP 0
SoftwareSerial SaberSerial = SoftwareSerial( SABER_RX_PIN, SABER_TX_PIN );
void initSabertooth( void )
{
  pinMode( SABER_TX_PIN, OUTPUT );
  SaberSerial.begin( SABER_BAUDRATE );
  delay( 2000 );
  setEngineSpeed( SABER_ALL_STOP );
}
void setEngineSpeed( signed char cNewMotorSpeed )
{
  unsigned char cSpeedVal_Motor1 = 0;
  unsigned char cSpeedVal_Motor2 = 0;
  if( cNewMotorSpeed == 0 )
  {
    SaberSerial.print( 0, BYTE );
    return;
  }
  if( cNewMotorSpeed >= 100 )
  {
    cSpeedVal_Motor1 = SABER_MOTOR1_FULL_FORWARD;
    cSpeedVal_Motor2 = SABER_MOTOR2_FULL_FORWARD;
  }
  else if( cNewMotorSpeed <= -100 )
  {
    cSpeedVal_Motor1 = SABER_MOTOR1_FULL_REVERSE;
    cSpeedVal_Motor2 = SABER_MOTOR2_FULL_REVERSE;
  }
  else
  {
    cSpeedVal_Motor1 = map( cNewMotorSpeed,
                           -100,
                            100,
                            SABER_MOTOR1_FULL_REVERSE,
                            SABER_MOTOR1_FULL_FORWARD );

     cSpeedVal_Motor2 = map( cNewMotorSpeed,
                            -100,
                             100,
                             SABER_MOTOR2_FULL_REVERSE,
                             SABER_MOTOR2_FULL_FORWARD );
  }
  SaberSerial.print( cSpeedVal_Motor1, BYTE );
  SaberSerial.print( cSpeedVal_Motor2, BYTE );
}

void setup( )
{
  initSabertooth( );
}
//void control( )
//{
//  // Full stop
//  setEngineSpeed( 0 );
//
//  // Half reverse
//  setEngineSpeed( -50 );
//
//  // Full reverse
//  setEngineSpeed( -100 );
//
//  // Half forward
//  setEngineSpeed( 50 );
//
//  // Full forward
//  setEngineSpeed( 100 );
//}

void setEngineSpeedDir( signed char cNewMotorSpeedDir )
{
  unsigned char cSpeedValDir_Motor1 = 0;
  unsigned char cSpeedValDir_Motor2 = 0;
  if( cNewMotorSpeedDir >= 100 )
  {
    cSpeedValDir_Motor1 = SABER_MOTOR1_FULL_FORWARD; // GO RIGHT
    cSpeedValDir_Motor2 = SABER_MOTOR2_FULL_STOP;
  }
  else if( cNewMotorSpeedDir <= -100 )
  {
    cSpeedValDir_Motor1 = SABER_MOTOR1_FULL_STOP; // GO LEFT
    cSpeedValDir_Motor2 = SABER_MOTOR2_FULL_FORWARD;
  }
  else
  {
    cSpeedValDir_Motor1 = map( cNewMotorSpeedDir,
                              -100,
                               100,
                               SABER_MOTOR1_FULL_STOP,
                               SABER_MOTOR1_FULL_FORWARD );
    cSpeedValDir_Motor2 = map( cNewMotorSpeedDir,
                              -100,
                               100,
                               SABER_MOTOR2_FULL_FORWARD,
                               SABER_MOTOR2_FULL_STOP);
  }
  SaberSerial.print( cSpeedValDir_Motor1, BYTE );
  SaberSerial.print( cSpeedValDir_Motor2, BYTE );
}

//void turn ( )
//{
//  // Turn left
//  setEngineSpeedDir( -100 );
//
//  // Turn right
//  setEngineSpeedDir( 100 );
//}




void loop()
{
  setEngineSpeedDir( -100 );
  delay( 5000 );
  setEngineSpeed( 0 );
 
  
  
  
//  signed char traverse;
//  signed char negotiate;
//
//  if(Serial.available()>0)
//  {
//    int data = Serial.read();
//
////    digitalWrite(buttonPin,LOW);
//
//    switch(data)
//    {
//      case'w':traverse = 100;break; //full forward
//      case's':traverse = -50;break; // half reverse
//      case'q':traverse = 0;break; // Stop
//      case'a':negotiate = -100;break; // left
//      case'd':negotiate = 100;break; // right
//    }
//
//    setEngineSpeed( traverse );
//    setEngineSpeedDir( negotiate );
//  }
}

Moderator edit: code tags added.
5  Using Arduino / Motors, Mechanics, and Power / Sabertooth motor control - tank styled Please help young engineers! on: August 29, 2012, 04:42:37 pm
I was wondering if someone could help me design a program that can run 2 different dc motor with a sabertooth controller (i have one, and have been using it for segways and stuff) The problem is i don't know how to write a standard like motor1 run until delay and motor 2 run until delay, type with the sabertooth. Also for the motors speed to be controlled with a potentiometer. So basically the motors have button inputs for left and right steering, and then for forward (straight ) control where both motors are running in the same direction, and a potentiometer would control the speed for that.

example  if (button 1 = on) {
motor1 - forward
delay (1000);
}
example if (button 2 = on) {
motor2 -forward
delay(1000);
}

for steering and

potentiometer would control the speed.

so if val = i < 0 {
val = motor1 - forward
val = motor2 -forward
} until u moved the potentiometer to 0 again.

this obviously isn't real code but i just wrote this to explain the type of function im talking about.

and also it would be cool if we could use the potentiometer for steering as well.
Thanks to anyone that wants to help!
Pages: [1]