Hi team, I’m testing some simple arduino mega code to call scripts on the miastro 24. I can trigger the script no problem but when I call any function like getScriptStatus or getMovingState or even getError during the script the board goes into error state and gets a stack overflow/underflow error 0x0800.
Please help, is there a problem in my pololu script? or arduino code? Thanks for any help!!
Here is the code starting with pololu:
### Sequence subroutines: ###
#master sequence test script 2 servos
begin
#Sequence_0
#Sequence_1
repeat
# Sequence 0
sub Sequence_0
500 6000 6000 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0 frame_0..23 # Frame 0
500 8000 frame_0 # Frame 1
500 3968 frame_1 # Frame 2
500 5944 frame_1 # Frame 3
500 5846 frame_0 # Frame 4
500 3968 7921 frame_0_1 # Frame 5
return
# Sequence 1
sub Sequence_1
500 3968 7921 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0 frame_0..23 # Frame 0
500 5925 frame_1 # Frame 1
500 5905 frame_0 # Frame 2
500 3968 frame_0 # Frame 3
500 6042 frame_0 # Frame 4
return
# Sequence 2
sub Sequence_2
500 8000 3968 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0 frame_0..23 # Frame 0
500 8000 frame_1 # Frame 1
500 7197 frame_1 # Frame 2
500 7902 frame_1 # Frame 3
500 3968 frame_0 # Frame 4
500 5494 frame_0 # Frame 5
500 6062 frame_1 # Frame 6
return
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
0 servo
delay
return
sub frame_1
1 servo
delay
return
sub frame_0_1
1 servo
0 servo
delay
return
→ Begin Arduino Code
#include <PololuMaestro.h>
#include <SoftwareSerial.h>
SoftwareSerial maestroSerial(19, 18);
MiniMaestro maestro(maestroSerial);
void setup()
{
maestroSerial.begin(9600);
Serial.begin(115200);
Serial.println("Test Maestro");
maestro.goHome();
Serial.println("went home");
}
void loop()
{
uint8_t scriptstatus = 0;
uint8_t servostatus = 0;
uint8_t errorstate = 0;
Serial.println("start script 0");
maestro.restartScript(0);
//servostatus = maestro.getMovingState();
//Serial.print("Servo Status");Serial.println(servostatus);
scriptstatus = maestro.getScriptStatus();
errorstate = maestro.getErrors();
Serial.print("script Status");Serial.println(scriptstatus);
Serial.print("error");Serial.println(errorstate);
delay(4000);
// Stop the running script.
maestro.stopScript();
Serial.println("Stop");
}