Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

Arduino 1.0 library for the 2s9v1?


#1

hi all!

where can i get it??

greetings
rui


#2

Hello,

We are working on a new library that will support both the qik 2s9v1 and 2s12v10, but it is not available yet. Since it seems like there have been a few requests to update the existing library for the 2s9v1, I have made an updated version and attached it below. I made sure that it compiles, but I have not tried using it with a qik yet.

  • Kevin

EDIT: The new library is now available, with support for both the 2s9v1 and 2s12v10, and we recommend using it instead of this CompactQik2s9v1 library.
CompactQik2s9v1-arduino-1.0.zip (5.64 KB)


Pololu Qik 2s12v10 Dual Serial Motor Controller
2s9v1 Controller help with Arduino
#3

thanks kevin,

i’ll try it and let you know.

greetings
rui


#4

its working allright.

a Qik2s9v1 with the Arduino 1.0 programer.

thanks!!
rui


#5

Any ideias why it won’t work with meetduino?

looks like there’s a conflict of serials, even when using diferent pins for each serial.

when one issues the serial.begin for qik then meetduino stops working, and qik works fine.
if i coment the serialbegin for qik then i have meetduino working and no qik…

thanks in advance
rui

[code]#include <MeetAndroid.h>
#include <Wire.h>
#include <SoftwareSerial.h>

#define rxpin 3
#define txpin 2
MeetAndroid meetAndroid(rxpin,txpin, 9600);
#define sensorPin A0

#include <CompactQik2s9v1.h>
#define QrxPin 7
#define QtxPin 6
#define QrstPin 8

SoftwareSerial mySerial = SoftwareSerial(QrxPin, QtxPin);
CompactQik2s9v1 motor = CompactQik2s9v1(&mySerial,QrstPin);

void setup()
{
meetAndroid.registerFunction(floatValues, ‘A’); // float array
meetAndroid.registerFunction(getTemp, ‘B’);
Serial.begin(115200);
//mySerial.begin(9600);
motor.begin();
motor.stopBothMotors();
}

long n=1;

void loop()
{
meetAndroid.receive();
Serial.println(".");
if (n==200000) {
motorShow();
n=1;}
n=n+1;

}

void floatValues(byte flag, byte numOfValues)
{
float data[numOfValues];
meetAndroid.getFloatValues(data);

if (data[1]<-5){
meetAndroid.send(“forward”);
motor.motor0Forward(40);
motor.motor1Forward(40);
}
if (data[1]>5) {
meetAndroid.send(“backward”);
motor.motor0Reverse(40);
motor.motor1Reverse(40);
}
if (data[0]<-5 ) {
meetAndroid.send(“left”);
motor.motor0Forward(10);
motor.motor1Forward(40);
}
if (data[0]>5 ){
meetAndroid.send(“right”);
motor.motor0Forward(40);
motor.motor1Forward(10);
}
if (data[0]<4 && data[0]>-4 && data[1]<4 && data[1]>-4){
meetAndroid.send(“stop”);
motor.stopBothMotors();
}

}

void motorShow(){
motor.motor0Forward(40);
motor.motor1Forward(50);
delay(900);
motor.stopBothMotors();
}

void getTemp(byte flag, byte numOfValues)
{
int reading = analogRead(sensorPin);
float voltage = reading * 5.0;
voltage /= 1024.0;
float temperatureC = (voltage - 0.5) * 100 ; //converting from 10 mv per degree wit 500 mV offset
meetAndroid.send(temperatureC);
meetAndroid.send(“graus Celsus”);
}[/code]


#6

What do you mean when you say your Amarino connection stops working? Can you try making a simpler program to see if your program itself is to blame?

- Ryan


#7

Hi,

yes i did a simpler one and amarino worked ok.
even this same program works fine if i don’t do the myserial.begin (the qik serial).

rui


#8

Hi Ryan,

had to go back to arduino22
used the hardware rxtx (serial) for the meetduino
and the qik connected to pins 2 and 3. as shown in bellow
every thing worked perfectly!!

the thing is, i need the harware serial, so i was tring to use the arduino 1.0,
and have both meetduino and qik working in software serials…

if you have a clue why the first program wont work… please share.

greetings
rui

ps. i can send a video of my tiny bot commanded by my acelerometer android phone :wink:

#include <MeetAndroid.h>
MeetAndroid meetAndroid;

#include <CompactQik2s9v1.h>
#include <NewSoftSerial.h>
#define rxPin 3
#define txPin 2
#define rstPin 4

NewSoftSerial mySerial =  NewSoftSerial(rxPin, txPin);
CompactQik2s9v1 motor = CompactQik2s9v1(&mySerial,rstPin);
byte fwVersion = -1;

void setup()  
{
  Serial.begin(9600);
  meetAndroid.registerFunction(floatValues, 'A');
  meetAndroid.registerFunction(getTemp, 'B');
  
  mySerial.begin(9600);
  motor.begin();
  motor.stopBothMotors();
  }

long n=1;
#define sensorPin A0

void loop()
{
  meetAndroid.receive();
   if (n==200000) {
    //motorShow();
    n=1;}
  n=n+1;
}


void floatValues(byte flag, byte numOfValues){
  float data[numOfValues];
  meetAndroid.getFloatValues(data);
  if (data[1]<-5){
    meetAndroid.send("forward");
    motor.motor0Forward(40);
    motor.motor1Forward(40);
  }
  if (data[1]>5) {
    meetAndroid.send("backward");
    motor.motor0Reverse(40);
    motor.motor1Reverse(40);
  }
  if (data[0]<-5 ) {
    meetAndroid.send("left");
    motor.motor0Forward(10);
    motor.motor1Forward(40);
  }
  if (data[0]>5 ){
    meetAndroid.send("right");
    motor.motor0Forward(40);
    motor.motor1Forward(10);
  }
  if (data[0]<4 && data[0]>-4 && data[1]<4 && data[1]>-4){
    meetAndroid.send("stop");
  motor.stopBothMotors();
  }
}

