Hi,
my name is Guenter and my project is to control the Maestro12 by a µC currently an Arduino Uno. I have 3 figures in a RC model which are animated by the maestro. I have stored the script at the maestro iself. However, when driving left the driver figur shall also look to the left. Same when driving right. The Arduino monitors some I/Os and shall send a stop script command to the UART of the maestro and a restart script command when the I/Os are high.
For introduction I tested the examples in the Pololu Arduino library and everything works fine. However, when using my own C file the restart script command doe not work properly. The script hangs in the first command of the script.
Here the script at the maestro:
### Sequence subroutines: ###
goto main_loop
# Sequence 0
sub Sequence_0
1000 6000 6000 6000 6000 6000 6000
0 0 0 0 0 0 frame_0..11 # Frame 0
1500 7224 7244 5169 5984 6895 frame_0..3_5 # Frame 1
1200 6507 6294 5538 6526 frame_0..2_5 # Frame 2
1500 6022 6274 frame_0_3 # Frame 3
1000 6022 5925 6022 frame_1_2_5 # Frame 4
return
# Sequence 1
sub Sequence_1
#1000 6000 6000 6000 6000 6000 6000
#0 0 0 0 0 0 frame_0..11 # Frame 0
1500 6022 5925 6022 5984 6895 frame_0..3_5 # Frame 1
1200 6507 6294 5538 6526 frame_0..2_5 # Frame 2
1500 6022 6274 frame_0_3 # Frame 3
1000 6022 5925 6022 frame_1_2_5 # Frame 4
2000 5169 5053 5945 frame_0_2_3 # Frame 5
1500 5460 5538 6740 frame_0_2_5 # Frame 6
1500 5984 6468 frame_0_5 # Frame 7
1200 5344 6119 frame_0_1 # Frame 8
1500 5906 5964 5673 6546 frame_1..3_5 # Frame 9
1000 5984 6061 5324 6526 5984 frame_0..3_5 # Frame 10
1500 5945 5945 frame_2_3 # Frame 11
1200 5790 5712 frame_0_5 # Frame 12
1500 6681 frame_5 # Frame 13
1500 6410 6449 5518 frame_0..2 # Frame 14
2000 6022 6216 4665 frame_0..2 # Frame 15
1200 6507 frame_0 # Frame 16
1500 5363 5460 6507 frame_0_2_3 # Frame 17
1500 5945 6158 4917 6546 frame_0..3 # Frame 18
1500 6003 6003 6236 frame_2_3_5 # Frame 19
1500 5867 frame_5 # Frame 20
1500 6139 6468 frame_0_5 # Frame 21
1500 5053 5189 6565 frame_0_2_5 # Frame 22
1500 5945 5441 6875 frame_0_2_5 # Frame 23
1200 6255 5111 7127 frame_0_2_5 # Frame 24
1800 6139 6177 5402 6623 frame_0..3 # Frame 25
1500 5635 6546 frame_0_5 # Frame 26
1500 5906 6022 5984 frame_0_2_3 # Frame 27
1500 6080 6003 frame_0_5 # Frame 28
return
sub frame_0..11
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..3_5
5 servo
3 servo
2 servo
1 servo
0 servo
delay
return
sub frame_0..2_5
5 servo
2 servo
1 servo
0 servo
delay
return
sub frame_0_3
3 servo
0 servo
delay
return
sub frame_1_2_5
5 servo
2 servo
1 servo
delay
return
sub frame_0_2_3
3 servo
2 servo
0 servo
delay
return
sub frame_0_2_5
5 servo
2 servo
0 servo
delay
return
sub frame_0_5
5 servo
0 servo
delay
return
sub frame_0_1
1 servo
0 servo
delay
return
sub frame_1..3_5
5 servo
3 servo
2 servo
1 servo
delay
return
sub frame_2_3
3 servo
2 servo
delay
return
sub frame_5
5 servo
delay
return
sub frame_0..2
2 servo
1 servo
0 servo
delay
return
sub frame_0
0 servo
delay
return
sub frame_0..3
3 servo
2 servo
1 servo
0 servo
delay
return
sub frame_2_3_5
5 servo
3 servo
2 servo
delay
return
main_loop:
10 0 speed
sequence_0
sub start
begin
1500 6022 5925 6022 5984 6895 frame_0..3_5 # Frame 1
1200 6507 6294 5538 6526 frame_0..2_5 # Frame 2
1500 6022 6274 frame_0_3 # Frame 3
1000 6022 5925 6022 frame_1_2_5 # Frame 4
2000 5169 5053 5945 frame_0_2_3 # Frame 5
1500 5460 5538 6740 frame_0_2_5 # Frame 6
1500 5984 6468 frame_0_5 # Frame 7
1200 5344 6119 frame_0_1 # Frame 8
1500 5906 5964 5673 6546 frame_1..3_5 # Frame 9
1000 5984 6061 5324 6526 5984 frame_0..3_5 # Frame 10
repeat
Below is the Arduino C-file:
#include <PololuMaestro.h>
#ifdef SERIAL_PORT_HARDWARE_OPEN
#define maestroSerial SERIAL_PORT_HARDWARE_OPEN
#else
#include <SoftwareSerial.h>
SoftwareSerial maestroSerial(10, 11); // RX, TX
#endif
int LinksPin = 6;
int RechtsPin = 7;
int ledPin = 13;
int OLED = 5;
int Mon =4;
int Links;
int Rechts;
int InfoSys;
//MicroMaestro maestro(maestroSerial);
MiniMaestro maestro(maestroSerial);
void setup(){
maestroSerial.begin(9600);
pinMode(LinksPin, INPUT_PULLUP);
pinMode(RechtsPin, INPUT_PULLUP);
pinMode(ledPin, OUTPUT);
pinMode(OLED, OUTPUT); //Pin 5
pinMode(Mon, INPUT_PULLUP); //Pin 4
}
void loop(){
Links=digitalRead(LinksPin);
Rechts=digitalRead(RechtsPin);
InfoSys=digitalRead(Mon);
if (Links == 0){
maestro.stopScript();
uint8_t ScriptStatus = maestro.getScriptStatus();
if (ScriptStatus==1) {
delay(50);
maestro.setSpeed(0,20);
delay(50);
maestro.setAcceleration(0,20);
delay(50);
maestro.setTarget(0, 8000);
delay(1000);
}
digitalWrite(ledPin,1);
}
else if (Rechts == 0) {
maestro.stopScript();
uint8_t ScriptStatus = maestro.getScriptStatus();
if (ScriptStatus==1) {
delay(50);
maestro.setSpeed(0,20);
delay(50);
maestro.setAcceleration(0,20);
delay(50);
maestro.setTarget(0, 4000);
delay(1000);
}
digitalWrite(ledPin,1);
}
else if (Links==1 and Rechts==1){
uint8_t ScriptStatus = maestro.getScriptStatus();
if (ScriptStatus==1) {
maestro.restartScript(12);
delay(50);
}
digitalWrite(ledPin,0);
}
if (InfoSys==1) {
digitalWrite(OLED,1);
delay(50);
}
else {
digitalWrite(OLED,0);
delay(50);
}
}