The part I am asking for help with is about serial communication from C/Linux.
After having gone the "try to control servo with GPIO -> too fuzzy with Debian/Raspbian / try Realtime Kernel and optimise C program -> still too fuzzy (20us is still too much)"-path and then finally admitting that one can not get really quality servo control by bitbanging for critical applications from Linux... I have bought a Pololu 207 servo controller board to do the time-critical stuff. I learned a lot while doing this, but for model RC planes I just wasn't satisfied with the precision.
So I am trying to talk to this module now via Pi's UART:
Pololu 207: http://www.pololu.com/catalog/product/207/resources
User guide: http://www.pololu.com/file/0J37/ssc03a_guide.pdf
Here is my wiring:
I have added the resistor for additional security although not really needed I think. I do only need Pi's Tx, Rx is not connected.
Power on, everything seems fine: yellow LED on the Pololu. Whenever I open the serial interface /dev/ttyAMA0, I get the LED signal 'red + fast green' from the Pololu 207, which shall mean 'Baudrate too high' according to the manual.
I open it in C via (pseudocode) (I peeked at the great wiringPi-library to see if I am completely of):
Code: Select all
fd = open("/dev/ttyAMA0", ...) tcgetattr(fd, &options) cfsetospeed(...) tcsetattr(...) [tcflush(...)] [ioctl(...)] close(fd)
The Pololu gives the error signal immediately after the 'open(...)'.
So I guess I shall set the baudrate before opening the device. This is where I am stuck. I need a file handle to get options (tcgetattr()) and set the baudrate with cfsetospeed().
I am not sure if my basic understanding of the UART is right, but I think it will start sending zeros and stopbits as soon as I open the device, but unfortunately it is by default at 115k Baud and the Polulu expects 10k-40k.
Could it also be that the signal interpretes 0 as 'high' which would be wrong for the Pololu?
The voltage of 3v3 is OK for the 'logic-level serial input', according to the manual.
Any help is appreciated.