Jump to content



Photo
- - - - -

DIY the cheapest nudge controller


  • Please log in to reply
16 replies to this topic

#1 ChupoCro

ChupoCro

    Hobbyist

  • Members
  • PipPip
  • 24 posts

  • Flag: Croatia

  • Favorite Pinball: Terminator

Posted 20 October 2024 - 04:20 PM

Hi all,
 
not everyone has enough money to buy or build a cabinet and/or some expensive controllers - I'll here post the instructions on how to build probably the cheapest pinball nudge controller.
 
(I don't know if this is the right place to post the topic - if it isn't let the admin transfer it to where it belongs)
 
Here is how it works:
 
Instead of using some microcontroller which has USB and can simulate a HID device (joystick, keyboard, ...) I took a new approach. I couldn't find if someone else did the same but it works very well. The trick is to use $5 Zero Delay arcade controller which already has USB output acting as a game controller and to simulate joystick movements by generating high frequency PWM signal filtered with a resistor and a capacitor which is connected to analog input of the controller.
 
In this way every microcontroller can read the BMI160 accelerometer ($1.3) and generate the PWM signals for left-right and forward-backward nudging. This firmware works with every Arduino board having ATmega328 microcontroller and 16 MHz crystal powered by 5V (Arduino Uno, Arduino Nano, Arduino Pro Mini, ...) which cost only $2 - $5. 
 
I'll here post brief instructions which are enough for everyone who has worked with Arduino but I'll post more details in case someone needs additional help.
 
Here is the code. I am using PlatformIO but the same code shoud probably work with Arduino IDE. I recommend using PlatformIO because it will automatically download the correct BMI160 library specified in platformio.ini file.
platformio.ini:

[env:uno]
platform = atmelavr
board = uno
framework = arduino
lib_deps =
    emotibit/EmotiBit BMI160 @ ^0.3.3

// ****************************************************************
// ****************************************************************

main.cpp:

#include <Arduino.h>
#include <BMI160Gen.h>

#define PWM_OUT_X       PB3     // OC2A (D11)
#define PWM_OUT_Y       PD3     // OC2B (D3)

void interrupts_init(void);
void podesi_akceleraciju_LR_TMR2(float acc_raw);
void podesi_akceleraciju_FR_TMR2(float acc_raw);

void setup() {
    DDRB |= 1 << PWM_OUT_X;         // OC2A (PB3) is output      <-- D11
    DDRD |= 1 << PWM_OUT_Y;         // OC2B (PD3) is output      <-- D3
    DDRB |= 1 << PB0;               // output for oscilloscope   <-- D8
    interrupts_init();

    Serial.begin(9600);
    while (!Serial)
        ;       // wait for the port

    Serial.println("Initialisation...");
    //BMI160.begin(BMI160GenClass::SPI_MODE, /* SS pin# = */ 10);
    BMI160.begin(BMI160GenClass::I2C_MODE);
    uint8_t dev_id = BMI160.getDeviceID();
    Serial.print("DEVICE ID: ");
    Serial.println(dev_id, HEX);

    // gyro range = 250 deg/s
    BMI160.setGyroRange(250);

    // accelerometer range = 2g
    BMI160.setAccelerometerRange(2);
    Serial.println("END initialisation");
}

void loop() {
    //int gxRaw, gyRaw, gzRaw;
    int axRaw, ayRaw, azRaw;

    // BMI160.readGyro(gxRaw, gyRaw, gzRaw);
    BMI160.readAccelerometer(axRaw, ayRaw, azRaw);
    
    podesi_akceleraciju_LR_TMR2(ayRaw);
    podesi_akceleraciju_FR_TMR2(axRaw);

    delay(5);       // adjust the looptime

    // debug:
    // for measuring looptime
    PINB = 0x01;          // pulse for oscilloscope (D8)
}

// Generating high frequency PWM signal with duty cycle
// proportional to the acceleration measured by BMI160
void podesi_akceleraciju_LR_TMR2(float acc_raw) {
    // -32768 to +32767 --> 0 do 255 (almost)
    float val = ((acc_raw * 127.0 * 2) / 32768.0) + 128;
    // for Teleplot
    // Serial.print(">dLR:");
    // Serial.println(val);
    OCR2A = val;        // set duty cycle at D11
}

