Maestro and arduino sequence launch fails

Hi, I made a 22 dof robot using pololu maestro 24. everything works really nice via the control center. It is connected via tx rx to arduino mega 2650 so that the arduino launches sequences on the maestro.The problem is that is works … a few times… i’d say maybe 10 minutes then… it totaly stop launching sequences like it had lost connection. When i retry the day after without changing anything… ho miracle… it works again!!! a few times or minutes then stop…
I tried diferent modification in the pololu script… removing the no stop atribute, replacing return by quit… etc etc… same issue all the time

here is the pololu script (followed by the arduino script)

### Sequence subroutines: ###

# Abonjour
sub Abonjour
  500 6453 6415 5940 9984 7932 5897 
  4756 3968 5957 6976 6959 3406 
  9600 3755 2981 6199 5749 3968 
  8832 9370 5807 5284 0 0 frame_0..23 # Frame 0
  500 6823 5167 7955 8260 7713 7240 
  9954 3800 frame_0..6_11 # Frame 1
  500 6792 5958 4787 3406 frame_0_1_5_11 # Frame 2
  500 6466 7123 frame_2_5 # Frame 3
  500 4801 7284 4524 frame_1_2_5 # Frame 4
  500 6823 5167 7955 7240 3800 frame_0..2_5_11 # Frame 1
  500 6792 5958 4787 3406 frame_0_1_5_11 # Frame 2
  500 6453 6415 5940 9984 7932 5897 
  4756 frame_0..6 # Frame 0
nostop:        
550 delay
goto nostop
  
# Boui
sub Boui
  500 6453 6415 5940 9984 7932 5897 
  4756 3968 5957 6976 6959 3406 
  9600 3755 2981 6199 5749 3968 
  8832 9370 5807 5284 0 0 frame_0..23 # Frame 0
  500 6164 3599 8832 7065 7560 9298 
  3999 6395 5692 8303 6081 5399 frame_0..2_5_6_12_13_15_16_18_20_21 # Frame 1
  500 6720 5824 9600 3755 6199 5749 
  8832 5807 5284 frame_1_2_12_13_15_16_18_20_21 # Frame 2
  500 3584 8832 frame_1_2 # Frame 3
  500 6720 5824 frame_1_2 # Frame 4
  500 6453 6415 5940 5897 4756 frame_0..2_5_6 # Frame 0
goto nostop
  
# Cnon
sub Cnon
  500 6453 6415 5940 9984 7932 5897 
  4756 3968 5957 6976 6959 3406 
  9600 3755 2981 6199 5749 3968 
  8832 9370 5807 5284 0 0 frame_0..23 # Frame 0
  500 7607 5106 6612 4583 8260 3706 
  2845 frame_0..2_5_6_10_11 # Frame 1
  500 5034 6080 7094 6452 5457 3854 frame_0..2_5_9_11 # Frame 2
  500 7607 5106 6612 4583 6976 2845 frame_0..2_5_9_11 # Frame 1
  500 5034 6080 7094 6452 5457 3854 frame_0..2_5_9_11 # Frame 2
  500 6453 6415 5940 5897 4756 6976 
  6959 3406 frame_0..2_5_6_9..11 # Frame 0
goto nostop
  
# Dsais pas
sub Dsais_pas
  500 6453 6415 5940 9984 7932 5897 
  4756 3968 5957 6976 6959 3406 
  9600 3755 2981 6199 5749 3968 
  8832 9370 5807 5284 0 0 frame_0..23 # Frame 0
  500 4721 6720 8116 4904 8786 3022 
  3311 frame_0..2_5_6_10_11 # Frame 1
  500 7294 7503 9984 4493 1984 3111 frame_0_5_6_9..11 # Frame 2
  500 5631 7678 7706 3968 4061 3117 frame_0_5_6_9..11 # Frame 3
  500 8329 5824 5138 6713 3122 frame_0_2_5_9_11 # Frame 4
  500 6453 6415 5940 5897 4756 6976 
  6959 3406 frame_0..2_5_6_9..11 # Frame 0
