Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Troubleshooting / Re: arduino robot: ps2 mouse + pololu motor controller on: November 03, 2009, 05:40:39 am
hello mike, pepe34 and mem,

sorry for the ultra long reaction time but we had to finish another more important project in the last weeks.  here we go:
yes we powered the motors with an external power suppy and the problem is still there. plus we tried to get rid of all the while cycles in the ps2 lib. but then the "mouse readings intervals" became really too slow, to make sense for calculating the position of the robot ...

so in the end we simply gave up, probably the motors produce too much noise for our electronic skills smiley-sad

but at least we have now a nice remote controlled car. not bad. if you interested here is a video:

thanks for all the help

2  Forum 2005-2010 (read only) / Troubleshooting / Re: arduino robot: ps2 mouse + pololu motor controller on: October 15, 2009, 01:58:56 am
hello mike,

our motor controller can handle 3A but both motors have together only something like 2A. we have also a capacitor attached, see picture. plus we drove yesterday evening the robot without problems in "remote car" style for hours (of course without the ps2 mouse).

what do you think? a bug in the ps2 lib?

thanks benedikt

3  Forum 2005-2010 (read only) / Troubleshooting / arduino robot: ps2 mouse + pololu motor controller on: October 14, 2009, 07:19:18 am
hello all,

we trying to build an arduino robot ...
by using the following components:

1x Pololu Dual MC33887 motor controller
2x GHM-16 gearhead motors
2x QME-01 encoders (attached to the motors)
1x ps2 mouse
1x Arduino Duemilanove


actually we are quite happy that we reached already the step, that we have everything up and running:
we get precise encoder values, we are able to control the motors with PWM via the pololu controller and with the help of the ps2 library the mouse is also working as an input sensor.

but so far we couldn't solve one strange problem:
if we drive the motors above certain PWM values the whole arduino freezes smiley-sad
for instances:
// causes freeze
out_motorPWM[0] = 255;
out_motorPWM[1] = 255;
// working
out_motorPWM[0] = 127;
out_motorPWM[1] = 127;
please note also, without reading the mouse values in the main loop, we have no problems to drive the motors with any PWM value without any freeze.
so it seems to us that we have some strange interaction with the motors and the ps2 mouse lib.

any hint is very welcome. see below code and wiring.


#include <ps2.h>
// Ps2mouse lib ->

// ---- pins ----
#define pinM1_DirectionA 4
#define pinM1_DirectionB 5
#define pinM1_PWM 10

#define pinM2_DirectionA 13
#define pinM2_DirectionB 7
#define pinM2_PWM 11

#define pinE1_A 2
#define pinE1_B 8

#define pinE2_A 3
#define pinE2_B 6

#define pinP_data 9
#define pinP_clock 12

PS2 mouse(pinP_clock, pinP_data);

