Psx Library and dc motors, possible power issue?
August 24, 2010
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
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.
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
digitalWrite(motorPin13, HIGH); // If button is pressed, turn the motor
digitalWrite(motorPin12, HIGH); // If button is pressed, turn the motor
digitalWrite (motorPin10, HIGH);
digitalWrite (motorPin8, HIGH);
digitalWrite(motorPin13,LOW); // If button is pressed, turn the motor
digitalWrite(motorPin12, LOW); // the rest stay off to avoid cooking the h bridge