Notifications
Clear all

Adeept Hexapod kit ADA033, thirteenth servo will not attach

54 Posts
4 Users
12 Likes
5,422 Views
ZoolanderMicro
(@zoolandermicro)
Member
Joined: 4 years ago
Posts: 144
Topic starter  

Does anyone have experience with Adeept robot kits? I got a hexpod robot with thirteen servos, twelve for the legs, and one for the head. The control board is the Adeept Pixie, with a Mega328P. Using the Arduino IDE I can compose and upload code. The attached PDFs display the robot servos and the Pixie board. The issue is the thirteenth servo (for the head) will not attach in the code. Here is my servo test code:

/*
* Adeept Hexapod test code written to test each of 
* thriteen servos.
*/
#include <Servo.h>
#define servoData 13  //Number of servos
#define numSweeps 2 //Number of spider bot head sweeps left and right
const int MIN_ANGLE = 10;  //Minimum sweep angle of bot head
const int MAX_ANGLE = 170; //Maximum sweep angle of bot head
int angle[servoData] = {90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90};
Servo myServo[servoData];//Create servo object.Indecies 0 through 12 (13 servos)

void setup() {
  for (int i = 0; i < servoData; i++) { //Attach servos to pins 2 through 14
    myServo[i].attach(i + 2);
  }
  for (int i = 0; i < servoData; i++) { //Set all servos to 90 degree angle
    myServo[i].write(angle[i]);
  }
  delay(1000);//wait for a second
}
void loop() {
  for (int index = 0; index < servoData; index++) {
    if (index <= 5) {                          //Move servos on left side
      move_Servo_L(index);
    }
    else if (index > 5 && index < servoData) { //Move servos on right side
      move_Servo_R(index);
    }
    else {
      botHead_Sweep(); //Move head servo
    }
  }
}
//Functions
int move_Servo_L(int servo) { //Left side pivot and claw servos
  if (myServo[servo].attached()) { //If the servo is attached, proceed with the function
    myServo[servo].write(60);
    delay(500);
    myServo[servo].write(90);
    delay(500);
    myServo[servo].write(120);
    delay(500);
    myServo[servo].write(90);
    delay(500);
  }
}
int move_Servo_R(int servo) { //Right side pivot and claw servos
  if (myServo[servo].attached()) { //If the servo is attached, proceed with the function
    myServo[servo].write(120);
    delay(500);
    myServo[servo].write(90);
    delay(500);
    myServo[servo].write(60);
    delay(500);
    myServo[servo].write(90);
    delay(500);
  }
}
void botHead_Sweep() {         //Head servo pivots
  if (myServo[12].attached()) { //If the 13th servo is attached, proceed with the function
    for (int count = 0; count < numSweeps; count++) { //The head sweeps left and right twice
      static int sweep = 10; //initialize bot head angle to 10 degrees
      while (sweep < MAX_ANGLE) {
        myServo[12].write(sweep);
        sweep = sweep + 2;
        delay(100); //wait
      }
      while (sweep > MIN_ANGLE) {
        myServo[12].write(sweep);
        sweep = sweep - 2;
        delay(100); //wait
      }
    } //End for loop
  } //End if
}//End function

 

ZoolanderMicro, where small ideas are a big deal


   
Quote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6988
 

Just an aside, how did you get the code snippet to format so nice, I tried the source widget {;} and it was a mess.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
ZoolanderMicro
(@zoolandermicro)
Member
Joined: 4 years ago
Posts: 144
Topic starter  

All the legs servos move, claw in/out then pivot forward/back. Even in the setup() function the head servo does not initialize to 90 degrees. Unfortunately, the Adeept forums and support are very unresponsive. Many questions asked, few replies. I've successfully written code just for the head servo. The botHead_Sweep() function works fine for just the head. Is there a limitation to the number of servos per timer? From what I can understand reading the servo.h file, I don't see a limitation.

 

ZoolanderMicro, where small ideas are a big deal


   
ReplyQuote
ZoolanderMicro
(@zoolandermicro)
Member
Joined: 4 years ago
Posts: 144
Topic starter  
Posted by: @zander

how did you get the code snippet to format so nice

I clicked the code <> link, and a window pops up where you can past your code. After you add your reply, the code appears in a nice, blue box. 😉

ZoolanderMicro, where small ideas are a big deal


   
Inst-Tech reacted
ReplyQuote
ZoolanderMicro
(@zoolandermicro)
Member
Joined: 4 years ago
Posts: 144
Topic starter  

I had to write separate functions for the legs on the right and left because the servos are mirrored on each side. That way, they all run the same out/in, back/forward pattern. 

ZoolanderMicro, where small ideas are a big deal


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6988
 

@zoolandermicro Your code is in error I think, you will never take the else botheadsweep as the loop will terminate at i<13 and the middle else is still being taken at i<13.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6988
 

@zoolandermicro My test mangled the code.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
ZoolanderMicro
(@zoolandermicro)
Member
Joined: 4 years ago
Posts: 144
Topic starter  

In the loop() function, I changed the for() loop to allow it to count up to 13. Still no joy 🙁 