//  ---- vars ----
int out_motorPWM[2] = {

// encoder 1
volatile int in_steps1 = 0;
int in_E1_prev = LOW;
int in_E1_curr = LOW;

// encoder 2
volatile int in_steps2 = 0;
int in_E2_prev = LOW;
int in_E2_curr = LOW;

// mouse
char mstat = '0';
char mx = '0';
char my = '0';

void setup() {
  // motor controller
  pinMode(pinM1_DirectionA, OUTPUT);
  pinMode(pinM1_DirectionB, OUTPUT);
  pinMode(pinM1_PWM, OUTPUT);

  pinMode(pinM2_DirectionA, OUTPUT);
  pinMode(pinM2_DirectionB, OUTPUT);
  pinMode(pinM2_PWM, OUTPUT);

  // encoders
  pinMode (pinE1_A,INPUT);
  pinMode (pinE1_B,INPUT);
  pinMode (pinE2_A,INPUT);
  pinMode (pinE2_B,INPUT);
  attachInterrupt(0, doEncoder1, CHANGE);
  attachInterrupt(1, doEncoder2, CHANGE);


  // wait for the mouse to be ready

void loop() {
  // ---- read data from computer host ----
  if (Serial.available() > 0) {
    int incomingByte =;
    // turn on both motors
    if (incomingByte == 'h') {
      // cause arduino to freeze
      out_motorPWM[0] = 255;
      out_motorPWM[1] = 255;
      // works
      //out_motorPWM[0] = 127;
      //out_motorPWM[1] = 127;
    // turn off both motors
    if (incomingByte == 'l') {
      out_motorPWM[0] = 0;
      out_motorPWM[1] = 0;
  // ---- set PWM + direction motor controller ----

  analogWrite(pinM1_PWM, abs(out_motorPWM[0]));
  analogWrite(pinM2_PWM, abs(out_motorPWM[1]));  

  // ---- read mouse data ----
  mouse.write(0xeb);  // give me data!;      // ignore ack
  mstat =;
  mx =;
  my =;

  // ---- send data to host ----
  Serial.print(mx, DEC);
  Serial.print(my, DEC);

  // reset variables after sending data, we just wanna have the delta
  in_steps1 = 0;
  in_steps2 = 0;


// ---- turn motros on + set direction ----
void drive(char m[]) {
  if (m=="motor1" && out_motorPWM[0]>=0) { // forward
    digitalWrite(pinM1_DirectionA, HIGH);
    digitalWrite(pinM1_DirectionB, LOW);
  else if (m=="motor1" && out_motorPWM[0]<0) { // backward
    digitalWrite(pinM1_DirectionA, LOW);
    digitalWrite(pinM1_DirectionB, HIGH);
  else if (m=="motor2" && out_motorPWM[1]>=0) { // forward
    digitalWrite(pinM2_DirectionA, HIGH);
    digitalWrite(pinM2_DirectionB, LOW);
  else if (m=="motor2" && out_motorPWM[1]<0) { // backward
    digitalWrite(pinM2_DirectionA, LOW);
    digitalWrite(pinM2_DirectionB, HIGH);

// ---- encoder interrupts event ----
void doEncoder1() {
  // left motor, cw = forward
  if ((digitalRead(pinE1_A) == HIGH)) {
    if (digitalRead(pinE1_B) == LOW) {
    else {
  else {
    if (digitalRead(pinE1_B) == LOW) {
    else {

void doEncoder2() {
  // right motor, cw = backward
  if (digitalRead(pinE2_A) == HIGH) {
    if (digitalRead(pinE2_B) == LOW) {
    else {
  else {
    if (digitalRead(pinE2_B) == LOW) {
    else {

// ---- mouse ----
void mouse_init()
  mouse.write(0xff);  // reset;  // ack byte;  // blank */;  // blank */
  mouse.write(0xf0);  // remote mode;  // ack
4  Forum 2005-2010 (read only) / News / Re: new tutorial - arduino longside VVVV on: January 23, 2006, 03:55:25 pm
no, do everything you want with it smiley
but i'm planing to do at least one more chapter. maybe in combination with the "dmx master" tutorial. something like "build you own dmx interface for vvvv", and show there how do work with a bunch of values.

when is the dmx tut finished?
does the dmx code work tight?
what means "Therefore the program will stop the interrupts when sending data"?

bene fit
5  Forum 2005-2010 (read only) / News / new tutorial - arduino longside VVVV on: January 23, 2006, 12:41:48 am
hello all,

i finshed 2 (first) chapters of my tutorial "arduino longside VVVV".
this 2 chapters are very basic and show how to connect arduino and VVVV.

any feedback is welcome ...
or i'm the only VVVV user wich is using arduino  smiley-wink

bene fit
6  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: graphical lcd (nokia 3310) on: March 16, 2006, 03:07:03 pm
at the "hack a day" blog was a while ago a post which is mayby interesting ... never tried it ... but the good thing is they using a new display from SparkFun which is very cheap.
good luck.

7  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: how to controll brightness of LEDs with max 72 on: March 16, 2006, 11:58:11 am
hello fux,

can you please post the finished script?
i'm very also very interested into controlling leds with arduino via a led driver ... but i think i'm going to buy rather the MAX7313 (16 channels + PWM)

8  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: led driver with pulse width modulation on: January 27, 2006, 09:04:57 am
hmm, i'm a bit skeptic ... but i gonna try it at the weekend.
actually i wanna visualize with the leds music. so have to tween (smooth) all the time between different brightness levels. i'm not sure if your "trick" works for instance, if you have three changes within a 1 sec ... but anyway going to test your concept ... will post my experiences.


bene fit
9  Forum 2005-2010 (read only) / Frequently-Asked Questions / led driver with pulse width modulation on: January 25, 2006, 09:12:12 pm
l'm looking for an easy solution to drive with the arduino board ~60 leds controlled from VVVV via arduino. each led sould be dimmable individually ...
i think the software side is not that big problem (beltram did this wicked tutorial

but how to get more PWM pins?
a very easy (and espensive) solution would probably be to use arduino as dmx interface and buy an dmx multiplexer ... but then you have this huge 19" box smiley-sad
in the led driver tutorial you use unfortunatelly this philipp chip which has no PWM smiley-sad

i found this site from the MIT disco dancefloor dudes
they do something similar, but as far i can see from their documentation, they have just  PWM in 16 steps smiley-sad

so folks any hints?

grz Mr Bene Fit
Pages: [1]