1. For downloading SimTools plugins you need a Download Package. Get it with virtual coins that you receive for forum activity or Buy Download Package - We have a zero Spam tolerance so read our forum rules first.

    Buy Now a Download Plan!
  2. Do not try to cheat our system and do not post an unnecessary amount of useless posts only to earn credits here. We have a zero spam tolerance policy and this will cause a ban of your user account. Otherwise we wish you a pleasant stay here! Read the forum rules
  3. We have a few rules which you need to read and accept before posting anything here! Following these rules will keep the forum clean and your stay pleasant. Do not follow these rules can lead to permanent exclusion from this website: Read the forum rules.
    Are you a company? Read our company rules

Tutorial Mjoy16 USB AVR Joystick

Discussion in 'DIY peripherals' started by tronicgr, Jan 3, 2008.

  1. Frakk

    Frakk Active Member

    Joined:
    Apr 15, 2009
    Messages:
    1,144
    Balance:
    327Coins
    Ratings:
    +4 / 0 / -0
    George, I'm not sure what you want to achieve with the Dsub connections on the pcb. Are you trying to make it a modular keypad with only a few button inputs? The analog inputs will work just by connecting them pin to pin, but in order for the matrix keypad to work, you need to short individual rows and columns to register only one button. In order to do this, you will need column and row connections and connect them accordingly to the switches.
  2. GeorgeBoles

    GeorgeBoles Member

    Joined:
    Apr 27, 2009
    Messages:
    66
    Balance:
    4Coins
    Ratings:
    +2 / 1 / -2
    Dear Frakk,

    Reasonable question. I did not explain myself well. I am putting the MJoy in the base of the Throttle. I will be wiring diodes directly to the correct switches IN the HANDLES of the Joystick AND the Throttle to keep the number of wires across the desk neat (and so I can use the old professional, black cables which came with the CH Joysticks.) The Joystick will then connect to the Dsub mini connection (the top one) and the throttle (also with diodes placed within the handle) will wire directly to the sockets (pale blue colour). The lower Dsub connector will take the rudder +/- toe brakes, and in the future could carry sighals from a switch or two elsewhere on the desk. There will still be some patch cables to be done across the board because of different possibilities withe the joystick input (F-16 Flight Stick, F-16 Combat Stick, and F-16 Fighter Stick).

    The scheme matrix scheme is like one of the ones I put up in the .xls spreadsheet earlier in this thread. It has changed a little, but the idea is the same. The diodes will be going anode to the PC0 to PC7 inputs on the chip (as with Mindaugas' plan), but not on a matrix board but in the CH gear themselves.

    Essentially, I am not using the matrix system, but the direct wiring system Mindaugas describes to keep the number of wires across my desk (which is after all my home office) to just the same as with a normal CH Stick and Throttle setup ... not really what this amazing website is about, I know!

    I hope that makes sense this time round. ;)

    Many thanks for your input. If I am still wrong, please let me know.

    Regards,
    George.
  3. Senetor

    Senetor Member

    Joined:
    Oct 23, 2008
    Messages:
    90
    Location:
    Australia
    Balance:
    587Coins
    Ratings:
    +1 / 0 / -0
    Hi George,

    You could mount the MJoy 16 board ( without the Matrix ) into a plastic case and mount the D-sub and other connectors on the case, and wire from the connectors on the case to the MJoy with wires. With a lid on the case it would look neat and tidy and then just plug the cables into it.

    Regards Senetor.
  4. GeorgeBoles

    GeorgeBoles Member

    Joined:
    Apr 27, 2009
    Messages:
    66
    Balance:
    4Coins
    Ratings:
    +2 / 1 / -2
    Use AVcc instead of Vcc

    Hello Chaps.

    This might be important. I notice on Mindaugas' schematic and on his PCB that the analogue ports are fed their voltage from AVcc - from pin 30. On the PCB that we have been playing with, the analogue pots are being fed by Vcc ... I think a lower quality, less filtered voltage source. Perhaps that should be fixed.

    If we are going to fix that, should we also make the 100k trimmer potentiometer work on AVcc rather than Vcc?

    Hope this helps.

    George.
  5. Senetor

    Senetor Member

    Joined:
    Oct 23, 2008
    Messages:
    90
    Location:
    Australia
    Balance:
    587Coins
    Ratings:
    +1 / 0 / -0
    Hi George,

    Like this,
    MJoy 16-5.GIF

    Regards Senetor.
  6. tronicgr

    tronicgr

    Balance:
    Coins
    Ratings:
    +0 / 0 / -0
    Nice work everyone!

    It would be nice if you could show some photos of the new Mjoy16-C1 interfaced to custom controls. It would be especially useful to show some buttons or rotary encoders interfacing examples too, on the actual controls.

    Regards, Thanos :cheers:
  7. Senetor

    Senetor Member

    Joined:
    Oct 23, 2008
    Messages:
    90
    Location:
    Australia
    Balance:
    587Coins
    Ratings:
    +1 / 0 / -0
  8. GeorgeBoles

    GeorgeBoles Member

    Joined:
    Apr 27, 2009
    Messages:
    66
    Balance:
    4Coins
    Ratings:
    +2 / 1 / -2
    Dear Senetor,

    Yes, that looks better.

    Regards,
    George.
  9. Frakk

    Frakk Active Member

    Joined:
    Apr 15, 2009
    Messages:
    1,144
    Balance:
    327Coins
    Ratings:
    +4 / 0 / -0
    Has anyone tested the schematic?:) I'm getting the parts tomorrow if all goes well. I'll try to get everything together in the next couple of days and see how the firmware works. Btw, is there a programming file available with the source code (other than the hex file)?
  10. Frakk

    Frakk Active Member

    Joined:
    Apr 15, 2009
    Messages:
    1,144
    Balance:
    327Coins
    Ratings:
    +4 / 0 / -0
    Sorry for the delays, I have been caught up with other things, and I also need to find a serial cable... I didn't think it is such a hard task these days. :thbd:
  11. Senetor

    Senetor Member

    Joined:
    Oct 23, 2008
    Messages:
    90
    Location:
    Australia
    Balance:
    587Coins
    Ratings:
    +1 / 0 / -0
  12. Frakk

    Frakk Active Member

    Joined:
    Apr 15, 2009
    Messages:
    1,144
    Balance:
    327Coins
    Ratings:
    +4 / 0 / -0
    Allright! I just programmed the circuit and it seems to be working properly. Just a quick glance, I still have to test it more thoroughly.

    Windows only recognized it with 32 buttons + 1 hat switch by default. So far I hooked up only 2 analogs at the same time, the second one controls the rest of the 8 axis. I also noticed that the Voltage at the ARef pin doesn't respond according to the pot, it is either at 0 or 5V +-1%. At this point it is completely useless, I'll try to get it working if possible.

    Attached Files:

  13. tronicgr

    tronicgr

    Balance:
    Coins
    Ratings:
    +0 / 0 / -0
    Hahahahaha..... :lol:

    Its really limited to 32 buttons because of windows limitations...

    You have to use a small utility to overcome this issue:

    MJMInst.zip

    This is the Mjoy mapper!


    Here what it does:
    Code:
    About MJoy Mapper
    
    MJoy Mapper helps to overcome the maximum 32 buttons per joystick problem that many contemporary games still have. This limitation is implied by older versions of Direct X which had a limit of 32 buttons in it's DirectInput interface definitions. This limitation impacts the use of powerfull joystick device MJoy16-C1 which has a support 112 buttons. Using MJoy Mapper you may map upper joystick buttons to assigned keyboard keys. Then by pressing a joystick button you would activate a key press of virtual keyboard. 
    Below is a shortlist of MJoy Mapper usage points and fucntionality:
    
    MJoy Mapper allows you to create mapping configuration profiles, store them and load them when needed. 
    
    On first launch blank configuration is created and key mapings can be assigned by doubleclicking on appropriate buttons rows. Once assignement configuration created it should be saved to be able to use it later.
    
    On next launch MJoy Mapper automaticaly loads last used configuration.
    
    You may assign a target window to send the key presses to by specifying window class. For example MSFS2004(tm) has window class FS98MAIN. This enables to send key presses to right destination regardless which window is currently active.
    
    Pressing a refresh joysticks list enables you to discover and activate the newly connected joysticks.

    Thanos
  14. Frakk

    Frakk Active Member

    Joined:
    Apr 15, 2009
    Messages:
    1,144
    Balance:
    327Coins
    Ratings:
    +4 / 0 / -0
    I have the mapper but in the manual it says newer windows and directx versions support joysticks with all of these buttons. I have XP SP3 and I will try to install the latest DX9. Do we really have to use the mapper to make this controller function 100% with windows?
  15. tronicgr

    tronicgr

    Balance:
    Coins
    Ratings:
    +0 / 0 / -0
    The mapper will just assign the rest undetectable buttons as keyboard letters or keypresses... !! So yes, this program is needed!
  16. Frakk

    Frakk Active Member

    Joined:
    Apr 15, 2009
    Messages:
    1,144
    Balance:
    327Coins
    Ratings:
    +4 / 0 / -0
    I am thinking that games will recognise the buttons just like the mapper does. Even tho in the windows properties it only shows 32 buttons, it is likely that the rest is also useable without the mapper. I'll try it when I get a chance to play my friends' different games.
  17. IL2_flyer123

    IL2_flyer123 New Member

    Joined:
    Jun 25, 2009
    Messages:
    1
    Balance:
    0Coins
    Ratings:
    +0 / 0 / -0
    cool..I will build on ..THX..:)
  18. Sokol1

    Sokol1 Member

    Joined:
    Jul 6, 2009
    Messages:
    126
    Balance:
    14Coins
    Ratings:
    +1 / 1 / -1
    S! guys.

    Instead a MjoyMapper, use a SVMapper - a improved version of MjoyMapper made by Nihil that alow things like mapped key on press and mapped key on release for one toggle switch.

    http://forum.sukhoi.ru/showthread.php?t ... t=svmapper
    http://thommos.com/modules.php?name=Dow ... ostPopular

    I build some Mjoys too. My PCBs, smalls to put inside old joys, like Suncon F-15, Tm F22.
    http://www.wikifortio.com/739021/Mjoy16.zip

    Sokol1
  19. Sokol1

    Sokol1 Member

    Joined:
    Jul 6, 2009
    Messages:
    126
    Balance:
    14Coins
    Ratings:
    +1 / 1 / -1
    Senetor,

    Some comments about you PCB revision:

    The 10 pin header and associated (4x) 330k resitors of original Mindaugas layout is usefful in PCB only if a ATMEL Programmer is used.
    If you dont have a ATMEL Programmer and instead use a LPT1 cabble, put the four 330k resitors in cabble. Like in this cabble assembly by Tsinik:

    http://aviasimrus.spb.ru/forum/showthread.php?t=1014
    Note his miniaturized PCB (52x34mm).

    So, you reduce some traces an can use these resitors to programm more than one Mjoy16. :yes:

    To avoid gosth buttons, is usefull put a (8x) 10 resistor bridge between collumns (pins 22 to 29) and +5v.

    Like in Sundowner (Poly) revision, see under ATMEGA16:
    http://obrazki.elektroda.net/4_1237862153.jpg

    Is usefull too put jumpers with diodes (1N4148...) between pin 21 and 22, 23, 24 to select Init, Mode and Center functions (see in Mjoy16-C1 manual). Or put these jumpers in key matrix board, if used.

    [​IMG]

    Note: all these PCBs revisions/variations use the same original Mindaugas eletrical scheme and firmware (MJoy16-C1_SW_v1.3).

    I see that you put a 100k Multi (trimpot?) between +5v AVCC and Ground, what advantage in use these?

    Edit-Find the answer in the topic: 2. Analog reference adjust pot is definitely in order, since there are some sensors out there that can be used and output only 3.3v (some ratiometric hall effect sensors for example). With reference adjust pot you can measure the full range out of them!

    Thank you.

    S!

    Sokol1
  20. Frakk

    Frakk Active Member

    Joined:
    Apr 15, 2009
    Messages:
    1,144
    Balance:
    327Coins
    Ratings:
    +4 / 0 / -0
    Sokol, thanks for your input!

    About the svmapper: The firmware already has the toggle switches and encoders programmed so it only sends a short pulse for a change on the designated input. It is useful when using a single button, which also saves 1 input. Definitely good to have the extra options.

    About the circuit: I have already made changes to the last drawing posted to implement the changes you mentioned. The number of diodes could be reduced to 12 or 8 instead of 112. Currently I'm using no diodes or resistors whatsoever on the protoboard for the key matrix and I haven't experienced any ghosting. The 100k trimpot is there to set the reference voltage for the ADC of the IC, but as I mentioned it does'nt seem to have any effect. It either goes to 0V or 5V so I also have it removed until I can get it working.