Hi
I have strange problem, and I hope I am just overlooking something simple…
I have an arduino based remote control set to call sequences on a micro maestro 12ch.
The maestro controls 6 servos that animate a tortoise for a theatrical prop.
If I wire the rx tx lines direct from the arduino to the maestro… no problem and all works as needed.
I can call any of the maestro sequences and feedback is received and displayed on an LCD connected to the arduino.
Now if I send the serial via the xbee link… nothing… the xbees will connect briefly then the arduino freezes and the watchdog kicks in and resets the arduino.
The xbee link is has been tested multiple times and is good… and this is what perplexes me.
If I then connect the SAME arduino remote via the SAME xbee link with all the SAME power conections to ANOTHER 6ch micro maestro with a simplified script… NO PROBLEM All talking an working as it should.
I have set both maestros with identical serial connections.
I have also simplified the arduno script as much as I can.
Please all comments graciously received…I am pulling my hair out!!
[code]# when the aestro script is not doing anything else,
this loop will listen for button presses. When a button
is pressed it runs the corresponding sequence.
sub main
begin
buttonA if eat endif
buttonB if walk endif
buttonC if rest endif
buttonD if look endif
buttonE if eat endif
repeat
sub buttonA
7 get_position 500 less_than
return
sub buttonB
8 get_position 500 less_than
return
sub buttonC
9 get_position 500 less_than
return
sub buttonD
10 get_position 500 less_than
return
sub buttonE
11 get_position 500 less_than
return
Sequence subroutines:
eat
sub eat
500 0 8064 8192 8384 8212 9664
6944 frame_0…6 # rest
500 6464 6848 frame_2_3 # frbl
500 9073 10240 frame_1_4 # flbr
1000 2176 frame_5 # head out
500 8925 6573 6915 10090 frame_1…4 # Frame 18
600 9073 6464 6848 10240 9216 frame_1…4_6 # head left
500 4672 frame_6 # head right
2000 2866 5091 frame_5_6 # eat
2000 3484 4738 frame_5_6 # eat
500 8472 6807 frame_1_2 # Frame 16
2000 9073 6464 2575 5157 frame_1_2_5_6 # eat
500 8725 7012 9385 frame_1_3_4 # Frame 17
2000 9073 6848 10240 3266 5466 frame_1_3…6 # eat
2000 2176 4672 frame_5_6 # eat
500 9216 frame_6 # head left
500 9664 frame_5 # head in
500 6944 frame_6 # head right
500 8384 8192 frame_3_4 # back leg sit
500 8064 8192 frame_1_2 # front leg sit
main
look
sub look
500 0 8064 8192 8384 8192 9664
6944 frame_0…6 # rest
500 9238 6464 frame_1_2 # front legs
1600 2176 frame_5 # head out
1500 4672 frame_6 # head right
1200 2793 9216 frame_5_6 # head left
1100 3157 4672 frame_5_6 # head right
1200 2721 9216 frame_5_6 # head left
900 4066 4672 frame_5_6 # head right
700 6966 frame_6 # centre
700 9664 frame_5 # head in
500 8064 8192 frame_1_2 # rest
main
rest
sub rest
500 0 8064 8192 8384 8192 9664
6944 frame_0…6 # rest
main
walk
sub walk
500 0 8064 8192 8384 8192 9664
6944 frame_0…6 # rest
900 9856 6464 6848 10240 frame_1…4 # stand
100 8707 7453 frame_1_2 # Frame 2
800 9856 6464 7548 8530 frame_1…4 # Frame 3
200 6848 9752 frame_3_4 # Frame 4
1000 8629 7437 frame_1_2 # Frame 5
1000 9856 6464 7630 8530 frame_1…4 # Frame 6
1000 6848 10240 frame_3_4 # Frame 7
1000 8472 7537 frame_1_2 # Frame 8
1000 7727 8947 frame_3_4 # Frame 9
1000 9856 6464 frame_1_2 # Frame 10
1000 8384 8192 frame_3_4 # Frame 11
1000 8064 8192 frame_1_2 # Frame 12
main
sub frame_0…6
6 servo
5 servo
4 servo
3 servo
2 servo
1 servo
0 servo
delay
return
sub frame_2_3
3 servo
2 servo
delay
return
sub frame_1_4
4 servo
1 servo
delay
return
sub frame_5
5 servo
delay
return
sub frame_1…4
4 servo
3 servo
2 servo
1 servo
delay
return
sub frame_1…4_6
6 servo
4 servo
3 servo
2 servo
1 servo
delay
return
sub frame_6
6 servo
delay
return
sub frame_5_6
6 servo
5 servo
delay
return
sub frame_1_2
2 servo
1 servo
delay
return
sub frame_1_2_5_6
6 servo
5 servo
2 servo
1 servo
delay
return
sub frame_1_3_4
4 servo
3 servo
1 servo
delay
return
sub frame_1_3…6
6 servo
5 servo
4 servo
3 servo
1 servo
delay
return
sub frame_3_4
4 servo
3 servo
delay
return
[/code]
[code]
#include <PololuMaestro.h>
#include <LiquidCrystal.h>
#include <avr/wdt.h>
#ifdef SERIAL_PORT_HARDWARE_OPEN
#define maestroSerial SERIAL_PORT_HARDWARE_OPEN
#else
#include <SoftwareSerial.h>
SoftwareSerial maestroSerial(2, 3); // RX, TX
#endif
LiquidCrystal lcd(8, 9, 4, 5, 6, 7); // select the pins used on the LCD panel
// define some values used by the panel and buttons
int lcd_key = 0;
int adc_key_in = 0;
#define btnRIGHT 0
#define btnUP 1
#define btnDOWN 2
#define btnLEFT 3
#define btnSELECT 4
#define btnNONE 5
int scriptStatus = 0; // variable for reading if the maestro script is running
int servoPosition = 0; // variable for reading servo position
int read_LCD_buttons(){ // read the buttons
adc_key_in = analogRead(0); // read the value from the sensor
if (adc_key_in > 1000) return btnNONE;
if (adc_key_in < 50) return btnRIGHT;
if (adc_key_in < 250) return btnUP;
if (adc_key_in < 450) return btnDOWN;
if (adc_key_in < 650) return btnLEFT;
if (adc_key_in < 850) return btnSELECT;
return btnNONE; // when all others fail, return this.
}
// create a Maestro object using the serial port.
MiniMaestro maestro(maestroSerial);
void setup(){
lcd.begin(16, 2); // start the lcd library
lcd.setCursor(0,0); // set the LCD cursor position
lcd.print(“Arcadia Tortoise”); // print a simple message on the LCD
delay(1000);
lcd.setCursor(0,1);
lcd.print("-- CONNECTING --");
delay(1000);
lcd.clear();
// Set the serial baud rate.
Serial.begin(9600);
delay(1000);
maestroSerial.begin(9600);
delay(1000);
wdt_enable(WDTO_2S); // enable watchdog timer at 2 seconds
}
void loop(){
wdt_reset();
scriptStatus = maestro.getScriptStatus();
delay(100);
if (scriptStatus == 0){
lcd.setCursor(0,0);
lcd.print("Tortoise READY “);
}else{
delay(100);
lcd.setCursor(0,0);
lcd.print(“Arcadia Tortoise”);
lcd.setCursor(0,1);
lcd.print(” RED to RESET ");
}
lcd_key = read_LCD_buttons(); // read the buttons
switch (lcd_key){ // depending on which button was pushed, we perform an action
case btnSELECT:{
maestro.restartScript(0);
break;
}
case btnLEFT:{
maestro.restartScript(6);
delay(10);
lcd.setCursor(0,1);
lcd.print("... feed me ...");
wdt_reset();
delay(1800);
lcd.clear();
break;
}
case btnRIGHT:{
maestro.restartScript(6);
delay(10);
lcd.setCursor(0,1);
lcd.print("... head in ...");
wdt_reset();
delay(1800);
lcd.clear();
break;
}
case btnUP:{
maestro.restartScript(8);
delay(10);
lcd.setCursor(0,1);
lcd.print("... head out ...");
wdt_reset();
delay(1800);
lcd.clear();
break;
}
case btnDOWN:{
maestro.restartScript(9);
delay(10);
lcd.setCursor(0,1);
lcd.print("... sit ...");
wdt_reset();
delay(1800);
lcd.clear();
break;
}
/*case btnNONE:{
lcd.print("NONE "); // No action will show "None" on the screen
break;
}*/
}
}[/code]