goto nostop
  
# Emerci
sub Emerci
  500 6453 6415 5940 9984 7932 5897 
  4756 3968 5957 6976 6959 3406 
  9600 3755 2981 6199 5749 3968 
  8832 9370 5807 5284 0 0 frame_0..23 # Frame 0
  500 6720 5824 6977 9662 4242 5722 
  8186 5361 frame_1..3_6_13_16_18_21 # Frame 1
  500 5819 4699 frame_0_5 # Frame 2
  500 6007 5532 7430 5897 frame_0..2_5 # Frame 3
  500 6453 6415 5940 9984 4756 3755 
  5749 8832 5284 frame_0..3_6_13_16_18_21 # Frame 0
goto nostop
  
# Fdance
sub Fdance
  1000 6453 6415 5940 9984 7932 5897 
  4756 3968 5957 6976 6959 3406 
  9600 3755 2981 6199 5749 3968 
  8832 9370 5807 5284 0 0 frame_0..23 # Frame 0
  500 6352 3964 8014 5254 6946 8812 
  5982 5428 4007 3294 frame_0..3_6..11 # Frame 1
  500 4238 5824 3239 7955 5580 4230 
  2816 frame_1_2_5_7..9_11 # Frame 2
  500 5608 8121 7063 frame_4_8_9 # Frame 3
  500 3495 1984 10613 9312 3388 frame_3_5_7_9_11 # Frame 4
  500 6720 8832 4448 7658 11127 9656 
  9984 3896 frame_1..4_7..9_11 # Frame 5
  500 5129 5307 6309 3683 frame_0_4_8_11 # Frame 6
  500 8204 7658 9656 3896 frame_0_4_8_11 # Frame 5
  500 5129 5307 6309 3683 frame_0_4_8_11 # Frame 6
  500 4032 9494 6160 4339 5494 frame_11_12_15_17_20 # Frame 5
  500 9239 7658 9656 2816 9284 6610 
  3968 5944 frame_0_4_8_11_12_15_17_20 # Frame 10
  500 5129 5307 6309 4032 9494 6160 
  4339 5494 frame_0_4_8_11_12_15_17_20 # Frame 5
  500 9239 7658 9656 2816 9284 6610 
  3968 5944 frame_0_4_8_11_12_15_17_20 # Frame 10
  500 6352 4238 5824 3495 5608 10613 
  8121 9312 3388 9600 6199 5807 frame_0..4_7..9_11_12_15_20 # Frame 13
  500 6704 8774 frame_1_3 # Frame 14
  500 6656 4096 5401 4103 3213 frame_5_7_10_13_14 # Frame 15
  500 9308 6043 4274 8166 8728 5592 
  5226 frame_12_16..21 # Frame 16
  500 3584 8832 6454 5720 3597 4903 
  3530 6355 5809 7461 8699 5709 
  5091 frame_1_2_7_9_10_13..16_18..21 # Frame 17
  500 5286 3784 6727 5663 6757 8319 
  5110 frame_13..16_18_19_21 # Frame 18
  500 4903 3530 6355 5400 7461 8699 
  5091 frame_13..16_18_19_21 # Frame 19
  500 6704 5824 4096 9312 5401 4103 
  3213 6199 6043 8166 8728 5592 
  5226 frame_1_2_7_9_10_13..16_18..21 # Frame 20
  500 9600 5749 3968 8832 9370 5807 
  5033 frame_12_16..21 # Frame 21
  500 1984 10613 4007 3755 2981 5284 frame_5_7_10_13_14_21 # Frame 22
  500 5129 6720 8832 4448 5307 11127 
  6309 9984 3683 frame_0..4_7..9_11 # Frame 23
  500 8204 7658 9656 3896 frame_0_4_8_11 # Frame 24
  500 6352 4238 5824 5254 5608 3239 
  7955 8121 7063 2816 frame_0..5_7..9_11 # Frame 25
  500 7932 5580 4230 frame_4_8_9 # Frame 26
  500 3964 8014 5897 8812 5982 5428 
  3294 frame_1_2_5_7..9_11 # Frame 27
  1000 6453 6415 5940 9984 4756 3968 
  5957 6976 6959 3406 frame_0..3_6..11 # Frame 28
