Two QIK 2s12v10 hooked to Arduino

We have two QIK 2s12v10’s hooked up to one Arduino (nano v 3.1) running 4 motors. I’m running Arduino IDE 1.4

The Readme for the Arduino library states github.com/pololu/qik-arduino/b … ME.textile [quote]“It uses the compact protocol, not the Pololu protocol, so it cannot be used to control multiple qiks daisy-chained together on the same serial line.”[/quote]

Ok… so we hooked them up on separate pins (6,7,8) and (9,10,11).

Now for some reason ALL calls to get information such as getFirmwareVersion() and getM0CurrentMilliamps() HANG.

This does NOT happen if my code only uses one controller board at a time but if I even only init the second controller board none of the functions that receive data works. Here is the slightly modified version of the demo code that shows it failing. I commented out getFirmawareVersion() because it hangs there but hangs at the first call to getM0CurrentMilliamps() in the for loop.

[code]
#include <SoftwareSerial.h>
#include <PololuQik.h>

PololuQik2s12v10 qik(6, 7, 8);
PololuQik2s12v10 right(9,10,11);

void setup()
{
Serial.begin(115200);
Serial.println(“qik 2s12v10 dual serial motor controller”);

qik.init();
right.init();

Serial.print("Firmware version: ");
// Serial.write(qik.getFirmwareVersion());
Serial.println();
}

void loop()
{
for (int i = 0; i <= 127; i++)
{
qik.setM0Speed(i);
if (abs(i) % 64 == 32)
{
Serial.print("M0 current: ");
Serial.println(qik.getM0CurrentMilliamps());
}
delay(5);
}

for (int i = 127; i >= -127; i–)
{
qik.setM0Speed(i);
if (abs(i) % 64 == 32)
{
Serial.print("M0 current: ");
Serial.println(qik.getM0CurrentMilliamps());
}
delay(5);
}

for (int i = -127; i <= 0; i++)
{
qik.setM0Speed(i);
if (abs(i) % 64 == 32)
{
Serial.print("M0 current: ");
Serial.println(qik.getM0CurrentMilliamps());
}
delay(5);
}

for (int i = 0; i <= 127; i++)
{
qik.setM1Speed(i);
if (abs(i) % 64 == 32)
{
Serial.print("M1 current: ");
Serial.println(qik.getM1CurrentMilliamps());
}
delay(5);
}

for (int i = 127; i >= -127; i–)
{
qik.setM1Speed(i);
if (abs(i) % 64 == 32)
{
Serial.print("M1 current: ");
Serial.println(qik.getM1CurrentMilliamps());
}
delay(5);
}

for (int i = -127; i <= 0; i++)
{
qik.setM1Speed(i);
if (abs(i) % 64 == 32)
{
Serial.print("M1 current: ");
Serial.println(qik.getM1CurrentMilliamps());
}
delay(5);
}
}[/code]

My ‘guess’ is that the problem is the SoftwareSerial library that has been in use since Arduino version 1.0. I’ve had a lot of problems with this library and its documented conflicts with the Servo library. Since the QIK library was last updated in May 2011 it was written prior to the new SoftwareSerial library was added into Arduino 1.0

Hi again.

Ok it appears that ONE problem is that the Pololu library needs to call the SoftwareSerial.listen() method.

Listen MUST BE CALLED when using multiple SoftwareSerial ports as per arduino.cc/en/Reference/SoftwareSerialListen

So for example the code for getFirmwareVersion() should be changed to look like the following:

char PololuQik::getFirmwareVersion() { listen(); // <-- added this write(QIK_GET_FIRMWARE_VERSION); while (available() < 1); return read(); }

Since PololuQik is derived from SoftwareSerial just call listen() directly.

The same must be done for all the other methods that perform a read such as getErrors(). We were getting errors with the boards and when we called getErrors(), they’d never return at all and the program hung.

Now errors do return when an error occurs but I often get all bits on which of course makes no sense. I have 6 of these motor controllers and I am seeing this on 4 of them so far. Have not tried it with the other two yet.

Hello, Dennis.

Thank you for the suggestion; we will look into updating the library. Do the qiks still raise errors if they are connected individually (and you only define one PololuQik2s12v10 object in your program)? If so, are the bits set in the error byte still the same? Does your modified getFirmwareVersion() function work correctly when multiple qiks are connected?

By the way, there’s a typo on the GitHub page: the release date should say 2012-05-07 (like it says in the Version History at the bottom), not 2011. Thanks for catching that too.

- Kevin