// Generating high frequency PWM signal with duty cycle
// proportional to the acceleration measured by BMI160
void podesi_akceleraciju_FR_TMR2(float acc_raw) {
    // -32768 to +32767 --> 0 do 255 (almost)
    float val = ((acc_raw * 127.0 * 2) / 32768.0) + 128;
    // for Teleplot
    // Serial.print(">dFR:");
    // Serial.println(val);
    OCR2B = val;        // set duty cycle at D3
}

// Timer2 is used for both the PWM signal and as the time base
// prescaler = 1, phase correct PWM --> PWM frequency:
// 16000000/510 = 31372.5 Hz --> 31.875 µs
// The same frequency is for Timer2 overflow interrupts
void interrupts_init(void) {
    TCCR2A |= 1 << WGM20;       // phase correct PWM mode, TOP = 0xff
    TCCR2B |= 1 << CS20;        // prescaler = 1
    //TCCR2B &= ~(1 << CS21);
    // TCCR2B |= 1 << CS21;     // debug (prescaler = 8)
    // No need to reset CS22 if using bare metal firmware because it is LOW
    // by default but if using Arduino framework that bit has to be reset!
    TCCR2B &= ~(1 << CS22);     // set by Arduino framework!!
    TCCR2A |= (1 << COM2A1) | (1 << COM2B1);        // clear OC2A and OC2B on compare match
    TIMSK2 = 1 << TOIE2;        // enable timer2 overflow interrupt
    sei();                      // enable interrupts
}

// For measuring the interrupt frequency
ISR(TIMER2_OVF_vect) {
    // Frequency has to be 31372.5 / 2 = 15686.25 Hz
    // To measure the interrupt frequency uncomment the next line and
    // comment out the same line for measuring the looptime in loop()
    // PINB = 0x01;           // pulse for oscilloscope (D8)
}

Here are some pictures:


01_t.jpg
 
02_t.jpg
 
03_t.jpg
 
04_t.jpg
 
05_t.jpg

 

The jumper wire is pull up "resistor" for starting the controller in analog mode. Without that the controller starts in digital mode and it could be switched into analog mode by a button. This is "ARC" version of the PCB where it isn't so easy to solder the wires because the traces are very tiny but there is CY-822A version of the PCB where the wires could be soldered by everyone.

 

Red wire is +5V from the USB for powering up the microcontroller and the green wire is X axis analog input. The other side of the green wire is connected to D11 through RC filter (R = 1k, C = 100 µF).

 

Y axis output is D3.

 

The VPX settings depend on the weight of the box. With my box which is quite heavy I am using:

X-Max 100, X-Gain 80%
Y-Max 100, Y-Gain 180%
DeadZone 4%

Edited by ChupoCro, 21 October 2024 - 12:56 AM.


#2 Emanoel299

Emanoel299

    Enthusiast

  • Members
  • PipPipPip
  • 370 posts

  • Flag: Brazil

  • Favorite Pinball: Black Knight, AFM, Creature Black Lagoon, Dr.Who

Posted 26 May 2025 - 08:39 PM

Looks Great

 

I use a simple PS3 joystick board for all my systems.

It works fine. No latency

I would like to upgrade to a professional system as PINSCAPE but it is too expansive

Your option looks a good option.

Thank you



#3 rickh

rickh

    Enthusiast

  • Gold Supporter
  • 435 posts
  • Location:Raleigh

  • Flag: United States of America

  • Favorite Pinball: I love them all

Posted 26 May 2025 - 10:34 PM

Thank you for presenting this nice project.  What is the full cost for this system? Can you use the Joystick Z axis for an analog plunger?  I ask because I posted a similar project using a RP Pico and a LIS3DH accelerometer that had 16 inputs and an analog plunger too.  Total cost in USD was ~$10.  I might revisit this project again, as MJR's Pinscape Pico software might port to this as well.

 

Again, thank you.

 

 

Rick


Rickey

Intense Arcade

http://www.intensearcade.com

 


#4 ChupoCro

ChupoCro

    Hobbyist

  • Members
  • PipPip
  • 24 posts

  • Flag: Croatia

  • Favorite Pinball: Terminator

Posted 27 May 2025 - 01:08 AM

Looks Great

 

I use a simple PS3 joystick board for all my systems.