void motorShow(){
motor.motor0Forward(40);
motor.motor1Forward(50);
delay(900);
motor.stopBothMotors();
}

void getTemp(byte flag, byte numOfValues)
{
  int reading = analogRead(sensorPin);  
  float voltage = reading * 5.0;
  voltage /= 1024.0; 
  float temperatureC = (voltage - 0.5) * 100 ;
  meetAndroid.send(temperatureC);
  meetAndroid.send("graus Celsus");
}

#9

For this to work in 1.0 and newer, you need to change the NewSoftSerial to SoftwareSerial.

[code]#include <CompactQik2s9v1.h>
#include <SoftwareSerial.h>
#define rxPin 3
#define txPin 2
#define rstPin 4

SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
CompactQik2s9v1 motor = CompactQik2s9v1(&mySerial,rstPin);[/code]

I didn’t (and don’t have time currently) get a chance to look at the updated (for 1.0) library, but it should have any similar references changed also, in which case this may work in the first couple tries.

Also:
When posting problems, it is very helpful if you also include the error messages that you get when you try to verify/compile. While they can seem very cryptic to new programmers, they are often easily recognized and understood by more experienced programmers.


#10

Hi,

when i verify inside arduino1.0, there are no problems.
(the first program i pasted here used under arduino1.0)

but when i upload to hardware arduino uno, things don’t work.

i believe i can only have one software serial.
either i use the meetduino software serial or the qik software serial. can’t use both at the same time.

then i rewrote to arduino 22, and changed it back to newsoftserial (the second program i pasted here),
when i uploaded it to arduino uno, i use both serials (one newsoftserial for qik and one hardware serial for the meetduino (as default)).

greetings
rui


#11

Have you tried running some of the example programs from the qik 2s9v1 library to make sure those work by themselves? Then, for your final program, try using two SoftwareSerial objects on two different sets of pins, and make sure you have each device connected to the right pins.

The reason Darth Maker said you should use SoftwareSerial instead of NewSoftSerial is that, as of Arduino 1.0, the library that used to be called NewSoftSerial was renamed to SoftwareSerial and included in the Arduino core libraries (replacing an older, different version of SoftwareSerial). NewSoftSerial was written for pre-1.0 versions of the Arduino environment, so you really should not be using it in 1.0. You should be able to have multiple SoftwareSerial objects, so any problems are probably caused by conflicts such as trying to use the same pins for both.

- Kevin


#12

Hi,
sorry for my English… maybe i misspelled what i meant.

bellow is a little cut and paste from the program i used with Arduino1.0
you may see there are no conflicting pins, and i do not use the newsoftserial. Only softwareserial which is already implemented in Arduino1.0.

#include <Wire.h>
#include <SoftwareSerial.h>

#define rxpin 3
#define txpin 2
MeetAndroid meetAndroid(rxpin,txpin, 9600);
#define sensorPin A0

#include <CompactQik2s9v1.h>
#define QrxPin 7
#define QtxPin 6
#define QrstPin 8

SoftwareSerial mySerial = SoftwareSerial(QrxPin, QtxPin);
CompactQik2s9v1 motor = CompactQik2s9v1(&mySerial,QrstPin);

there are no errors while compiling
but, it wont work in my application.
if delete one of the software serials, then the other one works perfectly. meaning (i belive) there are no wiring problems. i think there’s a problem with conflicting software… not detected while compiling.

thanks for your time
rui


#13

Well, that seems strange, since http://arduino.cc/en/Reference/SoftwareSerial claims “It is possible to have multiple software serial ports with speeds up to 115200 bps.” I tried to find the MeetAndroid source to check how it uses SoftwareSerial, but I didn’t see a constructor that takes 3 arguments. Are you using a modified MeetAndroid library?

It is also possible that you are just running out of memory on the Arduino. Here are some functions you might be able to use to help determine whether that is the problem.

- Kevin


#14

MeetAndroid.cpp (7.51 KB)Hi,

can’t remember where i got it…
for sure, i didn’t made it myself. because i am not as knowledgeable.

here are the .h and the .cpp files in attachment.
hope the author don’t mind me doing this.

greetings
rui
MeetAndroid.h (4.02 KB)


#15

Your MeetAndroid library doesn’t seem to do anything unusual with SoftwareSerial. At this point, I suspect it is a memory issue. To test this, you can try using the code on the page I linked to in my last post.

Another thing you might be able to try is to (temporarily) replace your MeetAndroid object with another SoftwareSerial object on the same pins, and try sending and/or receiving data on both serial interfaces to see if they still work.

- Kevin


#16

thanks for your comments.

i’lll try them and post results.

greetings
rui


#17

Hi,

i tried 2 software serials (in arduino1.0), and they worked ok.

here’s the code.

now i need to try the meetduino and the qik…
there hasn’t been much spare time lately. :slight_smile:

still, i’ll post results when available.
greetings
rui

[code]#include <SoftwareSerial.h>

SoftwareSerial mySerial1(3, 2); //(rx,tx)
SoftwareSerial mySerial2(7, 6);

int n;
void setup()
{
Serial.begin(57600);
// set the data rate for the SoftwareSerial port
mySerial1.begin(9600);
mySerial2.begin(9600);

}

void loop() // run over and over
{
n=1;

while(n<100){
Serial.println(n);Serial.println("HSerial ");
mySerial1.println(n);mySerial1.println(“SoftSerial one”);
mySerial2.println(n);mySerial1.println(“SoftSerial two”);
n=n+1;
}
}[/code]