I have two DC motors i am trying to run using the Qik 2s9v1 motor controller. I am running into problems getting the motors to work using the example code provided by pololu. I have the wiring correct and there is a good serial connection according to the green on board LED, but i don’t know where to go from here to get the motors running. any help would be appreciated.
this is the code I’m currently using:
[code]#include <PololuQik.h>
#ifndef PololuQik_h
#define PololuQik_h
#include <Arduino.h>
#include <SoftwareSerial.h>
// Commands
#define QIK_GET_FIRMWARE_VERSION 0x81
#define QIK_GET_ERROR_BYTE 0x82
#define QIK_GET_CONFIGURATION_PARAMETER 0x83
#define QIK_SET_CONFIGURATION_PARAMETER 0x84
#define QIK_MOTOR_M0_FORWARD 0x88
#define QIK_MOTOR_M0_FORWARD_8_BIT 0x89
#define QIK_MOTOR_M0_REVERSE 0x8A
#define QIK_MOTOR_M0_REVERSE_8_BIT 0x8B
#define QIK_MOTOR_M1_FORWARD 0x8C
#define QIK_MOTOR_M1_FORWARD_8_BIT 0x8D
#define QIK_MOTOR_M1_REVERSE 0x8E
#define QIK_MOTOR_M1_REVERSE_8_BIT 0x8F
// 2s9v1 only
#define QIK_2S9V1_MOTOR_M0_COAST 0x86
#define QIK_2S9V1_MOTOR_M1_COAST 0x87
/******** 2s12v10 only
#define QIK_2S12V10_MOTOR_M0_BRAKE 0x86
#define QIK_2S12V10_MOTOR_M1_BRAKE 0x87
#define QIK_2S12V10_GET_MOTOR_M0_CURRENT 0x90
#define QIK_2S12V10_GET_MOTOR_M1_CURRENT 0x91
#define QIK_2S12V10_GET_MOTOR_M0_SPEED 0x92
#define QIK_2S12V10_GET_MOTOR_M1_SPEED 0x93
*********/
// Configuration parameters
#define QIK_CONFIG_DEVICE_ID 0
#define QIK_CONFIG_PWM_PARAMETER 1
#define QIK_CONFIG_SHUT_DOWN_MOTORS_ON_ERROR 2
#define QIK_CONFIG_SERIAL_TIMEOUT 3
#define QIK_CONFIG_MOTOR_M0_ACCELERATION 4
#define QIK_CONFIG_MOTOR_M1_ACCELERATION 5
#define QIK_CONFIG_MOTOR_M0_BRAKE_DURATION 6
#define QIK_CONFIG_MOTOR_M1_BRAKE_DURATION 7
#define QIK_CONFIG_MOTOR_M0_CURRENT_LIMIT_DIV_2 8
#define QIK_CONFIG_MOTOR_M1_CURRENT_LIMIT_DIV_2 9
#define QIK_CONFIG_MOTOR_M0_CURRENT_LIMIT_RESPONSE 10
#define QIK_CONFIG_MOTOR_M1_CURRENT_LIMIT_RESPONSE 11
class PololuQik : public SoftwareSerial
{
public:
PololuQik(unsigned char receivePin, unsigned char transmitPin, unsigned char resetPin);
void init(long speed = 9600);
char getFirmwareVersion();
byte getErrors();
byte getConfigurationParameter(byte parameter);
byte setConfigurationParameter(byte parameter, byte value);
void setM0Speed(int speed);
void setM1Speed(int speed);
void setSpeeds(int m0Speed, int m1Speed);
protected:
unsigned char _resetPin;
};
class PololuQik2s9v1 : public PololuQik
{
public:
PololuQik2s9v1(unsigned char receivePin, unsigned char transmitPin, unsigned char resetPin) : PololuQik(receivePin, transmitPin, resetPin) {}
void setM0Coast();
void setM1Coast();
void setCoasts();
};
#endif
/*
Required connections between Arduino and qik 2s9v1:
Arduino qik 2s9v1
5V - VCC
GND - GND
Digital Pin 2 - TX
Digital Pin 3 - RX
Digital Pin 4 - RESET
*/
PololuQik2s9v1 qik(11, 12, 13);
void setup()
{
Serial.begin(115200);
Serial.println(“qik 2s9v1 dual serial motor controller”);
qik.init();
Serial.print("Firmware version: ");
Serial.write(qik.getFirmwareVersion());
Serial.println();
}
void loop()
{
for (int i = 0; i <= 127; i++)
{
qik.setM0Speed(i);
delay(5);
}
for (int i = 127; i >= -127; i–)
{
qik.setM0Speed(i);
delay(5);
}
for (int i = -127; i <= 0; i++)
{
qik.setM0Speed(i);
delay(5);
}
for (int i = 0; i <= 127; i++)
{
qik.setM1Speed(i);
delay(5);
}
for (int i = 127; i >= -127; i–)
{
qik.setM1Speed(i);
delay(5);
}
for (int i = -127; i <= 0; i++)
{
qik.setM1Speed(i);
delay(5);
}
} [/code]