goto nostop
  
# Gbye
sub Gbye
  500 6453 6415 5940 9984 7932 5897 
  4756 3968 5957 6976 6959 3406 
  9600 3755 2981 6199 5749 3968 
  8832 9370 5807 5284 0 0 frame_0..23 # Frame 5
  500 5944 5547 7766 6454 5932 1984 frame_0..2_7_8_10 # Frame 0
  500 5895 frame_9 # Frame 1
  500 6760 7092 3642 frame_0_9_11 # Frame 2
  500 5944 6729 6187 frame_0_2_9 # Frame 3
  500 7766 6976 3406 frame_2_9_11 # Frame 0
  500 5895 frame_9 # Frame 1
  500 6760 7092 3642 frame_0_9_11 # Frame 2
  500 5944 6729 6187 frame_0_2_9 # Frame 3
  500 6453 6415 5940 3968 5957 6976 
  6959 3406 frame_0..2_7..11 # Frame 4
goto nostop
  
# sequ1
sub sequ1
  500 6453 6415 5940 9984 7932 5897 
  4756 3968 5957 6976 6959 3406 
  9600 3755 2981 6199 5749 3968 
  8832 9370 5807 5284 0 0 frame_0..23 # Frame 0
goto nostop
  

sub frame_0..23
  23 servo
  22 servo
  21 servo
  20 servo
  19 servo
  18 servo
  17 servo
  16 servo
  15 servo
  14 servo
  13 servo
  12 servo
  11 servo
  10 servo
  9 servo
  8 servo
  7 servo
  6 servo
  5 servo
  4 servo
  3 servo
  2 servo
  1 servo
  0 servo
  delay
  return

sub frame_0..6_11
  11 servo
  6 servo
  5 servo
  4 servo
  3 servo
  2 servo
  1 servo
  0 servo
  delay
  return

sub frame_0_1_5_11
  11 servo
  5 servo
  1 servo
  0 servo
  delay
  return

sub frame_2_5
  5 servo
  2 servo
  delay
  return

sub frame_1_2_5
  5 servo
  2 servo
  1 servo
  delay
  return

sub frame_0..2_5_11
  11 servo
  5 servo
  2 servo
  1 servo
  0 servo
  delay
  return

sub frame_0..6
  6 servo
  5 servo
  4 servo
  3 servo
  2 servo
  1 servo
  0 servo
  delay
  return

sub frame_0..2_5_6_12_13_15_16_18_20_21
  21 servo
  20 servo
  18 servo
  16 servo
  15 servo
  13 servo
  12 servo
  6 servo
  5 servo
  2 servo
  1 servo
  0 servo
  delay
  return

sub frame_1_2_12_13_15_16_18_20_21
  21 servo
  20 servo
  18 servo
  16 servo
  15 servo
  13 servo
  12 servo
  2 servo
  1 servo
  delay
  return

sub frame_1_2
  2 servo
  1 servo
  delay
  return

sub frame_0..2_5_6
  6 servo
  5 servo
  2 servo
  1 servo
  0 servo
  delay
  return

sub frame_0..2_5_6_10_11
  11 servo
  10 servo
  6 servo
  5 servo
  2 servo
  1 servo
  0 servo
  delay
  return

sub frame_0..2_5_9_11
  11 servo
  9 servo
  5 servo
  2 servo
  1 servo
  0 servo
  delay
  return

sub frame_0..2_5_6_9..11
  11 servo
  10 servo
  9 servo
  6 servo
  5 servo
  2 servo
  1 servo
  0 servo
  delay
  return

sub frame_0_5_6_9..11
  11 servo
  10 servo
  9 servo
  6 servo
  5 servo
  0 servo
  delay
  return

