PololuQik2s12v10 hangs Arduino

I have problems with getting configuration commands PololuQik2s12v10.
For example: calling getM1Speed ​​() causes hang sketch Arduino Mega 2560.

#define PololuTXPin 14
#define PololuRXPin 15
#define PololuRSTPin 16
PololuQik2s12v10 Pololuqik(PololuTXPin, PololuRXPin, PololuRSTPin);

Pololuqik.setM1Speed(Select_Gear_Start_Speed);
Serial.println(Pololuqik.getM1Speed()); <-- hang sketch

Without the use commands to getting configuration sketch works without problems.
I use last versions of libraries.
Help me PLZ.

Hello.

Could you post pictures and a diagram of your setup? Could you also post the complete code that demonstrates the problem?

- Jeremy

For example:
This sketch resets the Arduino.
If you do not use the “wdt_reset” that hangs Arduino.
In the serial monitor displays nothing.

#include <avr/wdt.h>
#include <SoftwareSerial.h>
#include <PololuQik.h>


#define  PololuTXPin 14 
#define  PololuRXPin 15 
#define  PololuRSTPin 16  
PololuQik2s12v10 Pololuqik(PololuTXPin, PololuRXPin, PololuRSTPin);


void setup() 
{
wdt_enable (WDTO_8S); // timer reset

// 14-16 Pololu
Pololuqik.init();

Serial.begin(115200);
}

void loop()
{
wdt_reset(); //if hang

Serial.println(Pololuqik.getFirmwareVersion());
delay(500);
}

I tried to sketch a demo on different controllers: Arduino Mega 2560 and Seeduino Mega 1280.

/*
Required connections between Arduino and qik 2s12v10:

      Arduino   qik 2s12v10
---------------------------
          GND - GND
Digital Pin 2 - TX
Digital Pin 3 - RX
Digital Pin 4 - RESET

DO NOT connect the 5V output on the Arduino to the 5V output on the qik 2s12v10!
*/

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

PololuQik2s12v10 qik(2, 3, 4);

void setup()
{
  Serial.begin(115200);
  Serial.println("qik 2s12v10 dual serial motor controller");
  
  qik.init(115200);
  
  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);
  }
}

Sketch shows only that the image:

Nothing more…
This is the problem with Mega?
Perhaps some specific requirements for the pins?

Commands like “qik.setM0Speed(127);” work fine.
“Get” commands not working… :neutral_face:

I suspect you might have a connection issue. Could you please post pictures of your setup?

- Jeremy

Pololu + Seeeduino Mega 1280
No external power supply is connected (In the photo).

big-e.ru/images/pololu/P1020733.JPG
big-e.ru/images/pololu/P1020734.JPG
big-e.ru/images/pololu/P1020735.JPG
big-e.ru/images/pololu/P1020736.JPG
big-e.ru/images/pololu/P1020737.JPG
big-e.ru/images/pololu/P1020738.JPG
big-e.ru/images/pololu/P1020739.JPG
big-e.ru/images/pololu/P1020740.JPG
big-e.ru/images/pololu/P1020741.JPG
big-e.ru/images/pololu/P1020742.JPG
big-e.ru/images/pololu/P1020743.JPG
big-e.ru/images/pololu/P1020744.JPG
big-e.ru/images/pololu/P1020745.JPG

According to SoftwareSerial Library, you can only use the following pins for RX on the Mega: 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69.

Could you try changing your RX pins to one of those and see if that fixes your problem?

- Jeremy

JeremyT
Thanks. Now it’s working…

Another question:
How can I set the control signal as in the picture

The pulse duration 50mks.
The speed of rotation is to be maximized.

do {
Pololuqik.setM1Speed(127);
delayMicroseconds(50);
Pololuqik.setM1Brake(0);
delayMicroseconds(50);
} while...

or otherwise?

Could you clarify what you mean by “the speed of rotation is to be maximized.”? If you are controlling something else, you might consider doing this with a output pin of a microcontroller. Or are you trying to get a high current output with that signal? If so, the best way would be to set the PWM frequency to 9.8 kHz and use 50% duty cycle (by setting the speed at half). This will give you approximately 51 microseconds pulse duration.

- Jeremy

I need a signal with a maximum current and the speed of rotation of electric motor and a duty cycle of 50% in order to get a powerful torque of electric motors.

Thanks for your advice on changing the PWM frequency helpful.

Another question: how to programmatically restart the driver PololuQik2s12v10. Sometimes when external power is on the driver indicator lights (signaling an error). If Arduino, press the reset button, the driver begins to work normally.
Is it possible to sketch after some time cause the reset command to reset the driver, not the Arduino?

There is an active low input for reset on the qik. You can drive the RST pin low with an IO line to reset the qik.

- Jeremy