Go Down

Topic: Banebots (Read 2993 times) previous topic - next topic

Raveious

alright, theres no way i can be screwing this up, the motor controller im using blinks quickly but does pause for a spit second, so i think i might have this a little correct.

(yes this is the sweep servo sample code modified to use the banebots motor controller)

Code: [Select]
#include <Servo.h>

Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created

int pos = 0;    // variable to store the servo position

void setup()
{
  pinMode(9, OUTPUT);
  myservo.attach(9,1000,2000);  // attaches the servo on pin 9 to the servo object
}


void loop()
{
  for(pos = 0; pos < 180; 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(15);                       // waits 15ms for the servo to reach the position
  }
  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees
  {                               
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}

CrossRoads

So is there a question here?
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Raveious


imho , first "for" loop doesn't works, as  it overwritten by second one.
you declare int=pos globaly, so it changes in any part of the code.



this is the sample "sweep" program


So is there a question here?


huh, i forgot that part, i cant get the banebots motor controller to work, the light just blinks but pauses sometimes like its working.

CrossRoads

Ok, so tell us about your wiring (preferably a schematic) and the motor you are using.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Raveious

i hope this helps because im stumped

CrossRoads

I don't see any info on what the "SIG" line is supposed to look like.
Presumably this is an RC thing where 20mS pulses come out for neutral position for example and less than 20mS moves one direction and more than 20mS moves the other direction?

What does the 1000, 2000, do here?
myservo.attach(9,1000,2000); 

What are you seeing compared to this paragraph from the controller spec?

"The controller will activate after power is applied when neutral throttle position signals are received.
This is a built-in safety feature.
The READY LED will blink rapidly until these signals are received.
When the controller has received these neutral position signals, the READY LED will stay on continuously.
The DIR LEDs will activate individually depending on the motor direction."

So it sounds like it is not seeing a good pulse stream.
Can you revise your code to just have it stay in one position, see if you can get that steady light, then try adding movement commands after that?
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.


Raveious

i finally got it to work and using this program i made i figure out what ranges it works at (and i dont know why its like that)
Code: [Select]
#include <Servo.h>

Servo myservo; 

int pos = 0;
byte blarg;

void setup()
{
  Serial.begin(57600);

  myservo.attach(11);
}


void loop()
{
  if (Serial.available())
  {
    blarg = Serial.read();
   
    if(blarg == '=' && pos <= 180)
    {
      pos+=5;
      if(pos > 180)
        pos = 0;
      myservo.write(pos);
      Serial.println(pos);
    }
    else if(blarg == '-' && pos >= 0)
    {
      pos-=5;
      if (pos < 0)
        pos = 180;
      myservo.write(pos);
      Serial.println(pos);
    }
  }
}


162 is full reverse (unstable)
26 is full forward (unstable)

can anyone help make figure out how to make it the full range (0-180 or 180-0)?????


Raveious

changed

myservo.attach(11);

to

myservo.attach(11,1000,2000);

and now its stable and i get full range, i still don't know why i had this problem in the first place, but now i have a benchmark of getting the stupid motor to work.

CrossRoads

Maybe your PWM pin 9 is fried?
Try this working program on 9, see if it works.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Raveious

yup, still works

Go Up