Go Down

Topic: Arduino Due and ADK (Read 15554 times) previous topic - next topic

PeterVH

The description of the cable on the e-bay store is really weird.

It is a non standard cable, but you reported it works well with some of your phones, when connected to the due's native port. From this I deduce the ID pin inside the micro B plug is connected to ground making it actually a working micro A plug but with the wrong B (trapezium) shape.

Because of the wrong shape you can also insert it into the programming port. But the latter ignores completely the ID pin. So this makes you connected two usb devices. Nothing should happen in this case, it should cause no harm, but you are right that neither of the devices should source power.

whitewater

I did some more testing and actually got it to work ... kind of :(

I have the Galaxy S (i9000) with the CyanogenMod 9 (Android version 4.0.4). The setup works if I power the Due over the USB connection and does not work, if I power it via the power jack. Is that by design?

However, the operation is inconsistent, sometimes the enumerates the devices and gets to adk.IsReady() == 1 and most of the time it does not. I've tried to printout the status of the usb_getUsbTaskState function and get different readouts (USB_STATE_RUNNING, USB_STATE_ERROR, USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE) when plugging the phone in and out.

Sometimes it even goes to USB_STATE_RUNNING and then straight to USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE. It could be a problem with the phone, since things get better (but not ideal) after the reboot of the phone. Unfortunately I don't have any other device to try it with.

ozziii

Hi i'm new Arduino Due dev :-P

Someone may link me some ADK2012  example or tutorial (sketch + Android Project)

Thanks

Sebastian Vik

Whitewater I have the exact same problem. Some times I get it to connected state and can transfer data successfully but then other times it just doesn't work.
I haven't figured out what's wrong yet. I've had varying degrees of success on different devices. One sketch would work fine with bi-directional communication on one device but only unidirectional on the other. Another sketch would work on both. Today I only had one successful run out of perhaps ten or fifteen attempts with different very simple sketches.
I always lose packets when I try sending them them too fast from the Due, like three in a row without any time between.

And the power is weird, isn't it? Of course it should power the USB port even if it's running on an external power source!

Sebastian Vik

OK, I hope this can help figure it out.
Part of the problem, at least with the Note II, is timing. The error I get when debugging the USB host code is a timeout (error code 0xFF) on one of the USB packets. This doesn't happen if (for instance) I output a whole lot of serial data to slow the sketch down. It is not enough to add a delay() in the main loop, since the whole thing fails if we delay() too much as well. Adding a delay(50) between each call to Usb.Task() and a few delay(100) at strategic places inside USBHost::Task() makes it work pretty reliably. I haven't had the time to make it work well yet or I would post code.

Another issue is the fact that the USB code stops working if you soft-reset the Due, such as by opening the serial console after a sketch has started running. This can be worked around by uploading the sketch, then unplugging the Due and as fast as humanly possible after plugging it in, you open the debug console. I guess this works because you can actually soft-reset the Due before the USB initialization takes place, and therefore it doesn't try to initialize it twice.

If you have the phone connected to the Due and your sketch either crashes or your code is timed wrong, you might confuse the USB stack on the Android. This is only solved by rebooting. So if it stops working, you might get it running again by simply rebooting the Android. I power-cycle the Due between every run.

I ran a modified version of the ADK2012 sketch and library, compiled with the ADK2012 version of the IDE. This powered up the USB port even when running on external power, so there's nothing wrong with the hardware. There has to be a mistake somewhere in the library, I just don't have enough knowledge to find it!

twilkie

#20
Dec 24, 2012, 07:35 pm Last Edit: Dec 24, 2012, 08:41 pm by twilkie Reason: 1
Hi Sebastien

Can you share you code?  I'm trying to get my Due connected to a Nexus 7 running 4.2.1 and having no luck.  Due just charges and doesn't seem to recognise the result.

Not sure earlier comments by PeterVH about the right cable being needed are true: the source (in uotghs_host.c) seems to disable the id pin and force the Due into host mode (see otg_disable_id_pin()).  I can confirm this works, as I have a micro-B to full sized female A with a floating id pin (ie not tied to ground as it should be) but the due correctly acts as a host to a mouse using this adapter.

Do you know what the ADK code for the due is based on?  Its seems very different to both the google ADK2011 code and the ADK2012 code.

Edit: interestingly it works (reasonably reliably) with our Motorola Xoom running 4.1.2, without any modification to the sketch.  Am running with debug on.

Edit2: downgraded Nexus 7 to 4.1.2 and it still doesn't work - interestingly it doesn't even register any state change in the usb code when I plug it in.

Thanks

Tom

jangofei


OK, I hope this can help figure it out.
Part of the problem, at least with the Note II, is timing. The error I get when debugging the USB host code is a timeout (error code 0xFF) on one of the USB packets. This doesn't happen if (for instance) I output a whole lot of serial data to slow the sketch down. It is not enough to add a delay() in the main loop, since the whole thing fails if we delay() too much as well. Adding a delay(50) between each call to Usb.Task() and a few delay(100) at strategic places inside USBHost::Task() makes it work pretty reliably. I haven't had the time to make it work well yet or I would post code.

Another issue is the fact that the USB code stops working if you soft-reset the Due, such as by opening the serial console after a sketch has started running. This can be worked around by uploading the sketch, then unplugging the Due and as fast as humanly possible after plugging it in, you open the debug console. I guess this works because you can actually soft-reset the Due before the USB initialization takes place, and therefore it doesn't try to initialize it twice.

If you have the phone connected to the Due and your sketch either crashes or your code is timed wrong, you might confuse the USB stack on the Android. This is only solved by rebooting. So if it stops working, you might get it running again by simply rebooting the Android. I power-cycle the Due between every run.

I ran a modified version of the ADK2012 sketch and library, compiled with the ADK2012 version of the IDE. This powered up the USB port even when running on external power, so there's nothing wrong with the hardware. There has to be a mistake somewhere in the library, I just don't have enough knowledge to find it!


Could you share the setup you did? Thanks.

#22
Dec 29, 2012, 05:16 pm Last Edit: Dec 29, 2012, 05:27 pm by aleu Reason: 1
I could get the ADKTerminalTest demo to work without changes with a
- Galaxy Nexus / Android 4.2.1
- Nexus 7 / 4.2.1
- Acer A500/4.0.3.

First I had the same problems: only loading, nothing else. It started to work after I connected the Due directly with my Macbook (i.e. no hub in between etc.). If a power supply is connected, it does _not_ work either. To me, it looks like a power issue.

My setup:
Macbook -> Due/programming port (as I said, no hub/other device on that port)
Due / native USB -> USB-OTG adapter (Samsung ET-R205U) -> USB cable -> Android device

The due runs the ADKTerminalTest sample (I just added Serial.begin(9600) at the beginning of setup()). The android device runs the "Thibault ICS Termial" app as stated in ADKTerminalTest.
refined-apps.com

And we have "Hello World"!  Thank you aleu :D
added Serial.begin(9600); to Sketch
Running MacPro->Due Programming Port->
  Due NativeUSB-> USB adapter->Nexus 7 4.2.1->"Thibault Terminal" App

  edit- Tried on my Nexus S running 4.0.4 with no luck but that could be for any number of reasons....

jangofei


I could get the ADKTerminalTest demo to work without changes with a
- Galaxy Nexus / Android 4.2.1
- Nexus 7 / 4.2.1
- Acer A500/4.0.3.

First I had the same problems: only loading, nothing else. It started to work after I connected the Due directly with my Macbook (i.e. no hub in between etc.). If a power supply is connected, it does _not_ work either. To me, it looks like a power issue.

My setup:
Macbook -> Due/programming port (as I said, no hub/other device on that port)
Due / native USB -> USB-OTG adapter (Samsung ET-R205U) -> USB cable -> Android device

The due runs the ADKTerminalTest sample (I just added Serial.begin(9600) at the beginning of setup()). The android device runs the "Thibault ICS Termial" app as stated in ADKTerminalTest.



Did you download ADKTerminalTest  from :https://github.com/arduino/Arduino/pull/127/files#diff-720? I couldn't download it. Could you send it to me? Thanks.

I used the version that comes as sample with the arduino ide version 1.5.1/mac (file menu -> samples -> USBHost -> ADKTerminalTest) and the apk from the address in the ADKTerminalTest sketch (http://labs.arduino.cc/uploads/ADK/ArduinoTerminal/ThibaultTerminal_ICS_0001.apk).

refined-apps.com

jangofei


I used the version that comes as sample with the arduino ide version 1.5.1/mac (file menu -> samples -> USBHost -> ADKTerminalTest) and the apk from the address in the ADKTerminalTest sketch (http://labs.arduino.cc/uploads/ADK/ArduinoTerminal/ThibaultTerminal_ICS_0001.apk).




Thank you very much! I will try it.

Uno_Then_Due

Here's a software solution that might work:
Code: [Select]

pinMode(PB11,OUTPUT);
digitalWrite(PB11,LOW);

cmassicot

#28
Feb 25, 2013, 04:15 pm Last Edit: Feb 25, 2013, 04:32 pm by cmassicot Reason: 1

The example that comes with Arduino 1.5.2 works on a Nexus 7 with Android 4.2.2 using this cable http://hakshop.myshopify.com/products/micro-to-micro-otg

I am running ADKTerminalTest.ino on the Arduino side and http://labs.arduino.cc/uploads/ADK/ArduinoTerminal/ThibaultTerminal_ICS_0001.apk on the Android side

Does anyone know where to find the source code for the Android example (ThibaultTerminal_ICS_0001.apk)?

Thanks

cmassicot

Eriker

#29
Mar 01, 2013, 06:07 pm Last Edit: Mar 01, 2013, 09:34 pm by Eriker Reason: 1
Work on HTC One X, running 4.1.1. With adding Serial.begin(9600), thanks aleu.

Please check the video: http://arduino-er.blogspot.com/2013/03/adk-running-on-arduino-due.html

Go Up