Page 1 of 1

Problem with PS2 shield and driver MD30C

PostPosted: Sun Apr 06, 2014 10:56 pm
by Momentz
I am new in arduino. I would like to control a DC motor using MD30C. I have connected the motor to the driver with wireless PS2 controller. Below are my coding:-
CODE: SELECT_ALL_CODE
#include <Shield_PS2.h>

//declare class objects
PS2 ps2=PS2();                    //PS2 class object: ps2

const int mtr1_dir = 2;
const int mtr1_pwm = 3;

void setup()
{
   ps2.init(9600, 2, 3);   

  pinMode(mtr1_dir, OUTPUT);
  pinMode(mtr1_pwm, OUTPUT);                                                     
  digitalWrite(mtr1_pwm,LOW);
}
void loop()

  if( ps2.getval(p_up)==0) 
  {
      digitalWrite(mtr1_dir, LOW);
      analogWrite(mtr1_pwm, 255);
      delay(100);
  }
  else if( ps2.getval(p_down)==0)
    {
      digitalWrite(mtr1_dir, HIGH);
      analogWrite(mtr1_pwm, 255);
      delay(100);
  }
  else
  {
      digitalWrite(mtr1_pwm, LOW);
  }   
}


When i tested my controller using the sample coding given to light up pin13 LED with the "select" button, it is working. But when i uploaded this coding into my arduino, it doesn't work. The motor just keep turning in one direction without any button pressed. I have tried the rest of the buttons to light up the pin13 LED. All of them are working. It's just doesn't work when it is use to send signal to the MD30C. Anyone know any problem with the coding? Did i left out any library? Thank you

Re: Problem with PS2 shield and driver MD30C

PostPosted: Mon Apr 07, 2014 12:24 pm
by ober
Can share your hardware setup?

A few clear photos would help.

Re: Problem with PS2 shield and driver MD30C

PostPosted: Mon Apr 07, 2014 4:23 pm
by Momentz
1.png
2.png
3.png


Does these pictures clear enough? Because the maximum size for one picture is less than 1MB. Hopefully it helps =)

Re: Problem with PS2 shield and driver MD30C

PostPosted: Tue Apr 08, 2014 8:18 am
by ober
If you notice, you are using both pin 2 and 3 for software UART and also control for MD30C. It crashes the signal.

You should switch the control pin of MD30C to pin 4 and 5. Both software and hardware.

Re: Problem with PS2 shield and driver MD30C

PostPosted: Tue Apr 08, 2014 3:39 pm
by Momentz
I see. Thanks for the info =)