Qik 2s9v1 red LED on

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.

Demo mode is working fine though.

Hello.

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:

Brandon

Thanks for the response.
Here’s the code:

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;}

How it’s compiled:

pi@raspberrypi:~/wiringPi/examples $ g++ -Wall -o tcserver tcserver.c -lrt -lwiringPi -lpthread

The result (which returns immediately):

pi@raspberrypi:~/wiringPi/examples $ sudo ./tcserver
Failed to set timeout on Qik motor controller: -1 (0), Success

Here’s the connection - Note that the jumper is in the fixed-baud position:

Hello.

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.

–David

Here’s the output:

8250.nr_uarts=1 dma.dmachans=0x7f35 bcm2708_fb.fbwidth=640 bcm2708_fb.fbheight=480 bcm2709.boardrev=0xa02082 bcm2709.serial=0x8b583c3f smsc95xx.macaddr=B8:27:EB:58:3C:3F bcm2708_fb.fbswap=1 bcm2709.uart_clock=48000000 vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000 dwc_otg.lpm_enable=0 console=ttyS0,115200 console=tty1 root=/dev/mmcblk0p7 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

I’m running the latest version of raspbian. Here’s the output of uname -a:

Linux raspberrypi 4.4.13-v7+ #894 SMP Mon Jun 13 13:13:27 BST 2016 armv7l GNU/Linux

Sorry for the formatting in the previous response. serialPutchar is actually on a separate line.

Thanks for all your response so far!

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.

–David

Thanks for the link.

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.

Could my 2s9v1 be a defective unit?

Hello.

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:

#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <wiringSerial.h>

int main(int argc, char ** argv)
{
    int fd = serialOpen("/dev/ttyAMA0", 38400);
    serialFlush(fd);

    serialPutchar(fd, 132);
    serialPutchar(fd, 42);

    int result;
    result = serialGetchar(fd);
    printf("serialGetchar: %d, %d, %s\n", result, errno, strerror(errno));
    result = serialGetchar(fd);
    printf("serialGetchar: %d, %d, %s\n", result, errno, strerror(errno));

    serialClose(fd);
    return 0;
}

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.

–David

Thanks for the reply.

Here are the results:

The first test took about 18 seconds to complete. The second test returned immediately.

Thanks David.

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!

I am glad that you were able to get everything working. Your results from the loopback test are what I would expect.

–David