Qik Arduino Wont work

Hey all, I am trying to get a qik to be flagged as unit 0 and every time I try to send it the control information it goes red and I cant seem to get an error byte from it. I am interfacing with an arduino mega 2560 and the qik is connected to serial line 1 so it is on a dedicated line here is my code? anybody see anything wrong here?

//Qik Test

//Qik Programmer
byte incoming='X';
byte hex84=132;
byte hex55=85;
byte hex2A=42;
byte hex82=130;
byte hexAA=170;
byte zero=0;
void setup()
{

  Serial.begin(9600);
  Serial1.begin(38400);
  Serial2.begin(38400);
  Serial3.begin(38400);
  




  Serial1.write(170);
  delay(2000);



}

void loop()
{

  Serial1.print(132);  //Pololu Protocol Control Identifier
  Serial1.print(zero); 
  Serial1.print(zero); 
  Serial1.print(85);
  Serial1.print(42);




  while(incoming=='X')
  {
    Serial.println("checking");
    Serial.println(incoming);  
    if (Serial1.available())
    {
      incoming=Serial1.read();
      Serial.println(incoming);
    }
    Serial.println(incoming);
  }
  delay(1000);
}

Hello.

The problem is the way you are using serial.print(): instead of sending a byte, you are sending the ASCII representation of that byte’s value (e.g. ‘1’, ‘3’, ‘2’ instead of 132). Can you try changing your code to:

Serial1.print(132, BYTE);  //Pololu Protocol Control Identifier
Serial1.print(zero, BYTE); 
Serial1.print(zero, BYTE); 
Serial1.print(85, BYTE);
Serial1.print(42, BYTE);

and see if that makes a difference?

If you are still having trouble, can you try doing something simpler, like commanding the motor to move and using the motor indicator LEDs as feedback to tell if the command worked?

- Ben

Hey Ben thanks for your reply. I think you are mistaken, accordring to the arduino reference using serial print with the byte specific code WILL give you the ascii representation I did a little digging and found that the Serial.write() will transmit the data in the proper format and I did that however the device is still not working at all. Has there been anyone who used an arduino with one of these successfully without using that library which only can operate the simple protocol with soft serial? Im just wondering because there is ZERO information on the net about doing this (at least that I can find) and I believe i am following the instructions pretty well but am still getting nothing for results.

Thanks
Dan

ok so I tried it both ways and neither serial1.print(HEX,BYTE); nor serial.write(hex); causes the error to trigger. However neither of those get the thing to work either. I am trying to control a casefan and I know the fan works I just cant get this device to do anything other than blink

I’m pretty sure you are misinterpreting the Arduino reference.

You are (or at least were) doing the top line, and this is wrong; doing this transmits two bytes: ‘7’,‘8’ (or 55, 56). What you want to do is the bottom line, which transmits one byte, ‘N’, which has the (correct) numerical value of 78. I have successfully used the qik with the Arduino, and the way I transmitted the serial bytes was with the BYTE argument. Have you actually tried changing all of your serial transmits to what I suggested, or are you just assuming it won’t work? Does it make a difference if you change the baud rate to something much lower, like 9600?

By the way, you never said which version of the qik you are using. I will assume for now that you are using the smaller 2s9v1. If you are not, please let me know because the two versions are not identical.

Here are two things I think you should try in order, with no motor connected:

  1. Successfully send a command to it via software serial using the existing Arduino qik library. If this works, it will verify that your understanding of the qik connections is correct. If it doesn’t, then your problem is likely not with the software. Another useful test would be to put the qik into demo mode and make sure it echoes the serial bytes you send it, and that those bytes are what you expect them to be. And yet another way to test your connections and the hardware would be with a USB-to-TTL-serial adapter. You could then test the qik by sending bytes directly to it to see how it responds (our Serial Transmitter Utility can be used for this).

  2. Focus on making sure you can get the qik out of auto-detect baud mode. When the qik is waiting to detect the baud rate, it has a distinct, even green LED blinking pattern. Once you successfully send it the byte 0xAA at a valid baud rate, it will learn the baud rate and the blinking pattern will change to a brief flash approximately once every two seconds. If you never see the green LED change to this style of blinking, there is no hope that the qik will ever recognize the subsequent commands you are sending it. If the qik is not successfully learning the baud rate when you send that first 0xAA byte, we have reduced the problem to a simpler case that will hopefully be easier to troubleshoot.

- Ben

Thanks for the detailed update Ben! I did try and change my serial to the way you told me to do it. I had assumed that sending it a signal (that the arduino interprets as ascii) was wrong. I will give your troubleshooting a go and get back to you. Sorry if I came off as arrogant, I didnt mean for it to read that way. Again thanks for all the help I will give it another shot!

Thanks
dan