Pololu Qik 2s12v10 12A 6-16V Dual Serial Motor Controller

Hello,

I just got the Qik 2s12v10 Dual Serial Motor controller and I am trying to use the Arduino Microcontroller to speak to it and I do not know how to. Does anyone have a code that I can use that works? Does anyone also know how I can connect it?. All I know is connecting the RX pins on motor controller to the TX pin of the Microcontroller, and also the TX pin on the motor controller to the RX pin on the Microcontroller. Please please can anyone help with this. All I want it to be able to make these motors move and I do not know how. PLEASE HELP!!!

Hello.

Have you read the user’s guide for the Qik 2s12v10? The guide explains what the controller pins are, how to connect it to a microcontroller, and documentation for the serial commands. If there is anything you don’t understand about these instructions, please let me know.

I recommend you use software serial to communicate with the motor controller, since the hardware serial lines on the Arduino are used for programming and debugging. Arduino has several software serial libraries that makes this easy to do. Also, there is a customer-written Arduino library for the smaller qik 2s9v1 that should provide you with a nice example of how to write an Arduino program to control the qik 2s12v10. The motor-driving commands from this library should work directly with the the qik 2s12v10 since those commands are the same as on the 2s9v1, but the rest of the commands are slightly different and you will probably need to implement them yourself using the qik library as a reference if you want to use them.

If you are still confused or find yourself getting stuck, post your code here along with a description of what you’re trying to do and what actually happens.

- Ben

I used this example code shown below

#include <CompactQik2s9v1.h>
#include <NewSoftSerial.h>

/*
	Important Note:
		The rxPin goes to the Qik's "TX" pin
		The txPin goes to the Qik's "RX" pin
*/
#define rxPin 3
#define txPin 4
#define rstPin 5

NewSoftSerial mySerial =  NewSoftSerial(rxPin, txPin);
CompactQik2s9v1 motor = CompactQik2s9v1(&mySerial,rstPin);

byte motorSelection;
byte motorSpeed;

void setup()  
{
  Serial.begin(9600);
  mySerial.begin(9600);
  motor.begin();
  motor.stopBothMotors();
}



void loop() 
{
  if ( Serial.available() > 0 )
  {
    motorSelection = Serial.read();
    switch(motorSelection)
    {
      case 0:
        motor.motor0Forward(getSpeedByte());
        break;
      case 1:
        motor.motor0Reverse(getSpeedByte());
        break;
      case 2:
        motor.motor1Forward(getSpeedByte());
        break;
      case 3:
        motor.motor1Reverse(getSpeedByte());
        break;        
      case 4:
        motor.motor0Coast();      
        break;
      case 5:
        motor.motor1Coast();
        break;
      case 6:
        motor.stopBothMotors();
        break;
      default:
        showHelp();
        break;
    }     
  }
}

byte getSpeedByte()
{
  return Serial.read();
}

void showHelp()
{
  Serial.println("Send 1 or 2 bytes: ");
  Serial.println("<motor selection> (<speed>)");
  Serial.println("motor selection choices:");
  Serial.println("0 - m0 forward");
  Serial.println("1 - m0 reverse");  
  Serial.println("2 - m1 forward");
  Serial.println("3 - m1 reverse");    
  Serial.println("4 - m0 coast (no speed byte)");
  Serial.println("5 - m1 coast (no speed byte)");
  Serial.println("6 - stop both (no speed byte)");
}

After I upload it and access the Serial monitor on Arduino compiler, I type in values that are meant to make it work…but i get a red LED come on signifying that there was an error. Firstly, isnt this code supposed to work? and what should I be doing differently?

I feel like you didn’t really read what I wrote in my first post. Some of your code will work and some will not; the library you are using is written for the qik 2s9v1, which is not the same product as the qik 2s12v10. You will have to modify the library code if you want access to all of the qik 2s12v10 functions. If you want to use this controller, you will have to invest some time in understanding how it works and how to use it. As a first step, you really should read the user’s guide. As a second step, you should look at the library code to see what it’s doing. As a third step, try writing a simple program to make the motors start moving. A program with a serial menu is not a simple program. For example:

#include <NewSoftSerial.h>

#define rxPin 3
#define txPin 4

NewSoftSerial mySerial = NewSoftSerial(rxPin, txPin);

void setup() 
{
  mySerial.begin(9600);
  mySerial.print(0xAA, BYTE);  // let qik learn the baud rate
  mySerial.print(0x88, BYTE);  // M0 forward command byte
  mySerial.print(0x7F, BYTE);  // M0 speed = 127 (full speed in 7-bit mode)
}

void loop()
{
}

Does this very basic program make motor 0 drive forward (you should be able to tell just from the motor indicator LEDs)?

The error could be the result of a number of things, but the LED behavior should help you narrow down on the problem. For example, if the qik is set to auto-detect baud mode, you need to transmit 0xAA as your first byte so that the device can learn the baud rate. If you transmit something else, the red LED will turn and the qik will remain in auto-baud detect mode waiting for an 0xAA. If the green LED is fading in and out evenly every 0.8 seconds, you aren’t making it out of the auto-baud detect phase and the controller is not receiving your commands. If the green LED is briefly flashing every 1.3 seconds, then a different error occurred, such as a badly formatted command, an incorrect command byte, or even a faulty serial signal. If you have access to a USB-to-serial adapter, you can try sending commands to the controller with our Serial Transmitter Utility.

- Ben

Hey,

I am new to programming embedded systems. I have the same setup as chinedu_ofo. I ran the code that Ben had posted and I am getting the 1.3 second LED flash. I was wondering if you could explain what is going when you wrote:

mySerial.print(0xAA, BYTE);

Does this mean you are sending the 0xAA byte that terminates the autodetect mode? Is mySeriel.print the way you transmit from the microcontroller to motor driver? Is there anyway I could test for a faulty serial signal?

Thank you for your help,

flynhwn

nvm i figured out what i was doing wrong. How would use two motors at once?

Hello.

Just send a motor speed command for motor 0 followed by a motor speed command for motor 1:

mySerial.print(0x88, BYTE);  // M0 forward command byte
mySerial.print(0x7F, BYTE);  // M0 speed = 127 (full speed in 7-bit mode)

mySerial.print(0x8E, BYTE);  // M1 reverse command byte
mySerial.print(63, BYTE);  // M0 speed = 63 (half speed in 7-bit mode)

- Ben