for (int index = 0; index <= servoData; index++) {

ZoolanderMicro, where small ideas are a big deal


   
ReplyQuote
ZoolanderMicro
(@zoolandermicro)
Member
Joined: 4 years ago
Posts: 144
Topic starter  

@Ron, here is the current loop() function. 

void loop() {
  for (int index = 0; index <= servoData; index++) {
    if (index <= 5) {                          //Move servos on left side
      move_Servo_L(index);
    }
    else if (index > 5 && index < servoData) { //Move servos on right side
      move_Servo_R(index);
    }
    else {
      botHead_Sweep(); //Move head servo
    }
  }
}

ZoolanderMicro, where small ideas are a big deal


   
ReplyQuote
ZoolanderMicro
(@zoolandermicro)
Member
Joined: 4 years ago
Posts: 144
Topic starter  

Ok, changed it again. The idea is to write to servos 0 through 5 (left side) and 6 through 11 (right side) and servo 12 is the head. After failing the if() and the else if() tests, the code is supposed to be true for the else clause. I hate the 'magic numbers' thing, but sometimes it makes it easier to read. Just uploaded the code, but the head servo still doesn't move.

void loop() {
  for (int index = 0; index <= servoData; index++) {
    if (index <= 5) {                          //Move servos on left side
      move_Servo_L(index);
    }
    else if (index > 5 && index < 12) { //Move servos on right side
      move_Servo_R(index);
    }
    else {
      botHead_Sweep(); //Move head servo
    }
  }
}

ZoolanderMicro, where small ideas are a big deal


   
ReplyQuote
ZoolanderMicro
(@zoolandermicro)
Member
Joined: 4 years ago
Posts: 144
Topic starter  

The Arduino IDE has an Auto Format function that make the code look nice. I just copied and pasted into the code box. I haven't tried copy/paste from Notepad++ (should work). 

ZoolanderMicro, where small ideas are a big deal


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6988
 

@zoolandermicro You are making some rookie errors here.

The code super simplified is 

for 0 to 12

do L for 0 to 5

do R for 6 to 11

do head for 12

Another way to think of it is you have 6 lefts, 6 rights, 1 head for a total of 13.

Your original code was one too far on the R, it should have been this leaves array(ServoData) for the head.

Sorry if that was long winded or not clear, but as someone brought up on hardware, micro-code, machne code, assembler, dozens of high level languages, numerous OS's, then finally applications, I have no trouble moving between 0 based nomenclature (actually how the low level stuff works) and 1 based (inefficient)

There are actually special hardware bits to sense empty (all o) registers, words, memory locations.

 

 else if (index > 5 && index < servoData) { //Move servos on right side

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6988
 

@zoolandermicro It was the standard supplied blink sketch, already formatted. I will include it here again and see what happens

[code] /* Blink Turns an LED on for one second, then off for one second, repeatedly. Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to the correct LED pin independent of which board is used. If you want to know what pin the on-board LED is connected to on your Arduino model, check the Technical Specs of your board at: https://www.arduino.cc/en/Main/Products modified 8 May 2014 by Scott Fitzgerald modified 2 Sep 2016 by Arturo Guadalupi modified 8 Sep 2016 by Colby Newman This example code is in the public domain. https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink */ // the setup function runs once when you press reset or power the board void setup() { // initialize digital pin LED_BUILTIN as an output. pinMode(LED_BUILTIN, OUTPUT); } // the loop function runs over and over again forever void loop() { digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second } [/code]

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
ZoolanderMicro
(@zoolandermicro)
Member
Joined: 4 years ago
Posts: 144
Topic starter  

The thirteenth servo controlling the Hexapod head works with this code:

/*
 * BotHeadSweep sketch tests the thirteenth servo
 * controlling the head of the Hexapod 
 */
#include 
const int MIN_ANGLE = 20;  //Minimum sweep angle of bot head
const int MAX_ANGLE = 160; //Maximum sweep angle of bot head
Servo botHead;//create servo object to control a servo
void setup() {
  botHead.attach(14);//attachs the servo on pin D14 of Pixie board
  botHead.write(90);//back to 90 degrees
  delay(1000);//wait for a second
}

void loop() {
  static int sweep = 90; //initialize bot head to 90 degrees
  while (sweep < MAX_ANGLE) {
    botHead.write(sweep);
    sweep = sweep + 2;
    delay(10); //wait
  }
  while (sweep > MIN_ANGLE) {
    botHead.write(sweep);
    sweep = sweep - 2;
    delay(10); //wait
  }
}

ZoolanderMicro, where small ideas are a big deal


   
ReplyQuote
ZoolanderMicro
(@zoolandermicro)
Member
Joined: 4 years ago
Posts: 144
Topic starter  

The servo.h file has this note:

 Note that analogWrite of PWM on pins associated with the timer are 
  disabled when the first servo is attached.
  Timers are seized as needed in groups of 12 servos - 24 servos use two 
  timers, 48 servos will use four.
  The sequence used to seize timers is defined in timers.h

ZoolanderMicro, where small ideas are a big deal


   
ReplyQuote
Page 1 / 4