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:
http://blog.intuitymedialab.eu/2009/10/22/ux-toolbox-update-hardware-hacking/

thanks for all the help
benedikt

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

specs
http://www.looksgood.de/_tmp/ghm16.pdf
http://www.looksgood.de/_tmp/encodeur-quadrature-qme-01-lynxmotion-assembly-guide.pdf
http://www.looksgood.de/_tmp/schaltplan2009.10.14.pdf

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:
Code:
// causes freeze
out_motorPWM[0] = 255;
out_motorPWM[1] = 255;
Code:
// 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.

thanks
benedikt




Code:
#include <ps2.h>
// Ps2mouse lib -> http://www.arduino.cc/playground/ComponentLib/Ps2mouse

// ---- 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] = {
  0,0};

// 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);

  Serial.begin(19200);
  Serial.println("hello");

  mouse_init();
  // wait for the mouse to be ready
  delay(2000);
}

void loop() {
  // ---- read data from computer host ----
  if (Serial.available() > 0) {
    int incomingByte = Serial.read();
    // 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 ----
  drive("motor1");
  drive("motor2");

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

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


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

  // 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) {
      in_steps1++;
    }
    else {
      in_steps1--;
    }
  }
  else {
    if (digitalRead(pinE1_B) == LOW) {
      in_steps1--;
    }
    else {
      in_steps1++;
    }
  }
}

void doEncoder2() {
  // right motor, cw = backward
  if (digitalRead(pinE2_A) == HIGH) {
    if (digitalRead(pinE2_B) == LOW) {
      in_steps2--;
    }
    else {
      in_steps2++;
    }
  }
  else {
    if (digitalRead(pinE2_B) == LOW) {
      in_steps2++;
    }
    else {
      in_steps2--;
    }
  }
}

// ---- mouse ----
void mouse_init()
{
  mouse.write(0xff);  // reset
  mouse.read();  // ack byte
  mouse.read();  // blank */
  mouse.read();  // blank */
  mouse.write(0xf0);  // remote mode
  mouse.read();  // ack
  delayMicroseconds(100);
}
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.

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

ciao
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.
check http://vvvv.meso.net/tiki-index.php?page=arduino01

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 ...
http://www.e-dsp.com/controlling-a-color-graphic-lcd-epson-s1d15g10-controller-with-an-atmel-avr-atmega32l/ never tried it ... but the good thing is they using a new display from SparkFun http://www.sparkfun.com/commerce/product_info.php?products_id=569 which is very cheap.
good luck.

bene
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)

thanks
bene
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.

thanks

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 http://www.progetto2501.com/b/tools/Arduino/)

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 http://web.mit.edu/storborg/ddf/index.html
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]