Let's Make Robots!

Psx Library and dc motors, possible power issue?

Hi everyone! First let me just say I love this site.It's an enormous wealth of information for an enthusiast like me. I have a few concerns with a project I am working on and would love a little input.

I came across instructions for connecting a ps one controller to an arduino.I'm an fx guy that does an awful lot of low budget stuff, so this was pretty interesting to me for animatronic applications, as these controllers are only a few dollars at second hand shops here in the states.Anyway, after some tweaking (thanks RobotFreak.Your advice in another thread on changing a line in the Psx.h file worked wonders!)I managed to get the controller to work.

I also incorporated an h bridge circuit using a design found here http://www.robotroom.com/BipolarHBridge.html. I'm currently using   2n3904 and 2n3906 transistors. I use one for each motor.So far I have two motors working,with an experimenters power supply at 9 volts.I need 3.I can't seem to get anything from the last one. I wish I could give more info on the gear motors, but they're

harvested from toys I bought at thrift stores.I can tell you most run at no more than 9 volts.Also, I've included the arduino sketch below. I basically just changed a few things around in the example. If anyone can help me, I'd happily supply them with any info about the project I can.Thanks :)

 

/* This a program to use ps one controllers attached to an arduino board
to control simple dc motors with hbridge circuits.
*/

#include <Psx.h>                                          // Includes the Psx Library

#define dataPin 2
#define cmndPin 3
#define attPin 4
#define clockPin 5

#define motorPin13 13
#define motorPin12 12
#define motorPin10 10
#define motorPin9 9
#define motorPin8 8
#define motorPin7 7

Psx Psx;                                                  // Initializes the library

unsigned int data = 0;                                    // data stores the controller response

void setup()
{
  Psx.setupPins(dataPin, cmndPin, attPin, clockPin,10);  // Defines what each pin is used
                                                                                   // (Data Pin #, Cmnd Pin #, Att Pin #, Clk Pin #, Delay)
                                                                                   // Delay measures how long the clock remains at each state,
                                                                                  // measured in microseconds.
                                                          
  pinMode(motorPin13, OUTPUT);
  pinMode(motorPin12, OUTPUT);
  pinMode(motorPin10, OUTPUT);
  pinMode(motorPin9, OUTPUT);
  pinMode(motorPin8, OUTPUT);
  pinMode(motorPin7, OUTPUT);

                                                       
}

void loop()
{
  data = Psx.read();                                      // Psx.read() initiates the PSX controller and returns
                                                          // the button data

                                       // If the data anded with a button's hex value is true,
                                                          // it signifies the button is pressed. Hex values for each
                                                          // button can be found in Psx.h
 switch (data){
   case psxR2:
    digitalWrite(motorPin13, HIGH);         // If button is pressed, turn the motor
 
    break;
   case psxR1:
   digitalWrite(motorPin12, HIGH);          // If button is pressed, turn the motor
 
   break;
   case psxL1:
   digitalWrite (motorPin10, HIGH);
   break;
   case psxL2:
   digitalWrite(motorPin9, HIGH);
   break;
   case psxO:
   digitalWrite (motorPin8, HIGH);
 
   break;
   case psxX:
   digitalWrite(motorPin7, HIGH);
 
   break;
   default:
    digitalWrite(motorPin13,LOW);         // If button is pressed, turn the motor
    digitalWrite(motorPin12, LOW);          // the rest stay off to avoid cooking the h bridge
    digitalWrite(motorPin10, LOW);
    digitalWrite(motorPin9, LOW);
    digitalWrite(motorPin8, LOW);
    digitalWrite(motorPin7, LOW);


}
}
 

 

 

 

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
RobotFreak's picture

How are the H-Bridges connected to the Arduino? Each H-Bridge needs 4 control pins, but in your Arduino sketch I see only 3 control pins.

A schematic would help.