1. Do not share user accounts! Any account that is shared by another person will be blocked and closed. This means: we will close not only the account that is shared, but also the main account of the user who uses another person's account. We have the ability to detect account sharing, so please do not try to cheat the system. This action will take place on 04/18/2023. Read all forum rules.
    Dismiss Notice
  2. 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!
  3. 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
  4. 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. Sokol1

    Sokol1 Member

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

    tirta Member

    Joined:
    Feb 4, 2010
    Messages:
    56
    Balance:
    0Coins
    Ratings:
    +0 / 0 / -0
    Hi Frakk and Sokol1,

    Thanks for all the explanations.
    I really appreciate all of them very much.

    sorry if this is another noob question:
    I am not so sure how to connect the 3 pins of the potentiometer to the pcb.

    According to the manual page 17:
    the 3 pins are: +5V, Signal & Ground.
    Does the original CH potentiometers match this specification?

    This is the layout I use:
    [​IMG]
    I guess the 3 pins goes to the 3 rows on the upper left corner of the pcb.
    The upper rows are +5V.
    The middle rows are Ground.
    The lowest rows, which are connected to the IC pins, are Signal.
    Are these correct?
  3. Sokol1

    Sokol1 Member

    Joined:
    Jul 6, 2009
    Messages:
    126
    Balance:
    14Coins
    Ratings:
    +1 / 1 / -1
    Yes, correctly, in smaller PCB you need a different pin arrangement to one show in manual.

    Middle pin of CH pot go to Mjoy16 Signal pin, and external pot pins go to +5V and GND.
    If you need reverse pot direction, invert wires from +5V and GND in pot external pins.

    [​IMG]

    This disposition of pins allow you to easy ground not used axis, putting a jumper over Signal and GND, to avoid spikes.

    See in this picture:

    [​IMG]

    In this Mjoy16 all axis are grounded - black and blue jumpers over Signal and GND pins.

    Warning: Don't put jumper over GND and +5V. Fried IC dont smells good. :D

    Sokol1
  4. tirta

    tirta Member

    Joined:
    Feb 4, 2010
    Messages:
    56
    Balance:
    0Coins
    Ratings:
    +0 / 0 / -0
    Hi Sokol1,

    Thanks for all the tips and explanations! :hi:

    I have finished soldering my pcb! :D
    Now I am going to program it.

    You said:
    How about when I am going to connect the programmer?
    Do I have to connect USB first? or it does not matter?
    Please advise.

    About the axis,
    where should I put the throttle? the pedals? the toe brakes?
    in Z or Rx, slider, dial ? or it does not matter?

    How about autocalibration? Does it affect all axis?
    or only X and Y and pedals ?
  5. Sokol1

    Sokol1 Member

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

    During write firmware proccess (programming) USB cable act as POWER SOURCE.

    So, plug SERIAL cable terminal in Mjoy16 and plub you DB-9 into computer, after this connect your power source (USB cabble).

    When programming firmware is done - pay special attention to Security and Configuration bits, Mindaugas instructions is little superficial (for newbies) in this part (1) - disconnect USB cable (power source) first, after disconnect SERIAL cable. Now remove SERIAL cable from Mjoy16 and after plug only USB cable in computer (and cross your fingers :lol:).

    (1) If, after WRITE firmware you select Security and Configuration bits and the options are grayed, first click in READ (dont click in WRITE), adjust fuses according instructions and then click in WRITE.

    Good luck. ;)

    Sokol1
  6. Sokol1

    Sokol1 Member

    Joined:
    Jul 6, 2009
    Messages:
    126
    Balance:
    14Coins
    Ratings:
    +1 / 1 / -1
    Only X and Y are reserved to joystick Aileron and Elevator axis, use another according convenience.
    Typically, first after X and Y are used for Throttle, next to Rudder... use the next two after rudder for right/left toe brakes.

    Only X, Y and Rudder, is the CENTER function described in Mjoy16-C1 manual pag. 7.

    To tweak axis ends, response curves... use DXTweak2, DView.

    Post some pictures of you precious.

    Sokol1
  7. Frakk

    Frakk Active Member

    Joined:
    Apr 15, 2009
    Messages:
    1,144
    Balance:
    328Coins
    Ratings:
    +4 / 0 / -0
    It doesn't matter what you plug in first or second. What matters is that you can't program the device without power. You need both cables connected. After you are done programming, unplug everything, plug USB back and you should have the MJ16 in your game controllers.
  8. tirta

    tirta Member

    Joined:
    Feb 4, 2010
    Messages:
    56
    Balance:
    0Coins
    Ratings:
    +0 / 0 / -0
    Hi Sokol1 & Frakk,

    Here is the picture of my pcb based on your layout. 8)
    [​IMG]

    I do not build the serial programmer, I build parallel programmer instead,
    since my friend shows me that I have one in my computer, I only have to connect this cable:
    [​IMG]
    [​IMG]

    However, connecting that cable to the motherboard is rather confusing.
    According to him, the red line on the cable marks pin #1 position.

    But according to your picture (I mark it in blue) that is not.
    [​IMG]
    So which one is correct pin #1?

    And on MJoy16-C1_SW_v1.3.zip, there are two files:
    mjoy_16.hex
    mjoy_16.eep
    Do I use both files for programming?

    Please advise.
  9. Sokol1

    Sokol1 Member

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

    Looks good. :)

    But, why you have two wires in the right pin of programmer cable (to GND pin), one brown and one green?
    And another two brown wires leaving the left corner?

    About LPT1 cable, your friend is wright. Red line mark pin position. Match this with motherboard connector, refer to manual.

    What picture your refer?

    If you refer to these:

    [​IMG]

    Look, this scheme is for male connector, and you see pins from solder side (where you weld the wires - so you see #1 pin to right), when you plug it into female connector (the new cable in your computer), the pins match. In your last picture the correctly pin 1 position is the RED, in right side of female connector.

    Pay attention: in the male DB-25 plug that you use to build your LPT1 programmer cable, exist numbers indicating pins 1 and 25 position, be guided by them.

    And to confuse a bit more, your first LPT1 cable picture is upside down. ;P :lol:

    To programming Mjoy16, you use .HEX file.

    Sokol1
  10. tirta

    tirta Member

    Joined:
    Feb 4, 2010
    Messages:
    56
    Balance:
    0Coins
    Ratings:
    +0 / 0 / -0
    Hi Sokol1,

    I have programmed my mjoy16 with no error,
    but my window (xp sp2) can not recognize the device. :?

    When I plug the usb, the message in window is :
    USB device not recognized.
    unknown device.

    This is what I did:
    1. run ponyprog, calibrate computer
    2. choose atmega16
    3. i/o setup, choose parallel, Avr ISP I/O, LPT1, then OK.
    4. connect the programmer( already connected to mjoy16) to parallel port,
    connect USB to mjoy16.
    5. read (flash), successfull
    6. erase, OK
    7. open .hex
    8. write program (flash), successful.
    9. set config and security bits, press ok
    10. disconnect USB, then programmer, then connect USB again.

    What did I do wrong? :? :?

    yes there are two wires connected to GND pin,
    there are 6 wires in my cable, so there is one unused cable, so I connect it to GND.

    The two brown wire is for the big brown inductor.
    I put the inductor near the lower left corner of my pcb,
    and the two cables goes to the middle of IC.

    Yes, this is what makes me confused, since I am a noob,
    I thought that is the view from outside. :blush:
  11. Sokol1

    Sokol1 Member

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

    This Unknow USB device message in system tray means that
    something is wrong with your new hardware.

    Apparently write firmware is OK. If you read ATMEGA16 again with PonyProg
    your see Mj16 n row 4000, in right side of codes.

    Check PCB for short circuit between trails, components, bad solder...
    If components have correctly values.
    The only polarized components are 10uF capacitor and Zener Diodes.
    From your picture they are correctly placed: Zener anode toward D-
    and D+ USB lines, 0 in 10uf capacitor toward GND.

    Sokol1
  12. Frakk

    Frakk Active Member

    Joined:
    Apr 15, 2009
    Messages:
    1,144
    Balance:
    328Coins
    Ratings:
    +4 / 0 / -0
    You might also want to check the clock select fuses. It seems that windows recognizes that there is something plugged in, just cannot communicate properly. As Sokol said, double check your components and connections, and also check your fuses.

    In ponyprog, the only bits selected (checkmark in the box) are BOOTSZ1, BOOTSZ0 and SUT1. This means these bits are 0, everything that doesn't have a checkmark means they are programmed as 1
  13. tirta

    tirta Member

    Joined:
    Feb 4, 2010
    Messages:
    56
    Balance:
    0Coins
    Ratings:
    +0 / 0 / -0
    clock select fuses?
    what is it?
    where can I find it?

    OK, I will try to check my pcb, components and connections.

    Also, I have read some old posts on this topic about CRC.
    If I check my .HEX file - before write > Open Program (FLASH) File, CRC is EA4Eh.
    The CRC of my programmed mjoy16 by clicking Read Device is 4100h
    What does this mean?
  14. Andrew91

    Andrew91 New Member

    Joined:
    Feb 8, 2010
    Messages:
    1
    Balance:
    0Coins
    Ratings:
    +0 / 0 / -0
    Hi

    I am constructing a modified version of the Mjoy16.

    I intend to modify the buttons and variable resistor setup and also use a Atmega32 (I don't have an Atmega16 on hand), and thus need to access to the assembly source.

    Does anyone know where I can get access to the assembly source?

    cheers,

    Andrew
  15. Sokol1

    Sokol1 Member

    Joined:
    Jul 6, 2009
    Messages:
    126
    Balance:
    14Coins
    Ratings:
    +1 / 1 / -1
    Assembly code for Mjoy16 is not know.
    The author, Mindaugas - that no longer support Mjoy - release to free use only .HEX file.
    Are a .eep file in 1.3 firmware package , but with only few lines of code...

    If you plan use ATMEGA32, you need create adequate code.

    ATMEGA16-16PU is very cheap in eBay: ie, with free shipping:

    http://cgi.ebay.com/2-pieces-ATMEGA16-1 ... 5d26c2bad6

    The reason to build Mjoy is the low cost and available firmware.
    If you plan create your own USB controller, think that more easy use Microchip PIC.
    These are USB 2.0 and work with high clock.

    Sokol1
  16. Frakk

    Frakk Active Member

    Joined:
    Apr 15, 2009
    Messages:
    1,144
    Balance:
    328Coins
    Ratings:
    +4 / 0 / -0
    Andrew, if you are able to modify the assembly code, I am pretty sure you can program the Atmega32 from scratch. I wish I had the time and energy to do it. Even if you did that, the Atmega32 would be an overkill for a controller like this. A simple mega8535 could do the job for fraction of the price.

    As Sokol suggested, ATmega16's are fairly cheap and you don't have to worry about the code. There is an other PIC based controller made by willynovi in this section if you want to check that out. If you want to customize your buttons and analog inputs he might be able to help you out with the firmware.
  17. MMASailor20

    MMASailor20 New Member

    Joined:
    Feb 8, 2010
    Messages:
    8
    Balance:
    0Coins
    Ratings:
    +0 / 0 / -0
    Sokol1 I was looking at that website that has the stuff on the MJOY-ENCODERS and I can't download anything from there properly...I can get the PDF, but I can't get the HEX files or anything. I've got the layout file, but I have nothing other than that. Could you perhaps point me in the right direction? The project I'm trying to build requires more than just 4 rotary encoders, so I was wanting to see about building the MJOY-ENCODERS so I could tack on some more encoders
  18. tirta

    tirta Member

    Joined:
    Feb 4, 2010
    Messages:
    56
    Balance:
    0Coins
    Ratings:
    +0 / 0 / -0
    Hi Sokol1,

    I have checked and rechecked my pcb, the position of the components,
    the soldering, the connections, and the components themselves
    and I can not find anything wrong.

    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]

    What should I do now?
    Please give me some directions since I am so confused about what to do next. :?

    And what about the difference in CRC?
    Does it mean anything?
    Please advise.
  19. Sokol1

    Sokol1 Member

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

    Your PCB and solder look very good (mine are very crap), I dont see anything wrong in your picture, no visible short circuit, bad solder...
    If you have a multimeter, try check components values.

    For CRC check previous NuMcA posts.

    MMASailor 20,

    For Mjoy-Encoders (daughter board for Mjoy16), look here:

    http://sites.google.com/site/mjoy16/root/

    Sokol1
  20. MMASailor20

    MMASailor20 New Member

    Joined:
    Feb 8, 2010
    Messages:
    8
    Balance:
    0Coins
    Ratings:
    +0 / 0 / -0
    Sokol1, I've been to the website but the download links wind me up with .rar files that don't work. I can download them fine, but they come up as an Invalid RAR file. Any suggestions?