Author Topic: detect the press on R2 / L2  (Read 2302 times)

Offline debra

  • Guppy
  • *
  • Posts: 3
  • Post quality +0/-0
  • Acidmods User
detect the press on R2 / L2
« on: March 15, 2019, 04:00:14 AM »
Hello and thank you in advance for your answers.

My project is to create a pcb myself to remap buttons PS4 controller.

For all the keys I get there except R2 / L2, because I do not understand how they work and therefore how to recognize by my microcontroller that someone has to press the key.

Sorry if my English is unusual because my native language is French.

Thank you in advance and good day.

Offline RDC

  • Administrator
  • Around the block
  • *
  • Posts: 2609
  • Post quality +90/-2
  • Gender: Male
  • The CGnome Project
Re: detect the press on R2 / L2
« Reply #1 on: March 15, 2019, 05:32:25 PM »
The L2/R2 are a bit of a mess. They use a pulsed VSS that goes into a voltage divider, and it's speed is either 100Hz or 250Hz depending if it's wireless or connected over USB. The ground half of the voltage divider is the L2/R2 button, the more it's pressed the lower the value of that Resistor. The other side of the divider is a fixed value and connected to the 3.2v supply. When L2/R2 is not pulled, and the controller is not reading them, the pulse is Hi, 3.2v, so the divider output is 3.2v. When the controller reads the L2/R2, it pulses the 2L/2R lines Lo for 120us. the pulsed VSS goes thru the Divider and if L2/R2 are not pulled, the output of the divider will measure ~1.6v, if L2/R2 are pulled all the way the divider output will be ~0.8v or so.

Schematic of how L2 works, R2 is the same



L2 and R2 on the Logic Analyzer. L2 Pressed and released, then R2 Pressed and released



L2/R2 close up and Not Pulled



L2/R2 close up and R2 Pulled all the way




The best way to go about seeing if one of them is pressed is to use 3 I/O in total on your microcontroller. Use a Digital (Input) connected to 2L (or 2R, 2L just go Lo 88ns sooner) then 2 Analog (Inputs) connected to L2 and R2.

When 2L goes Lo, wait at least 5us, then measure the voltages on L2 and R2 to tell if they are pressed or not. You need to wait a little bit so you get a good L2/R2 measurement.

If L2/R2 are not pressed, they will each measure ~1.6v

If they are pulled all the way, they will measure ~0.8v

Those voltages are approximate values, as the Resistors on the Daughter board (the Flex board) are what make up the voltage divider and their values can be a shade different from controller to controller. So doing something like over 1.5v = Not Pressed and under 1.2v = Pressed is a safe bet, unless you're wanting to know exactly how much the Trigger is being pulled, or you can code it up to calibrate the values it reads, plenty of options there.

To 'press' the L2/R2, just change your L2/R2 Analog pins to Digital (Outputs) and drive them Lo. Do not leave them as Outputs, only change them and drive them Lo when they need to be pressed, any other time they should be left floating, as Inputs or the ADC Inputs so they do not mess with how the controller normally works.
Screwing up is one of the best learning tools, so long as the only thing you're not learning is how to screw up.

Offline debra

  • Guppy
  • *
  • Posts: 3
  • Post quality +0/-0
  • Acidmods User
Re: detect the press on R2 / L2
« Reply #2 on: March 16, 2019, 04:08:01 AM »
A big thank you, I did not expect so many explanations. I will try to implement it and I will keep you informed on the progress of my project.

A very big thank you and have a good weekend.

Offline debra

  • Guppy
  • *
  • Posts: 3
  • Post quality +0/-0
  • Acidmods User
Re: detect the press on R2 / L2
« Reply #3 on: March 12, 2020, 08:50:09 AM »
Hello, sorry for my late reply but the system works well on the controler before jdm-040. But on the jdm-055 controllers I can't get the system to work. I tried to analyze the signal with an oscilloscope but without success because I want to detect the exact pressure of the triggers L2 and R2. Are the JDM-055 motherboards different on this side compared to the old ones? Thank you in advance and good
« Last Edit: March 12, 2020, 10:20:18 AM by debra »

Offline RDC

  • Administrator
  • Around the block
  • *
  • Posts: 2609
  • Post quality +90/-2
  • Gender: Male
  • The CGnome Project
Re: detect the press on R2 / L2
« Reply #4 on: March 12, 2020, 02:39:40 PM »
They haven't changed how they work that I'm aware of. What kind of scope are you using? You should be able to see any differences compared to the working one with it.
Screwing up is one of the best learning tools, so long as the only thing you're not learning is how to screw up.

 

SMF spam blocked by CleanTalk
SimplePortal 2.3.5 © 2008-2012, SimplePortal