It works fine. No latency

I would like to upgrade to a professional system as PINSCAPE but it is too expansive

Your option looks a good option.

Thank you

 

You are welcome :-)

 

So you are using a PS3 joystick board which has an accelerometer mapped to joystick axes?

 

The latency in my case depends on the joystick controller which is "Zero Delay Arcade Controller" - I don't notice any. The microcontroller I am using is for nudging only (the buttons are read directly by the Zero Delay controller) and could be connected to any joystick controller which doesn't have an accelerometer by disconnecting analog joystick(s) and connecting the outputs from my device.

 

I was planning to update the voltages at the outputs at full speed and using digital filtering but seems as Visual Pinball already is using some king of internal filtering for the analog axes used for nudging - that's why I even slowed down the rate of updating the output voltages (delay 5 in the program) to about 200 times per second. Because real pinball table is heavy and slower refresh rate in a way simulates the inertia caused by the weight.

 

I forgot what was the maximum update rate of the output voltages before I introduced the delay of 5 ms, I'll measure it when I'll have time and post the results. Anyway, the microcontroller could update the output voltages much faster than any controller can update the data sent via USB so the device doesn't introduce any additional latency.



#5 ChupoCro

ChupoCro

    Hobbyist

  • Members
  • PipPip
  • 24 posts

  • Flag: Croatia

  • Favorite Pinball: Terminator

Posted 27 May 2025 - 02:20 AM

Thank you for presenting this nice project.  What is the full cost for this system? Can you use the Joystick Z axis for an analog plunger?  I ask because I posted a similar project using a RP Pico and a LIS3DH accelerometer that had 16 inputs and an analog plunger too.  Total cost in USD was ~$10.  I might revisit this project again, as MJR's Pinscape Pico software might port to this as well.

 

Again, thank you.

 

 

Rick

 

Thank you, I am glad you like it :-)

 

The microcontroller board I used was about $5 (it has both ATmega328 and ESP8266) but everything would work with $2 Arduino Nano (the small green board in the first picture), Arduino Pro Mini or any board which has ATmega328.

 

BMI160 accelerometer was $1.3 and Zero Delay controller was $5. Full arcade kit (Zero Delay controller + 10 buttons + arcade joystick) is only $18.

 

I bought everything from Aliexpress with free shipping.

 

Zero Delay controller has two more analog axes which I didn't use and it would be easy to add additional outputs for the analog plunger (and even something else) in the same way as for the nudging. The firmware is so small because the only thing it does is generating analog voltages according to accelerometer readings and nothing else. All other things (reading the buttons, reading the analog axes, AD conversion, creating HID device, USB communication, ...) are done by Zero Delay controller or could be done by any button+joystick controller.

 

The proper way of generating the ouptut voltages would be by using a DA converter but generating PWM singnal and using a capacitor and a resistor works very well too.

 

I do have a few RP2040 boards too but in the case of making everything (HID device and nudging) without an additional controller I would probably use ESP32-S3 N16R8 because it has two USB ports.



#6 anthias

anthias

    Pinball Fan

  • VIP
  • 807 posts

  • Flag: Australia

  • Favorite Pinball: Lizards In The City



Posted 27 May 2025 - 06:43 AM

Nice idea! I have had such an addition in mind for a while but didn't want to replace my existing configuration which is two of that Verry same zero latency USB controller! So your solution is very interesting indeed.
screnstoaug21small.gif

#7 Emanoel299

Emanoel299

    Enthusiast

  • Members
  • PipPipPip
  • 370 posts

  • Flag: Brazil

  • Favorite Pinball: Black Knight, AFM, Creature Black Lagoon, Dr.Who

Posted 27 May 2025 - 06:27 PM

@chupocro

 

So you are using a PS3 joystick board which has an accelerometer mapped to joystick axes?

 

No. It is a PS3 joystick Zero delay board not official. No analogic input. Nudging is on/off.

But I tested with a Real PS3 joystick only the axes for nudging and plunger.

It works fine. But it is hard to built in a pinball cabinet. So, it was only a test.


Edited by Emanoel299, 27 May 2025 - 06:34 PM.


#8 rickh

rickh

    Enthusiast

  • Gold Supporter
  • 435 posts
  • Location:Raleigh

  • Flag: United States of America

  • Favorite Pinball: I love them all

