Problem with PS2 shield and driver MD30C

Autonomous Robot, Manual Robot, DC Motor Driver, Stepper Motor Driver, Servo, Multi PWM chip.....

Problem with PS2 shield and driver MD30C

Postby Momentz » Sun Apr 06, 2014 10:56 pm

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
#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
Momentz
Freshie
 
Posts: 4
Joined: Sun Apr 06, 2014 10:45 pm

Re: Problem with PS2 shield and driver MD30C

Postby ober » Mon Apr 07, 2014 12:24 pm

Can share your hardware setup?

A few clear photos would help.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1409
Joined: Wed Apr 15, 2009 1:03 pm

Re: Problem with PS2 shield and driver MD30C

Postby Momentz » Mon Apr 07, 2014 4:23 pm

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 =)
Momentz
Freshie
 
Posts: 4
Joined: Sun Apr 06, 2014 10:45 pm

Re: Problem with PS2 shield and driver MD30C

Postby ober » Tue Apr 08, 2014 8:18 am

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.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1409
Joined: Wed Apr 15, 2009 1:03 pm

Re: Problem with PS2 shield and driver MD30C

Postby Momentz » Tue Apr 08, 2014 3:39 pm

I see. Thanks for the info =)
Momentz
Freshie
 
Posts: 4
Joined: Sun Apr 06, 2014 10:45 pm


Return to Robot Controller

Who is online

Users browsing this forum: No registered users and 3 guests

cron