Arduino Due and ADK

...the programming port is powered; I can charge my phone over it! It's not supposed to power the programming port, right?

It should not even be possible to make such a connection: the usb spec only defines these cables for this use:

  1. micro B plug to standard A plug (the regular pc to phone cable).
  2. micro A plug to standard A receptacle (what massimo referred to)
  3. micro A plug to micro B plug (never seen this for sale)

You can plug cable 1 into cable 2, then you end up with the same thing as cable 3. So you always end up with an A plug on one end and a B plug on the other. The B plug goes in the phone. The A plug has a rectangular section and should only fit in the native usb port (micro AB connector) of the due. It should not fit in the programming port (micro B connector, trapezium shaped section)

So how did you make the connection?

  • did you put the A end in the (otg capable?) phone?
  • do you have a non std cable? (on ebay I saw cables that look like standard A receptacle to micro B shaped plug, but it is difficult to tell from the pictures)
  • does the due have a micro AB connector (rectangular shape) for the programming port? (I am still waiting for my due, so I can't see for myself)

I use a cable like this one on the Due side: http://www.ebay.com/itm/Micro-USB-Host-OTG-Cable-W-USB-power-Samsung-phone-i9100-i9300-i9220-9250-/150928276246?_trksid=p2047675.m1850&_trkparms=aid%3D222002%26algo%3DSIC.FIT%26ao%3D1%26asc%3D11%26meid%3D3299974227435379446%26pid%3D100011%26prg%3D1005%26rk%3D1%26sd%3D110931117836%26
It plugs into either the programming port or the native port. On the other end I use a normal USB charging cable (#1 in your list).

Is it simply because I'm using the wrong cable? But the host port powers up when the programming port is connected to the PC!

EDIT: The special cable acts like a normal OTG cable with the option of external power supply (not used in this case)

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.

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

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.

Hi i'm new Arduino Due dev :stuck_out_tongue:

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

Thanks

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!

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!

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

Could you share the setup you did? Thanks.

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.

And we have "Hello World"! Thank you aleu :smiley:
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....

aleu:
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).

aleu:
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.

Here's a software solution that might work:

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

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

Work on HTC One X, running 4.1.1. With adding Serial.begin(9600), thanks aleu.

Please check the video: Arduino-er: ADK running on Arduino Due

I tried Samsung i9100 CyanogenMod nightly 4.2.2 is working
There are no source code of ThibaultTerminal.apk?

Hi everyone,
I am aiming at a different problem than what this forum is expected to discuss, but, I believe people on this thread are the best to suggest me on my problem.

Problem: I am trying to transfer some data (24 bytes) to ADF4350 which is a Phase lock loop. The board I am using has a USB interface to connect to the ADF4350 chip. I am using arduino due to generate the required data and then transfer it to the board.

Untill now I have made the physical connection required to make Arduino Due the Host and the Board as the device. I am using a Micro-A USB plug to Standard A receptable and on the other end I use a mini-B Usb cable. I hope this physical connection is perfect. I have successfully generated the data on the Arduino Due.

Now I am aiming to transfer the data to the board. Can anyone please suggest how should I amend the USBHost library to get the work done?