0
\$\begingroup\$

I am new to this topic and did a lot of research but could not find a solution to my question.

What I want to do: I want to attach something directly (I do not want to add a microcontroller) to the micro usb slot of my phone to power and control it (I want to use my phones power to power something else). I will use the 5V voltage that usb can give me (as far as I know I will have to use a USB OTG compatible device, but that is not the issue). So far so good. What I additionally want to do are the following two things:

  1. I want to control the power.

1.a) Is there a way (Writing app or ...) to get my phone to output usb pwm?

1.b) I dont necessarily need the fast rate of pwm. So is there any way (Writing app or ....) to turn on and off the power of the usb output?

  1. Can I read incoming data while powering and can they be outside of the usb protocol? This is supposed to mean: Once my Phone has done its work I want to give a signal onto the D- and/or D+ of the usb cable to tell the phone that it should stop giving power. That signal will not be in the usb protocol but will rather just be some voltage. For that I would need to be able to directly read the usb income and control my phone based on that. Is that possible? In Short: When I want to be done powering I put a Voltage of e.g. 3.3V onto D-/D+ and the phone notices this and turns of the power. So the questions are:

2.a) can I power something and read data over the same usb at the same time?

2.b) can I directly read the D-and D+ pins and use them to control my program?

Thank you very much.

\$\endgroup\$
  • \$\begingroup\$ This question is far too broad and too vague to answer in any meaningful way. You'll have to be a lot more specific about what you want to accomplish. \$\endgroup\$ – Dave Tweed Nov 12 '16 at 14:47
  • \$\begingroup\$ What materials did you read about USB before making this wish list? \$\endgroup\$ – Ale..chenski Nov 12 '16 at 17:28
0
\$\begingroup\$

It's completely possible. Just very very unlikely. OTG power is sometimes handled through a Power Management Unit, or an independent OTG power controller. Some are accessible via I2c or other bus protocols, while others are built into the main processor. Either way, they are handled by the underlying OS.

You could modify how it works, but it would require in depth hacking and coding of the OS, kernel, modules, etc. For example, there were some android phones that had hardware supporting OTG but not enabled in software. Some support OTG but not charging while OTG. Some had FM radio hardware but not enabled stateside. All that was needed was changes to code. A complete understatement of course. PWM control may be feasible but your going to have to put much work in to figure it out.

A microcontroller middleman would be simpler.

| improve this answer | |
\$\endgroup\$
5
\$\begingroup\$

I want to control the power.

1.a) Is there a way (Writing app or ...) to get my phone to output usb pwm?

No.

1.b) I dont necessarily need the fast rate of pwm. So is there any way (Writing app or ....) to turn on and off the power of the usb output?

Highly unlikely.

Can I read incoming data while powering and can they be outside of the usb protocol? This is supposed to mean: Once my Phone has done its work I want to give a signal onto the D- and/or D+ of the usb cable to tell the phone that it should stop giving power. That signal will not be in the usb protocol but will rather just be some voltage. For that I would need to be able to directly read the usb income and control my phone based on that. Is that possible? In Short: When I want to be done powering I put a Voltage of e.g. 3.3V onto D-/D+ and the phone notices this and turns of the power. So the questions are:

No.

2.a) can I power something and read data over the same usb at the same time?

Not in the way you talk about, no.

2.b) can I directly read the D-and D+ pins and use them to control my program?

No.

USB is USB. You cannot use it for anything except USB.

You set the type of device (HOST or DEVICE) by setting the USBID pin (pin 4) of the USB socket to the right voltage (GND or 5V [I forget which is which off hand]). The phone then either enables or disables power from the VBUS pin (pin 1).

Any signalling is then performed using LVDS on the D+ and D- pair conforming to the USB protocol specification.

The only exception to this is when the phone is connected to a charge-only port where the static state of the voltages on D+ and D- indicate the current the charger can provide. This is done (usually) in hardware.

If you want to do anything at all through the USB other than just sucking power out of your phone you will need to add an active element that speaks USB. That could be a microcontroller, or it could be a discrete USB chip, such as an FT232 or similar device (there's many different options on what IO protocols and facilities are provided on the different chips - from UART through SPI/I2C, to parallel).

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.