sub frame_0_2_5_9_11
  11 servo
  9 servo
  5 servo
  2 servo
  0 servo
  delay
  return

sub frame_1..3_6_13_16_18_21
  21 servo
  18 servo
  16 servo
  13 servo
  6 servo
  3 servo
  2 servo
  1 servo
  delay
  return

sub frame_0_5
  5 servo
  0 servo
  delay
  return

sub frame_0..2_5
  5 servo
  2 servo
  1 servo
  0 servo
  delay
  return

sub frame_0..3_6_13_16_18_21
  21 servo
  18 servo
  16 servo
  13 servo
  6 servo
  3 servo
  2 servo
  1 servo
  0 servo
  delay
  return

sub frame_0..3_6..11
  11 servo
  10 servo
  9 servo
  8 servo
  7 servo
  6 servo
  3 servo
  2 servo
  1 servo
  0 servo
  delay
  return

sub frame_1_2_5_7..9_11
  11 servo
  9 servo
  8 servo
  7 servo
  5 servo
  2 servo
  1 servo
  delay
  return

sub frame_4_8_9
  9 servo
  8 servo
  4 servo
  delay
  return

sub frame_3_5_7_9_11
  11 servo
  9 servo
  7 servo
  5 servo
  3 servo
  delay
  return

sub frame_1..4_7..9_11
  11 servo
  9 servo
  8 servo
  7 servo
  4 servo
  3 servo
  2 servo
  1 servo
  delay
  return

sub frame_0_4_8_11
  11 servo
  8 servo
  4 servo
  0 servo
  delay
  return

sub frame_11_12_15_17_20
  20 servo
  17 servo
  15 servo
  12 servo
  11 servo
  delay
  return

sub frame_0_4_8_11_12_15_17_20
  20 servo
  17 servo
  15 servo
  12 servo
  11 servo
  8 servo
  4 servo
  0 servo
  delay
  return

sub frame_0..4_7..9_11_12_15_20
  20 servo
  15 servo
  12 servo
  11 servo
  9 servo
  8 servo
  7 servo
  4 servo
  3 servo
  2 servo
  1 servo
  0 servo
  delay
  return

sub frame_1_3
  3 servo
  1 servo
  delay
  return

sub frame_5_7_10_13_14
  14 servo
  13 servo
  10 servo
  7 servo
  5 servo
  delay
  return

sub frame_12_16..21
  21 servo
  20 servo
  19 servo
  18 servo
  17 servo
  16 servo
  12 servo
  delay
  return

sub frame_1_2_7_9_10_13..16_18..21
  21 servo
  20 servo
  19 servo
  18 servo
  16 servo
  15 servo
  14 servo
  13 servo
  10 servo
  9 servo
  7 servo
  2 servo
  1 servo
  delay
  return

sub frame_13..16_18_19_21
  21 servo
  19 servo
  18 servo
  16 servo
  15 servo
  14 servo
  13 servo
  delay
  return

sub frame_5_7_10_13_14_21
  21 servo
  14 servo
  13 servo
  10 servo
  7 servo
  5 servo
  delay
  return

sub frame_0..4_7..9_11
  11 servo
  9 servo
  8 servo
  7 servo
  4 servo
  3 servo
  2 servo
  1 servo
  0 servo
  delay
  return

sub frame_0..5_7..9_11
  11 servo
  9 servo
  8 servo
  7 servo
  5 servo
  4 servo
  3 servo
  2 servo
  1 servo
  0 servo
  delay
  return

sub frame_0..2_7_8_10
  10 servo
  8 servo
  7 servo
  2 servo
  1 servo
  0 servo
  delay
  return

sub frame_9
  9 servo
  delay
  return

sub frame_0_9_11
  11 servo
  9 servo
  0 servo
  delay
  return

sub frame_0_2_9
  9 servo
  2 servo
  0 servo
  delay
  return

sub frame_2_9_11
  11 servo
  9 servo
  2 servo
  delay
  return

sub frame_0..2_7..11
  11 servo
  10 servo
  9 servo
  8 servo
  7 servo
  2 servo
  1 servo
  0 servo
  delay
  return

