-
Notifications
You must be signed in to change notification settings - Fork 795
Arduino Mega ADK support in USB Host Shield 2.0 library #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…, which seems like a most suitable place for such things; - Added pin define for Pj2; - Use newly created BOARD_MEGA_ADK #define for separating Mega ADK-specific code from the common code.
|
Thanks! |
Arduino Mega ADK support in USB Host Shield 2.0 library
|
Hi, Also wouldn't it be better to replace the following lines: DDRJ |= 0x04; with: DDRJ |= _BV(PJ2); As it's more readable? Regards |
|
Hi, This is not my code - I just accepted a pull request from some guy a Oleg. On 3/16/2012 10:10 AM, TKJElectronics wrote:
|
|
Hi, Regards |
|
OK. Have you seen my reply to your question about my shields? On 3/16/2012 10:25 AM, TKJElectronics wrote:
|
|
No. I haven't received any email from you - I just checked my spam folder, but nothings there. |
|
If you need those shields for yourself, I can send you a couple for On 3/16/2012 10:33 AM, TKJElectronics wrote:
|
|
Thank you - and yes it's only for personal use :) |
|
Hi, |
|
Hi, Pj2 is the reset pin and Pe6 is the INT pin - see the schematic for more info: http://arduino.cc/en/uploads/Main/ADK_MEGA_2560-Rev2-sch.pdf also see the library at google's page: https://dl-ssl.google.com/android/adk/adk_release_0512.zip - see Max3421e.cpp line 39. As I understand it, you used the reset pin (Pj2) as the INT pin? The reason why I think it worked anyways, is because most sketches doesn't used the INT pin, so it works even if you haven't selected the right one. Oleg please correct me if I'm wrong? |
|
I don't know much about this board, nor do I care. As long as your mods don't touch the main code I'll accept anything. |
|
Kibab, have you implemented anything using the USB shield and Arduino Mega ADK ? |
|
Rolfarley if you are looking for an example, have a look at the following code: https://github.com/felis/USB_Host_Shield_2.0/blob/master/examples/adk/ArduinoBlinkLED/ArduinoBlinkLED.ino |
|
Thanks. Did you have the Android device plugged into the USB port from the USB shield for this ? |
|
Yes of course. That's how they communicate. |
|
Okay, thanks. I have a USB based sensor in my case and was using the Arduino Mega ADK. I need to pass the sensor data from the USB sensor to my Android handset and was intending to communicate between the Arduino and handset using the Mega ADK USB and communicate between the Arduino and sensor using the USB shield. (just wondering do I really need the USB shield in that case..can I connect a USB hub with the Arduino Mega ADK and plug the USB sensor and handset into the hub) |
|
You simply add this line https://github.com/felis/USB_Host_Shield_2.0/blob/master/examples/hub_demo/hub_demo.pde#L12 to your code. You might need to add more of them as shown, as there can be more IC's in one usb hub. |
|
Thanks very much, will try that out |
|
Lauszus, when I try the ArduinoBlinkLED sketch (using the Arduino Mega ADK and the USB shield) I can't control the LED when I have my Android handset plugged into the USB Shield port (I've uncommented the #define BOARD_MEGA_ADK in the avrpins.h header file). (Only if I have it plugged into the USB port of the Arduino Mega ADK does it control the LED -- if I want to use the USB from the shield is there something I'm missing ?) |
|
Rolfarley, |
|
Lauszus, |
|
Rolfarley, |
|
Lauszus, thanks for clarifying, I've been using the USB Hub sketch examples you mentioned above on the ADK itself (without the shield) and they're working alright. I should be able to find a small enough two port mini hub to satisfy a quick prototype. |
|
Rolfarley, |
|
Lauszus, I'm struggling a bit on how to communicate with my USB sensor - I can extract data from it using a basic hyperterminal (115200, 8 bits no parity) and want to basically grab/read the same data from Arduino Mega ADK. I've used the USB Hub Sketch example when it is plugged into a mini HUB along with an Android phone and see the two ports enumerated. Can you point me to any sketch or example ? |
|
What type of USB sensor are we talking about. Is it just a basic FTDI device? If so have a look at this example: https://github.com/felis/USB_Host_Shield_2.0/blob/master/examples/ftdi/USBFTDILoopback/USBFTDILoopback.pde |
|
Thanks once again, modified that sketch and am getting the sensor data, on my way to completion |
|
Hi once again, I'm having issues with my interface to the Android Handset - the first data sent goes through, but all subsequent data I send using adk.SndData gets a return code of hrNAK (4). The Android application on my phone appears to still be running fine (although I'm having trouble debugging or seeing what's going on - I thought I could use "adb wireless" but I can't have it running while I have my handset connected to the Arduino) void loop() |
|
Hi again, try to change this line: But it will give more sense just to check if there is an error or not. Take a look at this line: https://github.com/felis/USB_Host_Shield_2.0/blob/master/examples/adk/ArduinoBlinkLED/ArduinoBlinkLED.ino#L35-36 Try to post the rest of your code somewhere - for instance at gist: https://gist.github.com/, then I will have a look at it. |
|
Here is the full Arduino sketch: https://gist.github.com/4067762 I'm sending just dummy data now (was sending from USB based sensor initially but had the same issue). I have an Android charting app running and I get the first value, but each subsequent one from the Arduino I get an rcode of 4 (hrNAK) from the adk.SndData function and the Android charting app doesn't receive. |
|
The code looks alright. It might be related to your Android code. Take a look at this excellent guide: http://allaboutee.com/2011/12/31/arduino-adk-board-how-send-data-from-the-board-to-the-android-device/ |
|
Thanks, very much, appreciate it. |
|
Hi all. //sketch #include <avr/pgmspace.h> After I had compiled the sketch above and I had the folloiming errors. can someone please help? //errors generated after compilation In file included from USBcomarduionokeyboard.cpp:4:0: |
|
There is no need to modify the code. Simply just set this value: https://github.com/felis/USB_Host_Shield_2.0/blob/master/settings.h#L32 to 1 instead ;) |
|
oups! sorry I don't know why the libraries did not appear in the comment above but here there are in the same order |
|
Don't include all those includes, they are no longer needed. You only need On Fri, Nov 29, 2013 at 2:14 PM, bricol notifications@github.com wrote:
Visit my github for awesome Arduino code @ https://github.com/xxxajk |
|
Oh, also, include Arduino.h On Fri, Nov 29, 2013 at 2:20 PM, Andrew Kroll xxxajk@gmail.com wrote:
Visit my github for awesome Arduino code @ https://github.com/xxxajk |
|
@xxxajk it is not needed. It will be included if he includes Usb.h. |
|
I have applied the changes you (Lauszus) suggested but to no avail I have the following errors. Am I to make changes suggested to Kibab ? //errors |
|
when I include just Usb.h I have the following errors : In file included from /home/pifou/sketchbook/libraries/USB_Host_Shield_20_v1/usbhost.h:22:0, |
|
I am certain I have no problem with the libraries but if anyone has succesfully communicated between keyboard and arduino ADK over USB, may I have the sketch and the a link to the libraries. I later on adjust the sketch to fit the RFID reader. |
|
Do you include Arduino.h? On Fri, Nov 29, 2013 at 2:49 PM, bricol notifications@github.com wrote:
Visit my github for awesome Arduino code @ https://github.com/xxxajk |
|
Just do exactly as the error messages say... DO NOT include the following in your sketch: max3421e.h Once you eliminate those includes in any of your files in your sketch I don't understand what you do not understand about the message, it is On Fri, Nov 29, 2013 at 3:40 PM, Andrew Kroll xxxajk@gmail.com wrote:
Visit my github for awesome Arduino code @ https://github.com/xxxajk |
|
Looking closer at your error messages, you must remove the include lines On Fri, Nov 29, 2013 at 3:48 PM, Andrew Kroll xxxajk@gmail.com wrote:
Visit my github for awesome Arduino code @ https://github.com/xxxajk |
|
@bricol notice the status of this pull request: "Merged". This means that the changes done by Kibab is added to the code, so you should NOT modify the code in anyway. The only thing you change is setting the value Please do that and try one of the examples and report back if it is working or not :) |
|
Also note that if you are using the newest version of Arduino - which is 1.5.5. You do not have to modify anything, as it will automatically detect if an Arduino ADK is used :) |
|
@Lauszus thanks once more for your collaboration. I have downloaded the library and changed the USE_UHS_MEGA_ADK to 1 as you suggested. when I try to compile the acm_terminal example it compiles but when I connect a keyboard to the arduino ADK USB port, I have no output on the serial monitor except "start". Is the aim of this example to print input characters from the keyboard? |
|
@bricol you should use the following example: https://github.com/felis/USB_Host_Shield_2.0/blob/master/examples/HID/USBHIDBootKbd/USBHIDBootKbd.ino if you want to use a keyboard with the ADK. |
|
@Lauszus interesting !! I have compile the USBHIDBootKbd.ino and IT WORKS. Thanks. Super !! Now I have started thinking about proceeding with the USB RFID/barcode reader (can read both RFID and barcodes). I found the adk_barcode.ino amongst the examples and it seems logicial to me that I can use it to receive data from the reader. It compiles but on the serial monitor I can only see "ADK demo start" but no data from the scanner. Do you how I can access the data from the reader? Thanks |
|
Please read all these posts: http://www.circuitsathome.com/?s=barcode. The adk_barcode example is described in this post: http://www.circuitsathome.com/mcu/exchanging-data-between-usb-devices-and-android-phone-using-arduino-and-usb-host-shield. |
Move librespot into lib.rs and let main.rs be the test binary
I jumped the gun
Updating personal fork
Hi Oleg,
thank you for your great work, USB Host Shield is really very useful software! One thing I've noticed is that it doesn't support Arduino Mega ADK board (designed by Google based on your USB host shield).
On Mega ADK, USB host controller Max3421e is already on the board, and it uses different pins for SPI SS, MAX INT and MAX RST. Thus some pins should be different for Mega ADK board.
I have added support for Mega ADK in this pull request. First of all, as Arduino IDE doesn't provide any way to set project-wide C++ conditional defines, I chose avrpins.h as a place for BOARD_MEGA_ADK #define. This file is included both by Usb.h and usbhost.h, where modifications should be made to make Mega ADK work.
The only modifications required are some pin differences and explicit reset line pull-up. I'm not sure that I did it in the most beautiful way, please correct me if nessesary.
Hope you'll find this work useful.