Hi,
I have one of your Micro Serial Servo Controllers but am having trouble
getting it to work.
I am using Pololu Mode with no jumper on the board.
When I power up the board the yellow LED comes on ok.
When I try to send data to the board, the red LED comes on and the green LED
flashes.
Even if I try to get the board to tell me the servo number settings.
This happens whatever baud rate I try and set.
e.g.
// Open the serial port.
g_hSerialPort = CreateFile (TEXT("COM1:"), // Pointer to the name of the
port
GENERIC_READ | GENERIC_WRITE, // Access (read/write) mode
FILE_SHARE_READ | FILE_SHARE_WRITE, // Share mode
NULL, // Pointer to the security attribute
OPEN_EXISTING,// How to open the serial port
0, // Port attributes
NULL); // Handle to port with attribute to copy
// If it fails to open the port, return FALSE.
if ( g_hSerialPort == INVALID_HANDLE_VALUE ) {
// Could not open the port.
MessageBox (g_hWnd, TEXT("Unable to open the port"), TEXT("Error"),
MB_OK);
dwError = GetLastError ();
return FALSE;
}
SerialPortDCB.DCBlength = sizeof (DCB);
// Get the default port setting information.
GetCommState (g_hSerialPort, &SerialPortDCB);
SerialPortDCB.BaudRate = 9600; // Current baud
SerialPortDCB.fBinary = TRUE; // Binary mode; no EOF check
SerialPortDCB.fParity = FALSE; // Enable parity checking.
SerialPortDCB.fOutxCtsFlow = FALSE; // No CTS output flow control
SerialPortDCB.fOutxDsrFlow = FALSE; // No DSR output flow control
SerialPortDCB.fDtrControl = DTR_CONTROL_DISABLE ; // DTR flow control type
SerialPortDCB.fDsrSensitivity = FALSE; // DSR sensitivity
SerialPortDCB.fTXContinueOnXoff = FALSE; // XOFF continues Tx
SerialPortDCB.fOutX = TRUE; // No XON/XOFF out flow control
SerialPortDCB.fInX = FALSE; // No XON/XOFF in flow control
SerialPortDCB.fErrorChar = FALSE; // Disable error replacement.
SerialPortDCB.fNull = FALSE; // Disable null stripping.
SerialPortDCB.fRtsControl = RTS_CONTROL_DISABLE; // RTS flow
control
SerialPortDCB.fAbortOnError = FALSE; // Do not abort reads/writes on
error.
SerialPortDCB.ByteSize = 8; // Number of bits/bytes, 4-8
SerialPortDCB.Parity = NOPARITY; // 0-4=no,odd,even,mark,space
SerialPortDCB.StopBits = ONESTOPBIT; // 0,1,2 = 1, 1.5, 2
// Configure the port according to the specifications of the DCB structure.
if (!SetCommState (g_hSerialPort, &SerialPortDCB)) {
// Could not create the read thread.
MessageBox (g_hWnd, TEXT("Unable to configure the serial port"),
TEXT("Error"), MB_OK);
dwError = GetLastError ();
return FALSE;
}
buff[0]=0x80;//start byte
buff[1]=0x02;//device id
buff[2]=16;//command number
WriteFile(g_hSerialPort, &buff, 3, &len, 0);
Please advise what I am doing wrong.
Thanks
Simon