here is the arduino script (including the lcd, ir and dfplayer code)

#include <PololuMaestro.h>

/* On boards with a hardware serial port available for use, use
  that port to communicate with the Maestro. For other boards,
  create a SoftwareSerial object using pin 10 to receive (RX) and
  pin 11 to transmit (TX). */
#ifdef SERIAL_PORT_HARDWARE_OPEN
#define maestroSerial SERIAL_PORT_HARDWARE_OPEN
#else
#include <SoftwareSerial.h>
SoftwareSerial maestroSerial(19, 18);
#endif

/* Next, create a Maestro object using the serial port.
  Uncomment one of MicroMaestro or MiniMaestro below depending
  on which one you have. */
//MicroMaestro maestro(maestroSerial);
MiniMaestro maestro(maestroSerial);


// Include DFPlayer Mp3 library
#include "DFRobotDFPlayerMini.h"

DFRobotDFPlayerMini myDFPlayer;
bool dfMute = false;

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

#include "IRremote.h"

#define receiver 6 // Signal Pin of IR receiver to Arduino Digital Pin 11

/*-----( Declare objects )-----*/
IRrecv irrecv(receiver);     // create instance of 'irrecv'
decode_results results;     // create instance of 'decode_results'

char line[16];
int sequenceID=0;       // Sequence Index
int prevSequenceID=-1;  // Previous Sequence Index
bool runState=false;    // Script Run State
bool prevRunState=true; // Previous Script Run State

/*-----( Function )-----*/
/*

void translateIR() // takes action based on IR code received

// describing Remote IR codes 
{
  switch(results.value) {
    case 0xFFA25D: Serial.println("POWER"); break;
    case 0xFFE21D: Serial.println("FUNC/STOP"); break;
    case 0xFF629D: Serial.println("VOL+"); break;
    case 0xFF22DD: Serial.println("FAST BACK");    break;
    case 0xFF02FD: Serial.println("PAUSE");    break;
    case 0xFFC23D: Serial.println("FAST FORWARD");   break;
    case 0xFFE01F: Serial.println("DOWN");    break;
    case 0xFFA857: Serial.println("VOL-");    break;
    case 0xFF906F: Serial.println("UP");    break;
    case 0xFF9867: Serial.println("EQ");    break;
    case 0xFFB04F: Serial.println("ST/REPT");    break;
    case 0xFF6897: Serial.println("0");    break;
    case 0xFF30CF: Serial.println("1");    break;
    case 0xFF18E7: Serial.println("2");    break;
    case 0xFF7A85: Serial.println("3");    break;
    case 0xFF10EF: Serial.println("4");    break;
    case 0xFF38C7: Serial.println("5");    break;
    case 0xFF5AA5: Serial.println("6");    break;
    case 0xFF42BD: Serial.println("7");    break;
    case 0xFF4AB5: Serial.println("8");    break;
    case 0xFF52AD: Serial.println("9");    break;
    case 0xFFFFFFFF: Serial.println(" REPEAT");break;  
    default: Serial.println(" other button   ");
  }// End Case

  delay(500); // Do not get immediate repeat
} //END translateIR
*/

void setup() {

  // Setup DFPlayer
  Serial2.begin(9600);
  if (!myDFPlayer.begin(Serial2)) {
    Serial.println(F("Unable to begin:"));
    Serial.println(F("1.Please recheck the connection!"));
    Serial.println(F("2.Please insert the SD card!"));
  }

  myDFPlayer.volume(10);
  myDFPlayer.EQ(DFPLAYER_EQ_NORMAL);
  myDFPlayer.outputDevice(DFPLAYER_DEVICE_SD);
  myDFPlayer.play(2);

  // Setup Maestro
  maestroSerial.begin(9600);
  maestro.stopScript(); // In case a script was running while stating

  // Setup LCD
  lcd.begin(16, 2); // set up the LCD's number of columns and rows:

  lcd.print("Felicya control ");
  lcd.print("v1.0 Ready!     ");
  delay(3000);
  lcd.clear();

  // Setup IR
  irrecv.enableIRIn(); // Start the IR receiver
}