Posted 27 May 2025 - 09:10 PM

I am fascinated that these zero latency game controllers have an analog 3-axis joystick input.  If true, this means that we could use an ADXL335 accelerometer which has an analog output.  Can you give us a link to this game controller?

 

Thanks,

 

Rick


Rickey

Intense Arcade

http://www.intensearcade.com

 


#9 ChupoCro

ChupoCro

    Hobbyist

  • Members
  • PipPip
  • 24 posts

  • Flag: Croatia

  • Favorite Pinball: Terminator

Posted 28 May 2025 - 02:08 AM

Nice idea! I have had such an addition in mind for a while but didn't want to replace my existing configuration which is two of that Verry same zero latency USB controller! So your solution is very interesting indeed.

 

In that case you could, if there is a need, use up to eight inputs more for eight additional analog axes. After using one for quite a few years with MAME and seeing it works well, I decided to try using it for playing pinball as well.

 

No. It is a PS3 joystick Zero delay board not official. No analogic input. Nudging is on/off.

But I tested with a Real PS3 joystick only the axes for nudging and plunger.

It works fine. But it is hard to built in a pinball cabinet. So, it was only a test.

 

Your boards might have analog inputs too despite not being exposed. Zero Delay controller doesn't officialy have analog inputs either but they are implemented in the firmware and can be used after removing two resistors, cutting the traces and soldering wires. More details in my reply to rickh.

 

I am fascinated that these zero latency game controllers have an analog 3-axis joystick input.  If true, this means that we could use an ADXL335 accelerometer which has an analog output.  Can you give us a link to this game controller?

 

Thanks,

 

Rick

Well, the latency is not really zero, "zero delay" is only in the name of the controller. But it certainly has very low latency.

 

It not only has three analog axes but four :-)) Here is the screenshot how it presents itself in Devices and Printers.

 

It even has autofire (which can be assigned to any button on the fly), turbo (faster auto fire) and two modes of operation - one for mapping a digital joystick to analog x and analog y axes (default mode) and the other one for mapping a digital joystick to "Point of View Hat". In the default mode analog inputs don't work because analog axes are affected by the input for a digital joystick but in the other mode when digital joystick inputs are mapped to Point of View Hat the analog inputs start working.

 

Analog inputs are not exposed as connectors and are not documented but they can be used too. In the factory state all analog axes are connected to the middle of two identical resistors connected between +5V and GND so they are always in the center position but after removing those resistors and cutting the traces to separate the axes 4 analog inputs can be used.

 

And there is a pull-down resistor which can be moved to act as a pull-up resistor to enable analog axes by default. Without moving that resistor one additional button connected to MODE input could be used to change the mode but that would have to be done every time after powering up.

 

You are right, using ADXL335 would probably work well. When I started writing the firmware I thought I would have to use some kind of digital filtering (like running average, which would introduce a bit of latency) but it turned out everything works well even without it - that's why I think ADXL335 could be used too. Seems as VPX itself is doing some filtering.

 

This is from where I bought it:

https://www.aliexpre...5735969454.html

 

There are several versions of the PCB. Most of them are using the very same microcontroller with the very same firmware but the easiest to work with is the green one labeled CY-822A (Color: Board with cable in the listing), the blue one labeled ARC-968 (Color: Board without cable in the listing) has much thinner traces and doesn't have through hole contacts for soldering the analog inputs.

 

Pictures from the listings should not be trusted - I ordered the complete kit (controller + cables + joystick + buttons) from this link too:

https://www.aliexpre...6337184468.html

 

but I got the ARC-968 version of the PCB. The safest way is to check the reviews contaning the pictures to be sure which version of the PCB will arrive. But then - it's only $4 - $6 and every version works exactly the same.

 

The first two pictures in my initial post show the version of the PCB that is easier to work with and in the 3rd and the 4th picture there is a version where the traces are much thinner and there isn't through hole contacts for soldering the pull-up resistor so I had to solder the tiny wire.

 

zero_delay_controller_t.png



#10 rickh

rickh

    Enthusiast

  • Gold Supporter
  • 435 posts
  • Location:Raleigh

  • Flag: United States of America

  • Favorite Pinball: I love them all

Posted 28 May 2025 - 11:32 AM

 

 

