Servo Controller written in C
Posted: Tue Feb 05, 2008 7:13 pm
Hi,
I need to write a program to control a servo controller in our Remotely Operated Vehicle (ROV) for a regional, and possibly an international competition, however I cannot find enough information online on how to communicate with a Paralax servo which has a BASIC STAMP PIC in C. My assumption was simply to use open() giving the path to the device file (which was something like /dev/tty.usbserial-1b3) and then write to that device file the BASIC syntax command to move a servo connected to that servo controller, but this doesn't seem to work. The LED light on the servo controller flashes indicating that there is something sent to it but nothing happens. The manual says that the baud rate is 2400 for the controller but when I read what the baud rate is when first connected it is set to 9600 - which is weird but I just change it to 2400 using cfsetospeed() and cfsetispeed. Also it says the servo is non-parity and 8bit width plus it uses a carriage return to notify EOL. I think I set all of it in the termios structure using inclusive or to set the settings. However, even after that it still just flashes and the servo doesn't move. I based this on a tutorial on how to communicate with a modem. Would anyone know what might be the problem. Should I just give-in and write the program in BASIC or is there a way to do it in C. I though it was as simple as sending the BASIC syntax to the controller. Please help. Thanks in advance.
Best regards,
Kenneth
I need to write a program to control a servo controller in our Remotely Operated Vehicle (ROV) for a regional, and possibly an international competition, however I cannot find enough information online on how to communicate with a Paralax servo which has a BASIC STAMP PIC in C. My assumption was simply to use open() giving the path to the device file (which was something like /dev/tty.usbserial-1b3) and then write to that device file the BASIC syntax command to move a servo connected to that servo controller, but this doesn't seem to work. The LED light on the servo controller flashes indicating that there is something sent to it but nothing happens. The manual says that the baud rate is 2400 for the controller but when I read what the baud rate is when first connected it is set to 9600 - which is weird but I just change it to 2400 using cfsetospeed() and cfsetispeed. Also it says the servo is non-parity and 8bit width plus it uses a carriage return to notify EOL. I think I set all of it in the termios structure using inclusive or to set the settings. However, even after that it still just flashes and the servo doesn't move. I based this on a tutorial on how to communicate with a modem. Would anyone know what might be the problem. Should I just give-in and write the program in BASIC or is there a way to do it in C. I though it was as simple as sending the BASIC syntax to the controller. Please help. Thanks in advance.
Best regards,
Kenneth