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?