Coder Social home page Coder Social logo

Comments (5)

L10N37 avatar L10N37 commented on May 30, 2024

2K -> GND
1K -> signal lines to arduino board
Centre of resistors (where 2k meets 1k) to controller pins= reduce high 5v to 3.33v (on paper)

I've now switched them to 1k pullups from ~10k (tried 5 as well)
Now I just get "ready"

from psxnewlib.

SukkoPera avatar SukkoPera commented on May 30, 2024
  1. Use 1k pull-up on the CLK, DAT and CMD lines. "Pull-up" means resistors go between each of those pins and +3.3V.
  2. You can ignore ACK for the moment.
  3. You can also ignore the Rumble power.
  4. Make sure the Arduino pins you're using match those defined in the sketch.
  5. Use an external LDO to produce the 3.3V, don't use a voltage divider. The onboard Arduino regulator should be sufficient for a single controller.

On a side note, I don't think anything in my library says Ready. They should rather go Controller found...

from psxnewlib.

L10N37 avatar L10N37 commented on May 30, 2024

The "ready" is from your HW SPI and bitbang examples for the condition have controller = false.
I've attached 1k pull up to the those 3 lines, I didn't think data would need it as it's usually already 'INPUT_PULLUP' and clock and CMD outputs idle high. Now I don't get anything on the screen.

Keeping in mind I'm an absolute beginner, I've been able to at least get a response in the terminal with my own code using SPI.h library.. if I send it anything during the monitor, I receive a '1' if a controller is plugged in and powered on, and a zero if anything else. It's not exactly what I wanted (trying to send 0x01 0x42 initialisation and receive controller type in hex) but after all the playing around I've done, it's at least "something". This is using digital read on the data line after a read pulse just before or just after the SPI transaction ends. I will try and learn some more later.

Still baffled on why yours and the original library aren't working - I'm using the standard SPI in map for UNO, D10:D13 but this video [https://www.youtube.com/watch?v=aC_moW2T7e4] seems to think otherwise... I haven't tried that as it doesn't make sense!

here's my code anyways, maybe you could help out. I am only trying to learn how to read button states to capture a START+SELECT combo then { do stuff }

#include <SPI.h>

#define ATTENTION 10 /* PULL LOW with clock AND SEND '0X01' DOWN 'COMMAND' TO RECEIVE CONTROLLER ID
LOW DURING TRANSMISSION / SPI COMMUNICATION, HIGH END OF TRANSMISSION{SPI: LIKE CS) https://www.sparkfun.com/spi_signal_names */

#define DATA 11 //DATA FROM CONTROLLER TO CONSOLE (SPI: LIKE MISI)
#define COMMAND 12 //DATA FROM CONSOLE TO CONTROLLER (SPI: LIKE MISO)
#define CLOCK 13 // CLOCK TO PIN 13, NORMALLY HIGH, 250KHZ FOR PSX
#define PSX_Controller PORTB

const int SEND_READ_PULSE = (0B011000); //ATTENTION LOW, CLOCK, LOW & SEND START COMMAND, SHOULD RECEIVE CONTROLLER ID (PORTB maps to Arduino digital pins 8 to 13)
const int IDLE_PULSE = (0B111100); //SPI knows to pull ATT low but this adds clock
const int START_COMMAND = (0x01, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
volatile int controller_type = 0; //variable to store controller type
int read_latch = 0; //variable for latching read mode between idle pulse
int idle_latch = 0; //variable for latching idle mode between read pulse
int looptime = 0; //debug

void setup() {

Serial.begin (115200); //set the serial transmission baud rate for communicating with the serial monitor
//** SET CS AS OUTPUT AND REST HIGH
pinMode (ATTENTION, OUTPUT);
digitalWrite (ATTENTION, HIGH); // //set att to rest high
pinMode (DATA, INPUT_PULLUP); //SET DATA LINE AS INPUT FROM CONTROLLER TO ARDUINO
pinMode (COMMAND, OUTPUT); //SET COMMAND LINE AS OUTPUT FROM ARDUINO TO CONTROLLER
pinMode (COMMAND, HIGH); //SET COMMAND TO REST HIGH
pinMode (CLOCK, OUTPUT); //SET CLOCK AS AN OUTPUT FROM ARDUINO TO CONTROLLER
digitalWrite (CLOCK, HIGH); //SET CLOCK TO REST HIGH
digitalWrite (8, LOW); //unused pins in PSX_Controller set to low
digitalWrite (9, LOW); //

//SPI.begin; // doing this manually with register states

}

void loop() {
delay (850);
Serial.print ("Cycles: ");
Serial.println (++looptime);

// == == == == = serial monitor stuff == == == == == ==
if (Serial.available() > 0) {
Serial.print ("Controller Type: ");
Serial.println(controller_type, HEX);
}
//== == == == == == == == == == == == == == == ==

if (idle_latch == 1) {
read_latch = 0;
//PSX_Controller = IDLE_PULSE; //shift (port B) SPI register into idle / resting mode
}

if (read_latch == 1) {
idle_latch = 0;
PSX_Controller = SEND_READ_PULSE; //shift (port b) SPI register into read mode

}

delay (50);

SPI.beginTransaction(SPISettings(250000, LSBFIRST, SPI_MODE3)); // 250khz / least significant bit first / SPI mode 3
delay (50);
read_latch = 1;
SPI.transfer (START_COMMAND, 8); //SEND 8 initiation bytes to controller (2 bytes 6 nulls)
delay (50);
controller_type = digitalRead(DATA); //read bytes on data line and store in the controller_type variable
SPI.endTransaction(); //end transmission
idle_latch = 1; //return to idle

}

from psxnewlib.

L10N37 avatar L10N37 commented on May 30, 2024

From what I can tell it's just picking up the pull up resistor on data and showing 1 when the ports plugged in, or a zero when the pullups removed because the ports not plugged in as I'm powering it from a separate barrel onto the 3.3v LDO.

...I guess that's not an indication of getting anywhere with this at all

from psxnewlib.

SukkoPera avatar SukkoPera commented on May 30, 2024

Ok, the Ready is there, but it's printed unconditionally at the very start of the sketch, before the library even tries to detect anything. It's just there to show that the sketch has started.

I suggest you write a post on the Arduino forum. This is only a place to report bugs in this library. I suspect you are using the wrong pins or are not connecting the pull-ups correctly. There's not much more that can go wrong. Maybe get one of my PsxControllerShields.

from psxnewlib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.