raacampbell / openstage

Arduino-based microscope stage controller
GNU Lesser General Public License v3.0
41 stars 15 forks source link

Issue on connecting USB host shield with Mega ___"board.qc" fail to work #10

Open jason12333 opened 7 years ago

jason12333 commented 7 years ago

Hi, Rob! My name is Jason, a graduate student. After reading your paper and stage build, I am also quite interested in building my own motorized stage with relatively cheap motors to replace the expensive linear ones. The idea of using Joystick to control the stage movement is very innovative, which is also successful for the high precision gained. However, as I started to testing my PS3 controllers as a pure input device, I found it hard to connect it with my Arduino Mega. As I ran the board.qc file, it keeps showing me the error

USB Host Shield Quality Control Routine Reading REVISION register... Die revision invalid. Value returned: 00 Unrecoverable error - test halted!! 0x55 pattern is transmitted via SPI Press RESET to restart test.

(even after I pressed the Reset button several times). I am now using a Sparkfun shield and wiring the jumpers exactly the same as you did in the paper. On the other hand, if I ran the PS3USB file, then it'll show me "OSC did not start", which I am not quite sure what that OSC is. Luckily, as I tried stacking the Sparkfun shield on the Uno board with pin 7 of the shield connected to the Reset of the shield. It then works well (since the SCK,SIMO,MOSI and SS pins of both boards are on the same locations).

So my question is, is it the connection of SCK, MISO, SOMI AND SS the key point of this whole design? and why I should connect the pin 53 to the pin10 on the Mega board? (Since I am doing exactly the same as you did but have not gotten the same good result, and I found that pin10 is of no specific use) Is there any way else that I can do to succeed the Mega connection with the shield? Are there any notices I should pay attention to apart from the ones you mentioned in your paper? I am quite looking forward to your reply! Thank you so much for your help!

raacampbell commented 7 years ago

I used the SparkFun shield also. It looks like you're running into the same error I did when I first tried this. Does this post help?

jason12333 commented 7 years ago

Thank you so much for your respond, Rob! However, even though I did exactly the same as the post and your paper (including connecting pin10 to pin53 on the mega board), still it gives me "OSC did not start" in the PS3USB example file and the same error in the board.qc .

So is there any other things I should try using?

I checked all my wire connections and use 2 different mega boards. Since the shield works well with the Uno, there shouldn't be any problem with the shield or the soldering of the shield. So is this still about the connection between the shield and the mega?

Why we need the connection between the pin10 and pin53 on the mega board?

Thank you for your time!!

raacampbell commented 7 years ago

I agree that probably it's just a wiring issue with the Mega. I don't remember the reason for the jumper wire, however I see from my post that in principle four jumper wires may be needed. Not just pin 10 to pin 53. So you could try adding the other three and seeing if that helps. If it continues to fail, then I suggest you add a reply to my old post and see what comes back. That way others with the same problem will have the answers in the same place. It looks like in the PCB also I have only jumpered pin 10. Maybe something has changed in the Mega since I first built the controller.

jason12333 commented 7 years ago

Thank you so much for your answer, Rob! However, actually, I have already connected the 4 pairs of pins together, which are 13-52, 12-50, 11-51 and 10 to 53. But what I mean is that I noticed you mentioned connecting pin10 on the mega to pin53 on the mega, too (which is noted in your build_instructions(github)), whose reason I have not quite figured out yet.

So by saying adding the other 3, do you mean what I meant in the very beginning? Or you mean I should also connect pin50,51,52 to itself pin 10 also?

Well, since I have successfully demoed it using the Uno. I do not believe that there should be any difficulties or differences of demoing it in Mega as long as I got the right pin connections. (PCI configuration, the Vin, the GND and the Reset)

Do you suggest changing any code of the library s.t. it will work?

Again, thank you so much for your help! I will follow the same issue in your Arduino forum post as well.

raacampbell commented 7 years ago