void loop() {
  if (irrecv.decode(&results)) // have we received an IR signal?
  {
    switch (results.value) {
      case 0xFF6897: sequenceID=0; break;
      case 0xFF30CF: sequenceID=1; break;
      case 0xFF18E7: sequenceID=2; break;
      case 0xFF7A85: sequenceID=3; break;
      case 0xFF10EF: sequenceID=4; break;
      case 0xFF38C7: sequenceID=5; break;
      case 0xFF5AA5: sequenceID=6; break;
      case 0xFF42BD: sequenceID=7; break;
      case 0xFF4AB5: sequenceID=8; break;
      case 0xFF52AD: sequenceID=9; break;
      case 0xFF02FD: // PLAY/PAUSE
        if ( runState ) {
          maestro.stopScript();
          runState = false;
        } else {
          maestro.restartScript(sequenceID);
          runState = true;
        }
        break;
      default: // Unknown / Unused code
        break;
    }
    irrecv.resume(); // receive the next value
  }  
  if ( sequenceID != prevSequenceID ) {
    if ( ! runState ) {
      sprintf(line, "Sequence: %1d     ", sequenceID);
      lcd.setCursor(0, 1);
      lcd.print(line);
      prevSequenceID = sequenceID;
    } else {
      sequenceID = prevSequenceID;
    }
  }
  if ( runState != prevRunState ) {
    prevRunState = runState;
    lcd.setCursor(0, 0);
    if ( runState ) {
      lcd.print("Running:        ");
    }
    else {
      lcd.print("Select:         ");
    }
  }
  delay(100);
}

Hello, driftgirl.

When the robot stops responding, are you receiving an error on the Maestro (indicated by the red LED)? If so, can you check and see what that error is? You can do this by connecting it to your computer and looking in the “Errors” tab of the Maestro Control Center software. Alternatively, you could send a “Get Errors” serial command.

It looks like your Arduino code is set up to allow a sequenceID value of 0 to 9; however, if you send the “Restart Script at Subroutine” command with a sequenceID higher than 7, you will receive an error since the subroutines that correspond to those IDs end with a RETURN command.

By the way, you would probably be better off using QUIT commands to close out your subroutines instead of using a “GOTO” command to loop a delay command like that.

Brandon

Hi brandon. Thanks for your reply. I found what was wrong. …it’s not the code but the conection…I was using the digital ground pin on the arduino instead of power ground for the tx rx. The reason of the goto no stop is to avoid the robot to be power less when no script is active its a humanoid robot with 22 dof so it needs to be powered all the time to avoid falling. I’ll remove those return at the end of sequences.

All of the ground pins on the Arduino boards are connected internally, so there should be no difference between which one you connect to.

Please note that using the QUIT command does not turn off the servo channels that are currently active. It just stops the script from running; all servo channels will continue outputting their last target position.

Also, you should not remove the RETURN command from your ID 8 and 9 sequences subroutines (frame_0..23 and frame_0..6_11). Those are part of the script generated by the Sequencer. You should not be using the Restart Script at Subroutine to start at one of those two subroutines as they will not function by themselves. They need a list of target positions on the stack before they are called or else it will result in an error.

Brandon

there is no sequence 8 and 9…

Sorry, that was a typo; I was referring to the 8th and 9th subroutine in your script (not sequence). The script you posted has over 50 subroutines. When you use the Sequence tab in the Maestro Control Center to copy your sequences to the Script tab, it does so by placing them in their own subroutines. Additional subroutines are created to handle the frames from each sequence.

For example, as your script is written above, if you send the Restart Script at Subroutine command with a subroutine number of 0 it will start at your subroutine named “Abonjour” (the first one defined in the script). If you sent it with a subroutine number of 8, it will start at your subroutine named “frame_0…23”.

Brandon

OK lol now I understand :slight_smile: thanks :slight_smile: