How to connect pololuQik 2s12v10 motor interface with arduino mega 2560

Is there any sample code for connecting the PololuQik 2s12v10 with Arduino Mega and drive the motor into forward direction, by without using the demo mode. can anyone help me to connect the serial pins and interface PololuQik 2s12v10 with Arduino mega just only to drive a motor in forward direction.

Hello.

The connections between your Arduino and the Qik 2s12v10 will generally depend on your code. If you use our Qik2s12v10Demo.ino example code from the Qik Arduino library, you would connect pin 2 on the Arduino Mega to TX on the driver, pin 3 to RX, pin 4 to RESET, and ground to ground (as described in the comments of the code).

That demo code ramps each motor up and down in each direction, so you can use that as a starting point if you only want to drive the motor forward.

Brandon

Thank you for the clarification, when I executed the demo code it was working and then I changed the code by removing the reverse direction from the code but the motor direction was still unchanged, that is forward, break, and reverse direction. Any clarification on how I suppose to control the motor in forward, break and without reversing, That would be helpful for my agricultural project, which is by controlling the motor to move forward in curtain distance, stop, drop seeds for a few seconds then move forward.

Regards

Justin

To clarify, you can set the motor speeds using the qik.setM0Speed() and qik.setM1Speed() functions. A speed of 0 will stop the motor, a negative speed (up to -127 in the default 7-bit mode) will run the motor in reverse, and a positive speed (up to 127 in the default 7-bit mode) will run the motor forward. Ramping the speed up and down is optional but can result in smoother operation.

If your modified code is still running the motor in both directions, could you post it here? Also, it might sound silly, but could you double check that you actually uploaded that code to your Arduino?

Brandon

Thank you for your response. I have managed to solve the Demo mode from your response.
I have modified and still running the motor in both directions and have learned that serial communications will be ignored during Demo mode? Is it right?
I am working with motor (M0) and trying to ramp the motor from 0 to 127in 7-bit. I am trying to exit demo mode but it is not responding. I have removed the Demo mode jumper but the serial communication is still not going through. I have jumped Baud 1, which was according to the table given in the manual that it will set up baud rate to 115200 bps. The connections were as follows;

//Gnd to Gnd
//19 = RX1 of the Arduino Mega to TX of Driver
//18 = TX1 of the Arduino Mega to RX of Driver
//4 = Reset but was left disconnected

Attached is the code I am using.

#include <PololuQik.h>

// create a PololuQik object
PololuQik2s12v10 qik(19, 18, 4);

void setup() {
// initialize the PololuQik object with the desired baud rate
qik.begin(115200);
// send a command to exit demo mode
qik.init(0xAA);
// send the "Exit Safe Start" command to the motor driver
//qik.init(0x83);
}

void loop() {
// set motor 1 to full speed forward
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);
}
}

}

Regards

Justin

.

It looks like you are using the init() function incorrectly in your setup(). The argument of that function should be the baud rate you want to use (not some arbitrary byte you want to send). So, it should also be used instead of begin(). I recommend keeping it as simple as possible and removing stuff like the current reading until you get it working. For example, could you try the following code, which should ramp the motor up to full speed, then continue running it at full speed indefinitely?

#include <SoftwareSerial.h>
#include <PololuQik.h>

PololuQik2s12v10 qik(19, 18, 4);

void setup() {
  qik.init(115200);
}

void loop() {
  for (int i = 0; i <= 127; i++)
  {
    qik.setM0Speed(i);
    delay(5);
  }
  while(1);
}

That code should work with the connections you described, and it should work with either no baud rate jumpers or only the BAUD1 jumper installed. The demo jumper should be left off. Also, please note that you will need to power cycle the Qik whenever you change the BAUD jumper settings.

If that code does not function how I described, could you post pictures of your setup that show all of your connections?

Brandon

From the code you provided, I tried to connect it using the same configuration as before, without and with the Baud 1 jumper. With Baud 1 jumper on, the yellow (heart beat) light turns on in 2 flash intervals. However, it still did not ramp the motor as described. Before uploading, I disconnect both serial communication (RX & TX ) pins. Attached is a figure showing the following connections:

Arduino Qik

It looks like you are missing the connection from pin 4 on the Arduino to the reset pin on the Qik. Also, you have the “Enable-CRC” jumper installed, so that will prevent the communication from working unless you also send a CRC error-checking byte at the end of the command packets you send to the Qik.

Could you try adding that missing connection and removing all of the jumpers (for simplicity) to see if that changes anything?

Brandon