I am fascinated that these zero latency game controllers have an analog 3-axis joystick input.  If true, this means that we could use an ADXL335 accelerometer which has an analog output.  Can you give us a link to this game controller?

 

Thanks,

 

Rick

Well, the latency is not really zero, "zero delay" is only in the name of the controller. But it certainly has very low latency.

 

It not only has three analog axes but four :-)) Here is the screenshot how it presents itself in Devices and Printers.

 

It even has autofire (which can be assigned to any button on the fly), turbo (faster auto fire) and two modes of operation - one for mapping a digital joystick to analog x and analog y axes (default mode) and the other one for mapping a digital joystick to "Point of View Hat". In the default mode analog inputs don't work because analog axes are affected by the input for a digital joystick but in the other mode when digital joystick inputs are mapped to Point of View Hat the analog inputs start working.

 

Analog inputs are not exposed as connectors and are not documented but they can be used too. In the factory state all analog axes are connected to the middle of two identical resistors connected between +5V and GND so they are always in the center position but after removing those resistors and cutting the traces to separate the axes 4 analog inputs can be used.

 

And there is a pull-down resistor which can be moved to act as a pull-up resistor to enable analog axes by default. Without moving that resistor one additional button connected to MODE input could be used to change the mode but that would have to be done every time after powering up.

 

You are right, using ADXL335 would probably work well. When I started writing the firmware I thought I would have to use some kind of digital filtering (like running average, which would introduce a bit of latency) but it turned out everything works well even without it - that's why I think ADXL335 could be used too. Seems as VPX itself is doing some filtering.

 

This is from where I bought it:

https://www.aliexpre...5735969454.html

 

There are several versions of the PCB. Most of them are using the very same microcontroller with the very same firmware but the easiest to work with is the green one labeled CY-822A (Color: Board with cable in the listing), the blue one labeled ARC-968 (Color: Board without cable in the listing) has much thinner traces and doesn't have through hole contacts for soldering the analog inputs.

 

Pictures from the listings should not be trusted - I ordered the complete kit (controller + cables + joystick + buttons) from this link too:

https://www.aliexpre...6337184468.html

 

but I got the ARC-968 version of the PCB. The safest way is to check the reviews contaning the pictures to be sure which version of the PCB will arrive. But then - it's only $4 - $6 and every version works exactly the same.

 

The first two pictures in my initial post show the version of the PCB that is easier to work with and in the 3rd and the 4th picture there is a version where the traces are much thinner and there isn't through hole contacts for soldering the pull-up resistor so I had to solder the tiny wire.

 

zero_delay_controller_t.png

 

Thanks again! I purchased the unit suggested with the cables and will fetch me an analog output accelerometer board.  From your instructions, you pulled one of the inputs high using a pull-up resistor (this switches the input from digital to analog mode) and applied a PWM signal to the X and Y axis.  I assume that the RC filter (R = 1k, C = 100 µF) is used to convert the PWM to DC? 

 

Rick  


Rickey

Intense Arcade

http://www.intensearcade.com

 


#11 ChupoCro

ChupoCro

    Hobbyist

  • Members
  • PipPip
  • 24 posts

  • Flag: Croatia

  • Favorite Pinball: Terminator

Posted 28 May 2025 - 03:10 PM

Thanks again! I purchased the unit suggested with the cables and will fetch me an analog output accelerometer board.  From your instructions, you pulled one of the inputs high using a pull-up resistor (this switches the input from digital to analog mode) and applied a PWM signal to the X and Y axis.  I assume that the RC filter (R = 1k, C = 100 µF) is used to convert the PWM to DC? 

 

Rick 

 

Yes, the 0 Ohm resistor labeled J1 acts as a jumper. It's in the lower position by the factory and moving it into the upper position (exactly where the J1 label is printed) will enable the analog inputs by default.

 

The analog outputs are:

R1 - R2 --> X axis
R3 - R4 --> Y axis
R5 - R6 --> Z axis
R7 - R8 --> Z rotation axis

R1 goes from +5V to the analog input for the X axis and R2 goes from analog input for the X axis to GND.

R1 and R2 are soldered by the factory to hold every analog axis (when they are ON) in the center position. Insted of soldering R3 to R8 they connected all analog inputs together with the horizontal trace connecting all 4 midpoints of the resistor pairs.

 

