Bot Board II serial connection resetting

Hello all

I am trying to get the BotBoardII to connect to my laptop via serial. Programming works well and I can send values back and forward in basic micro studio and the included applications.

However whenever I try to access the board via C++ under linux, it resets after a loop has been performed:

BotBoardII pseudocode:

print X main print y ask for readings listen for readings perform actions goto main

C++ code:

while(1){ listen for messages print messages if reading asked for, send reply }

Now I expect to get:

x
y
Please send Value 1
Send Value 1
Please send Value 2
Send Value 2

y
Please send Value 1
Send Value 1
Please send Value 2
Send Value 2

etc…

but instead I get:

x
y
Please send Value 1
Send Value 1
Please send Value 2
Send Value 2
x <------------------------------------------
y
Please send Value 1
Send Value 1
Please send Value 2
Send Value 2

which implies the board is constantly resetting

I suspected this is a problem with the DTR line (I had problems in the past). I have now severed the DTR pin from my cables, but this has caused the rest problem (with the DTR line, I could neither read nor write to BotBoardII)

Any help would be wonderful. I have been stuck with this problem since January, and I am now completely confused, frustrated and lost.

Thanks in advance

TPWT

It is hard to know with the information you mentioned, could be several things including:

  1. DTR line as you mentioned - However you say you have disconnected the DTR? Note with all programs I use on the PC it will cause the BB2 (actually the BAP28 on the BB2) to reset. That is why in some of my VB apps, I connect and disconnect at the beginning to get it over with… If it were me with this problem I would hook up my logic analyzer to the ATN line going into BAP and see if the level keeps changing…

  2. Power to the BB2. Don’t know how you have it powered, but if the power voltage gets too low, the processor will reset

  3. Bug in your code. Could be where the code goes or could be reset. I often put a sound statement or a specific serout to s_out at the start to let me know the program reset. But can not give much help here without seeing the code.

Kurt

Hi Kurt

For me it is a repetitive resetting. In the Example I gave above it keeps outputting ‘x’ signifing that it is not looping around the min statement, but is in fact resetting completely each time.

BB2 Code (Excerpt):

;SSC-32 -> H3 engine
serout s_out,i9600,"X", 13]
gosub H3Init
;--------------------------------------------------------------------
;-------------Main loop
main

serout s_out,i9600,"Y", 13]

serout s_out,i9600,"R", 13]

serout s_out,i9600,"A",13]
serin s_in,i9600,[sdec DualShock(3)]
serout s_out,i9600,"C",13]
serin s_in,i9600,[sdec DualShock(4)]
serout s_out,i9600,"F",13]
serin s_in,i9600,[sdec DualShock(5)]
serout s_out,i9600,"G",13]
serin s_in,i9600,[sdec DualShock(6)]

serout s_out,i9600,"I",13]
serin s_in,i9600,[sdec HeadX]

serout s_out,i9600,"J",13]
serin s_in,i9600,[sdec LMandibleX]
serout s_out,i9600,"K",13]
serin s_in,i9600,[sdec LMandibleY]
serout s_out,i9600,"L",13]
serin s_in,i9600,[sdec RMandibleX]
serout s_out,i9600,"M",13]
serin s_in,i9600,[sdec RMandibleY]

C++ Code:[code]

#include
#include <SerialStream.h>
using namespace LibSerial;
using namespace std;

#include <stdio.h>
#include <math.h>

int main() {

// Create a SerialStream instance.
SerialStream my_serial_stream ;

// Open the serial port for communication.
my_serial_stream.Open( “/dev/ttyUSB0” );

cout << “Setup Stream” << std::endl;

// The various available baud rates are defined in SerialStreamBuf class.
// This is to be changed soon. All serial port settings will be placed in
// in the SerialPort class.
//
my_serial_stream.SetBaudRate( SerialStreamBuf::BAUD_9600 ) ;

// Use 8 bit wide characters.
//
my_serial_stream.SetCharSize( SerialStreamBuf::CHAR_SIZE_8 ) ;

// Use one stop bit.
//
my_serial_stream.SetNumOfStopBits(1) ;

// Use no parity during serial communication.
//
my_serial_stream.SetParity( SerialStreamBuf::PARITY_NONE ) ;

// Use hardware flow-control.
//
my_serial_stream.SetFlowControl( SerialStreamBuf::FLOW_CONTROL_NONE ) ;

cout << “Serial Stream Initialised” << std::endl;

if(my_serial_stream.good()){
std::cerr << "Serial Port is Peachy. " << std::endl;
}

if(!my_serial_stream.good()){
std::cerr << "Serial Port is Fucked. " << std::endl;
}

//const int BUFFER_SIZE=512;
char Command[1];
char input = ‘A’;

while(1){

   cout << "Read" << endl;

           my_serial_stream >> Command;
           //my_serial_stream.read(Command,BUFFER_SIZE);
           //std::cout << my_serial_stream << std::endl;
           std::cout << Command << std::endl;

// cin >> input;

// if (input==‘A’){
if (*Command==‘R’){ //Ready - -
cout << “Transmit” << endl;
// my_serial_stream << “1” << char(13);
cout << “Transmited” << endl;
}

   if (*Command=='A'){                                                     //DS3           A       1

cout << “Transmit” << endl;
my_serial_stream << “0” << char(13);
cout << “Transmited” << endl;
}

   if (*Command=='C'){                                                     //DS4           C       2

cout << “Transmit” << endl;
my_serial_stream << “0” << char(13);
cout << “Transmited” << endl;
}

   if (*Command=='F'){                                                     //DS5           F       3

cout << “Transmit” << endl;
my_serial_stream << “0” << char(13);
cout << “Transmited” << endl;
}

   if (*Command=='G'){                                                     //DS6           G       4

cout << “Transmit” << endl;
my_serial_stream << “0” << char(13);
cout << “Transmited” << endl;
}

   if (*Command=='I'){                                                     //HeadX         I       5

cout << “Transmit” << endl;
my_serial_stream << “15” << char(13);
cout << “Transmited” << endl;
}

   if (*Command=='J'){                                                     //LMX           J       6

cout << “Transmit” << endl;
my_serial_stream << “15” << char(13);
cout << “Transmited” << endl;
}

   if (*Command=='K'){                                                     //LMY           K       7

cout << “Transmit” << endl;
my_serial_stream << “-15” << char(13);
cout << “Transmited” << endl;
}

   if (*Command=='L'){                                                     //RMX           L       8

cout << “Transmit” << endl;
my_serial_stream << “15” << char(13);
cout << “Transmited” << endl;
}

   if (*Command=='M'){                                                     //RMY           M       9

cout << “Transmit” << endl;
my_serial_stream << “0” << char(13);
cout << “Transmited” << endl;
}

}
return 0;
}
[/code]

Is it a good idea to just apply a voltage directly to the pins? ie if the DTR is severed, and then I drop the voltage to -3V by adding a cell? Or will that just add more problems?