No, I don't mean connecting everything to pin 10. I mean 13 to 52 and so forth. To make sure we're both on the same page: I remembered why the jumpering is needed. The USB host shield is set up to plugged into an UNO. The Mega and the Uno have their SPI connections on different pins. The host shield is set up for the Uno configuration. So SS is mapped to pin 10 on the Uno but pin 53 on the Mega. If you stack the host shield on to the Mega you will need to jumper all the pins. If you have them side by side and connect with wires you shouldn't have to. For some reason I noted that 10 and 53 had to be jumpered together anyway. This makes no sense, but that's what I encountered. Perhaps I made a mistake somewhere along the line and this is what led to this.

TryChick commented 7 years ago

I'm having the same issues and jumper-ing all those pins made no difference. I still get that error. If the host shield is separated from the mega, which pins on the usb host shield need to be connected to which pins on the mega? Then also run 9v battery to shield vin and gnd, then jumper gnd to mega gnd?

raacampbell commented 7 years ago

I run it with the host shield separated and the pins wired like this. I never had problems with this configuration, but I'm using hardware from 2014 and maybe something changed in the mean time. I'm also using a PCB, so there aren't any wires to come loose. The version of the PCB I'm using is in the repository. There is also this one which should have some wiring bugs fixed but hasn't been tested.

praveenmalav09 commented 6 years ago

I connect USB shield according to your diagram but when i upload code of USBHIDBootkbd then i got start OSC did not start.

i connect 52->13 50->12 51->11 53->10 and RESET to pin 7. please help. How can i connect Arduino USB shield to Arduino mega?

raacampbell commented 6 years ago

I can only offer the information above, I'm afraid. I don't have a running system at the moment and it's also possible you have a different version of the host shield than I had, since I did this about 5 years ago. Your best bet is to ask on the Arduino forum, as this is a general question and they can likely help you.

AK-UGlas commented 6 years ago

Hi all, I came across the exact same problem too, and I stumbled across a solution the other night while looking through various forums. I think some of the USB host shield libraries have been updated since Rob made his initial publication. One website recommended looking at the library "UsbCore.h", which has a section at the start defining the pin configurations for different boards. Here, there are two references to the arduino mega:

`/ shield pins. First parameter - SS pin, second parameter - INT pin /

ifdef BOARD_BLACK_WIDDOW

typedef MAX3421e<P6, P3> MAX3421E; // Black Widow

elif defined(CORE_TEENSY) && (defined(AVR_AT90USB646) || defined(AVR_AT90USB1286))

if EXT_RAM

typedef MAX3421e<P20, P7> MAX3421E; // Teensy++ 2.0 with XMEM2

else

typedef MAX3421e<P9, P8> MAX3421E; // Teensy++ 1.0 and 2.0

endif

elif defined(BOARD_MEGA_ADK)

typedef MAX3421e<P53, P54> MAX3421E; // Arduino Mega ADK

elif defined(ARDUINO_AVR_BALANDUINO)

typedef MAX3421e<P20, P19> MAX3421E; // Balanduino

elif defined(__ARDUINO_X86__) && PLATFORM_ID == 0x06

typedef MAX3421e<P3, P2> MAX3421E; // The Intel Galileo supports much faster read and write speed at pin 2 and 3

elif defined(ESP8266)

typedef MAX3421e<P15, P5> MAX3421E; // ESP8266 boards

elif defined(ESP32)

typedef MAX3421e<P5, P17> MAX3421E; // ESP32 boards

else

typedef MAX3421e<P10, P9> MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560, Leonardo, Due etc.), Intel Edison, Intel Galileo 2 or Teensy 2.0 and 3.x

endif`

If you look at the code directly you'll see reference in the comments to "Arduino Mega ADK" as well as "Mega" and "2560" in the the official arduinos pin definitions.

I don't know what the difference is between the first reference to "Arduino Mega ADK" and the Mega refered to in the "Official Arduinos" list, but to get around the issues, I simply changed "P10" to "P53" in the Official Arduinos section and now the USB host shield works with the Mega when I run the board_qc sketch. There is also no need to jumper the Mega pin 10 to pin 53, as is defined in Rob's paper

I've so far tested it with 2 example sketches using a PS3 controller (PS3USB.h) and an Xbox wireless controller (XBOXRCEV.h) and both work fine. It works with the Openstage PCB now as well, although more testing is required before i'm entirely happy that everything is fine.

Hope this helps