Two analog inputs can be used by cutting the traces between the fitrst and the second analog input and by cutting the trace between the second and the third analog input. Three analog inputs can be used by cutting the trace between the third and the fourth analog input.

 

Important:

Unused analog inputs must not be left unconnected because the noise will propagate to the analog inputs that are used. If only two or three analog inputs are going to be used then R1 and R2 resistors must (after cutting the traces) be moved to the position R7 - R8 to hold the unused analog axes/axis in the center.

 

In my case the RC filter has two purposes:

 

1. Converting the PWM to DC (easier when PWM frequency is higher)

 

2. Smoothing the response from the accelerometer

 

In your case you will probably have to smooth out the response from the ADXL335 in the same way because otherwise the response would most likely be too "sharp", as if the pinball table is too light.

 

When I was tweaking the parameters I tried to find the best combination of:

 

1. Accelerometer range (set in the firmware)

 

2. RC filter cutoff frequency (capacitor value)

 

3. Output voltage swing (set in the firmware)

 

4. VPX settings (X-Gain and Y-Gain)

 

It took me only 20 minutes to find the best combination of those parameters but as I was using a microcontroller I was looking at nice real time graphs displaying the readings so it was easy to make adjustments. These can, in case of using a microcontroller, be enabled by uncommenting the lines below "for Teleplot" comment.

 

The low pass RC filter cutoff frequency is only 1.6 Hz but that doesn't mean it will remove the responses to the movements of the box/cabinet which are much faster - that's just -3dB gain point of the filter.

 

https://www.digikey....igh-pass-filter

 

If the response feels like there is too much inertia as if the pinball table is too heavy, lower capacity value will increase the filter cutoff frequency and the response would be "sharper". You could prepare several capacitors of different values (from 100 µF towards 100 nF) for testing with which capacity will the response be the most realistic.



#12 rickh

rickh

    Enthusiast

  • Gold Supporter
  • 435 posts
  • Location:Raleigh

  • Flag: United States of America

  • Favorite Pinball: I love them all

Posted 28 May 2025 - 03:24 PM

Thanks for your analysis.

 

"When I was tweaking the parameters I tried to find the best combination of:

 

1. Accelerometer range (set in the firmware)

 

2. RC filter cutoff frequency (capacitor value)

 

3. Output voltage swing (set in the firmware)

 

4. VPX settings (X-Gain and Y-Gain)"

 

 

Having straight analog from an accelerometer might have its limitations.  I'll need to play and see.  


Rickey

Intense Arcade

http://www.intensearcade.com

 


#13 ChupoCro

ChupoCro

    Hobbyist

  • Members
  • PipPip
  • 24 posts

  • Flag: Croatia

  • Favorite Pinball: Terminator

Posted 28 May 2025 - 03:36 PM

Having straight analog from an accelerometer might have its limitations.  I'll need to play and see. 

 

I think it will work well because all of these setting are interchangeable and there are many combinations which would produce the same result. For example, too low or too high voltage swing can be countered by the VPX gain settings and the accelerometer range (which can cause too harsh or too soft response) can be countered by changing the smoothness of the RC filter.


Edited by ChupoCro, 28 May 2025 - 03:38 PM.


#14 rickh

rickh

    Enthusiast

  • Gold Supporter
  • 435 posts
  • Location:Raleigh

  • Flag: United States of America

  • Favorite Pinball: I love them all

Posted 15 June 2025 - 12:31 PM

ChupoCro,

 

I finally got my encoder and have been experimenting with it.  I found another article that details the modification of this button encoder for analog input:https://www.instruct...oystick-Modifi/

The only issue I have is that the analog input is from 0-5V, as this makes it difficult for most analog output accelerometers, their output is only 3.3V.   I'll need to do more experimentation to validate this.


Rickey

Intense Arcade

http://www.intensearcade.com

 


#15 rickh

rickh

    Enthusiast

  • Gold Supporter
  • 435 posts
  • Location:Raleigh

  • Flag: United States of America

  • Favorite Pinball: I love them all

Posted 17 June 2025 - 09:06 PM

Folks,

 

