Menu

Joystick Interface - Legacy PC joystick to ADC joystick

Anobium
2023-09-02
2023-09-02
  • Anobium

    Anobium - 2023-09-02

    I needed to support an old legacy analog PC joystick on a very old computer that had a total different ADC interface. Not only the pin out was different, the voltages, the range of operation... totally incompatible.

    Old legacy analog PC joysticks are different from what you expect. The pots on the X or Y axis are not voltage dividers - they have no 0v0. So, the PC had to handle the voltage divider. Look at the first diagram it shows no 0v0 on the pots.

    And, the total resistance of the legacy analog PC joystick. is 120k but the range is 35k to 85k.

    old legacy joystick


    The need was to read the legacy analog PC joystick., and, then convert to a 0k to 10k range with a VREF of 1v8.


    I want to be able to simply connect the two 15 ways connectors to something and thhe solution should just work.

    The solution is very simple. Read the ADC(s) from the joystick, scale these results, send to Digital Pot. See code below. In the code below, I read ADC port 1 ( AN1 ) into a variable called Xadc then write the result variable called ResX to channel 0 -same for the other axis.

    A test ADC test program on the target computer shows ranges as 320 to 65520 - which is correct for that specific ADC.

    I used the LGTF328P UNO shield ( £3.20 .. or a lot more from my eBay!), a MCP4261 Digital Pot ( £1.60 ) and a few connectors.

    All most any PIC, AVR or LGT microcontroller will work. I think an 8 pin device would work as the SPI between the microcontroller and the Digital Pot can use software SPI, therefore, any port.pin on the microcontroller should work. The LGT microcontroller works at 32mHz ( twice as fast as the UNO ) but I have tested down to slow frequencies and all is good for low power use ( maybe direct from the Beeb PSU).

    With this solution used the computers VRef as the input side of the Digital Pot Terminal, and the Digital Pot Wiper back the computer.

    revised joystick with layout

    Brilliant it works!

    #chip LGT8F328P
    #option Explicit
    
        // Hardware USART, hardware SPI - remove from this listing... it is dead easy to configure
    
        // Main do-loop
    
        Do
            // Flash the LED to show action
                If LED_Counter MOD 2047 = 0 then DIGITAL_8 = !DIGITAL_8
                    LED_Counter++
    
            //! Read the joystick ADC values
              Xadc = ReadAD10( AN1 )
              Yadc = ReadAD10( AN0 )
    
            //! Scale results to get the correct range for DigitalPot
                ResX = Scale( Xadc, MinX, MaxX, 0, 255 ) 
                ResY = Scale( Yadc, MinY, MaxY, 0, 255 ) 
    
            //! Set the digital post with the value
                DigitalPotSetWiperPosition ABS(ResX), 0     // Channel 0
                DigitalPotSetWiperPosition ABS(ResY), 1     // Channel 1
    
        Loop
    

    The layout was easy. Adapt the pot within the joystick to have a common 0v0, and attach a MCP4261 ( a two port digital 10k pot). Very simple.

    pcb

     

    Last edit: Anobium 2023-09-02
  • Anobium

    Anobium - 2023-09-02

    This solution should work on most microncontroller - it can software SPI ( bit banging.

    I used the LGT as they are so cheap. :-) and, robust.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.