I’m connecting my 2s9v1 to a raspberry pi, but as soon as the pi is powered on the red LED on the controller stays on. Sending 0x82 to the controller using wiringPi (serialGetchar) would return 255 which is not a valid return value. Tried it on raspberry Pi 2B and 3 and got the same result.
Can you post a complete simplified version of your code that demonstrates the problem? What is the exact command you use to run it, and what is the exact output it gives? How long does the code take to run? Also, it is hard to tell from your picture where the jumper on your Qik 2s9v1 is installed; can you clarify if the jumper is in the “Fixed-baud” or “Enable-CRC” position? You can reference this picture to double check:
int main(int argc , char *argv[]){ wiringPiSetupGpio();
int fd = serialOpen("/dev/ttyAMA0", 38400); if (fd == -1) { printf("Failed to open serial port: %d\n", errno); return -1; }
// set timeout to 262ms serialPutchar(fd, 0x84); serialPutchar(fd, 0x03); serialPutchar(fd, 0x01); serialPutchar(fd, 0x55); serialPutchar(fd, 0x2a);
delay(4);
int ch = serialGetchar(fd); if (ch != 0) { printf("Failed to set timeout on Qik motor controller: %d (%d), %s\n", ch, errno, strerror(errno)); }
serialClose(fd);
return 0;}
I am sorry you are having trouble using your Raspberry Pi with the Qik 2s9v1. Can you please run the following command and post the full output from it?
cat /proc/cmdline
What Linux distribution are you running on the Raspberry Pi?
Also, in the code you posted, the calls to serialPutchar are on a line that begins with //, so they are commented out. I suspect that might just be a problem with how you copied and pasted the program into your forum post, but I recommend checking your code to make sure that those parts are not commented out.
Based on the part that says console=ttyS0,115200, it looks like your Raspberry Pi is configured to use the UART as a console, which will interfere with using it to control the Qik. I recommend following the instructions from this blog post to get the UART working on your Raspberry Pi 3:
Please note that these instructions also involve disabling and Bluetooth and WiFi.
I followed the instructions in the blog post with my RPi3 but it doesn’t solve my issue. Knowing that there’re changes to UART in RPi3, I now use my RPi2 and I get the same result.
I also tried modifying /boot/cmdline.txt to remove “console=ttyAMA0,115200”.
I’m thinking the issue may not be related to UART because the red LED is on even if I don’t connect the TX/RX pins. The LED is on when it’s powered and stays on until I take the power away.
If one of your attempts to set the Qik’s serial timeout to 262 ms was successful, then that would explain why its red LED turns on whenever you apply power. If you do not send it any commands within 262 ms of turning it on the serial timeout error will happen, and the red LED will turn on.
I think it’s more likely that something is still wrong with your Raspberry Pi configuration. I recommend doing a simple loopback test to make sure that your Raspberry Pi’s UART is working. Here is some C code that sends two characters on the TX pin and then receives two characters on the RX pin:
You can compile the code above with a command like:
gcc -Wall -o loopback loopback.c -lwiringPi
Please disconnect everything from the Raspberry Pi’s RX and TX pins, run the code above, and let me know what the results are. After doing that, please connect the Raspberry Pi’s RX pin to its TX pin, and the run the code again, and let me know what the results are. Please let me know approximately how long it takes the program to run in both cases, and post the full output of the program.
The problem is like what you said - the Qik’s serial timeout is set to 262ms. Once I set it to 0, the red LED turned off and I’m able to program it now.
Thanks for all your support. This is my first time doing this kind of programming and I learnt quite a lot from this experience. This is an amazing community. Thanks again!