I have finally evaluated this encoder/usb game controller with an analog accelerometer.  This project took me only 30 minutes to complete.  I had to move a resistor to change the encoder mode to analog, I had to removed two resistors used to place all axis inputs into quiescent state, a trace connecting all axis together needs to be cut and the accelerometer needs to be wired using four connections.  As mentioned, this accelerometer is driven by 3.3V and has quiescent output of 1.6V for both X/Y axis.  The game controller ADC has a range of 0-5V, the quiescent voltage is 2.5V.  So when the accelerometer is placed flat and simply attached to the encoder the joystick output is not in the middle.  Cutting to the chase, this economy solution will not work as is, but I knew this was going to happen.  This can be fixed by adding dual opamp and four resistors, but it makes it a bit more complicated and takes the fun out of this project.   If anyone wants to pursue this in detail, let me know and I'll draw out a cheesy schematic and instructions. 

 

 

Regards,

 

Rick    


Edited by rickh, 17 June 2025 - 10:30 PM.

Rickey

Intense Arcade

http://www.intensearcade.com

 


#16 ChupoCro

ChupoCro

    Hobbyist

  • Members
  • PipPip
  • 24 posts

  • Flag: Croatia

  • Favorite Pinball: Terminator

Posted 11 July 2025 - 02:28 AM

ChupoCro,

 

I finally got my encoder and have been experimenting with it.  I found another article that details the modification of this button encoder for analog input:https://www.instruct...oystick-Modifi/

The only issue I have is that the analog input is from 0-5V, as this makes it difficult for most analog output accelerometers, their output is only 3.3V.   I'll need to do more experimentation to validate this.

 

Hi,

 

I am sorry for late reply. I missed the email notification and I haven't checked the forum lately.

 

I saw you mentioned using two op amps for conditioning the output from the accelerometer but there might be a simpler method.

 

The first solution might be to use just one op amp with gain of 5/3.3 = 1.52 for amplifying 0V - 3.3V range to 0V - 5V range. That way 3.3V / 2 = 1.65V would be scaled to 2.5V. Did you plan on using a second op amp as a voltage follower to isolate the accelerometer output from the load? I think that isn't necessary because analog input is high impedance load so only one op amp should be enough.

 

But I think even simpler solution would work well. You could use a voltage divider consisting of two identical resistors supplied by 5V to generate 2.5V and connect the accelerometer output via a capacitor to the output of the voltage divider. That might work or not depending on the output impedance of the accelerometer. In that case the RC constant would be R1 in parallel with R2 times C and you could tweak the response by changing the capacitor value. By using a potentiometer instead of two resistors the accelerometer would be connected (via capacitor) to the potentiometer wiper which would in the same time be connected to the controller's analog input. That way you could use the potentiometer to center the output.

 

I think that would work because you don't need full swing of the signal from 0 to 5V. The accelerometer output would in that case be offset from 0 - 3.3V to 0.85V - 4.15V with the original swing of 3.3V which is more than enough and the full scale of the accelerometer will not be used anyway.

 

The only difference compared to the first solution is the device would response to transients only - meaning it wouldn't be possible to simulate lifting one side of the controller to cause the balls going in one direction by keeping the "table" slanted because the capacitor would block the DC component.

 

But that isn't something that needs to be simulated anyway because no one is lifting the table when playing pinball :-))

 

I can slant the controller in one direction and the result is the same as if I slanted the table. If I slant the controller to the front the ball goes towards the upper part of the playfield. The same would be with the first solution but not with the second one. But otherwise I think the second solution would work well.

 

There are more solutions without using a microcontroller. Summing amplifier cicruit using one op amp might work too.

 

Turning on Enable Nudge Filter in VPX Settings might cause autocalibration of analog axes. In that case everything would work without shifting the voltages.

 

Or you could try using DXTweak tool to calibrate the center point of the analog input.


Edited by ChupoCro, 11 July 2025 - 02:34 AM.


#17 rickh

rickh

    Enthusiast

  • Gold Supporter
  • 435 posts
  • Location:Raleigh

  • Flag: United States of America

  • Favorite Pinball: I love them all

Posted 12 July 2025 - 05:37 PM

Chupocro,

 

Yes, I was going to use a TL082, with a gain of 1.5.  A dual channel opamp is needed for both the X and Y axis channels.

 

Regards,

 

Rick   


Rickey

Intense Arcade

http://www.intensearcade.com