-2
\$\begingroup\$

The issue: I want to use Android smartphones to control servo motors. I do NOT want to use external modules like IOIO or any other.

The Proposal: use whatever serial communication channels available...This can be the Data+/- in the USB bus, or the Data[0,1,2] in the SD card bus. It really does not matter since all what I want is a GPIO.

Explanation:

  • I am aware that the Android OS will interrupt the operation of the PWM, but let's neglect this issue for now.
  • The control signal of a servo motor is a square wave [PWM] of 50Hz frequancy. A positive pulse width of 0.5ms will cause the servo horn to deflect +90 degrees, while 2.5ms will cause it to deflect -90 degrees. 1.5ms is 0 degrees. The output high voltage is typically 3V, low voltage is 0V.

Is this idea possible:

1) Theoretically?

2) Practically?

\$\endgroup\$
4
  • 2
    \$\begingroup\$ The audio port and the LED output are two sources of outputs, although the voltage of each is probably too low for the PWM detector on the servo, so you'll need some driver to boost it. Also, the audio port only has a 24 kHz bandwidth (at best) which may not be enough to give you the clear square wave the servo will work best with. Given that you need servo power anyway, why is putting an IOIO board in the same box as the battery for the servo motor not an option? It's what it's for. \$\endgroup\$
    – Jon Watte
    Commented Nov 4, 2013 at 5:23
  • \$\begingroup\$ I want to control 3 servos, that's why I am considering SD since it has 3 channels. I want the minimalist solutions, so IOIO is not an option for now. \$\endgroup\$
    – student1
    Commented Nov 4, 2013 at 5:34
  • \$\begingroup\$ The notification led is very hit or miss on devices, from crappy drivers to missing on many. Same goes for the flash led, and the power it draws on the ones that do have them would make it impractical @JonWatte but good thinking. \$\endgroup\$
    – Passerby
    Commented Nov 4, 2013 at 5:37
  • \$\begingroup\$ Theoretically: Modern mobile phones simply do not offer the low level access to physical peripheral lines (USB, SDIO, Audio) that is required. Practically: No. \$\endgroup\$ Commented Nov 4, 2013 at 8:54

5 Answers 5

3
\$\begingroup\$
  1. Theoretically, if you can drive arbitrary signals out of this pins, it could work.

  2. However, practically, it is highly unlikely to work. First, the USB pins are probably driven from a USB PHY chip and so they will only be able to transmit differential USB data. Unless you can fake a USB host on the other end, it may be impossible to transmit anything over the USB pins. Even if you could, I'm not sure if the operating system would allow the necessary control. The Micro SD card pins would be a similar story. They are likely driven by an internal SD card controller module, and you would be limited by the capabilities of the module and the interface provided by the operating system. Without having a card connected, it may be impossible to get anything out of the pins. With a card connected, you could be hard pressed to get the signals you want out of the pins.

\$\endgroup\$
3
  • \$\begingroup\$ Thanks, I have looked at a Galaxy S4 tear down and found that it does not have a PHY chip to control the USB, but still not sure about the SD. If that is the case, then I am in a truble, but still, can't I hack the signal before going to the Phy chip? OK, not an easy job, but is it possible? In software, I guess I need to replace SD software with PWM one, but this require Android professional, but again, in principle it should be doable. \$\endgroup\$
    – student1
    Commented Nov 4, 2013 at 5:41
  • 3
    \$\begingroup\$ Well, it probably has a USB PHY module inside of whatever SOC or ASIC the USB port is connected to. If it supports USB, it has to have USB PHY somewhere, but it doesn't have to be its own chip. \$\endgroup\$ Commented Nov 4, 2013 at 6:03
  • \$\begingroup\$ Oh, you are right, I missed that point! \$\endgroup\$
    – student1
    Commented Nov 4, 2013 at 16:16
4
\$\begingroup\$

The SD bus has 4 data lines (D3:D0), a CMD line and a CLK line. It will not be driven with GPIO pins, it will be accessed through a hardware SD controller peripheral, quite possibly one built into the phone's microprocessor. That said, it's possible that your particular CPU might be able to reconfigure those pins for GPIO.

The problem that you have is that you're imposing unrealistic constraints on your design. Get yourself a Bluetooth module, attach an MCU (just about anything with a UART and three hardware PWM peripherals), add a power supply, servo drivers (if TTL logic isn't sufficient) and some headers to connect everything up and have done. Even better, if you google you'll almost certainly find something ready to go, with an Android app already written to drive it.

If you're such a masochist that you must drive it from phone hardware, use frequency-division multiplexing to combine three ASK audio signals (say, 11kHz, 13kHz, 15kHz) on a headphone output, using the required PWM duty cycle to modulate each signal. Use a detector for each of the three frequencies that will output a logic high when the target frequency is input. Connect those outputs up to your servos.

\$\endgroup\$
1
  • \$\begingroup\$ Hobby servos use a PWM pulse witdh of 1000 to 2000 us. A 11 KHz signal with filter would not have enough discrimination to get you more than 10 discrete steps between the two ends. \$\endgroup\$
    – Jon Watte
    Commented Nov 5, 2013 at 17:51
2
\$\begingroup\$

Theoretically, everything is theoretically possible if you through enough money or time into it. Design an Android device from scratch with the options you want. Hack a cell phone to connect to available software controllable gpio.

But not practical.

You have a few options. The audio port could be PWM, giving two channels. This app lets you do it for free. You might even connect it directly to a servo if the signal level is high enough, but you might need an op-amp, or a microcontroller in the middle.

The other options are wireless. Bluetooth, or Wifi. Again, you would need a microcontroller or a router for this, but it will be infinitely more practical and already have been done, compared to trying to use low level usb data pins or sd card pins that are not directly controlled by software anyway.

\$\endgroup\$
3
  • \$\begingroup\$ Well, the reason why I am considering SD bus is that it has 3 channels, and I need to control 3 servos. But apart from that, if the signal level is ~3v then what issues do you think will be a problem? I do not want to use a microcontroller, otherise I'll simply buy IOIO. \$\endgroup\$
    – student1
    Commented Nov 4, 2013 at 5:36
  • 2
    \$\begingroup\$ @ali8 a microcontroller could be a dollar or two, used with the audio output. You could even program a way to get three channel encoded data from the phone through the audio, decode it with a microcontroller, which controls the three servos. And that is device independent, would work on any audio port. \$\endgroup\$
    – Passerby
    Commented Nov 4, 2013 at 5:39
  • \$\begingroup\$ I see, the price wasn't the issue for me, I simply wanted to have a single device (smartphone), but thanks anyway. In such a case I'd simply go for a microcontroller with a built in PWM channels. \$\endgroup\$
    – student1
    Commented Nov 4, 2013 at 5:50
1
\$\begingroup\$

This would be fairly easy to do using the audio output.

If the output's likely AC coupling (or filtering in the audio layer, sample rate converter, etc) distorts the pulse beyond trivial recovery, then you could modulate an audio signal at the high end of the audio bandwidth. A quite simple external circuit can demodulate by detecting the presence of this signal and generating a binary (on or off) output.

You could handle two servos by using the left and right channels, but in the analog RC systems PWM servos were designed for, channels are multiplexed by sending a pulse for each channel in turn, then a gap before the channel set repeats in the next frame (frames typically come about 50 times a second). A simple decoder demultiplexes to each servo jack in turn, and resets on the gap. Traditionally this was something like a 4017? counter, but today it would be simplest to do it with a low-end microcontroller.

You could also do this with an asynchronous serial data stream between the phone and decoder, rather than a multiplexed PWM one, comparable to how radios in the late 80's started using a PCM format over the air while still driving PWM to the servos.

Another option would be to generate a frequency proportional to the desired pulse width and measure it externally, for example you could use a frequency-to-voltage converter feeding a sawtooth & comparator PWM modulator.

\$\endgroup\$
0
\$\begingroup\$

You can control DC motors from an Android smartphone without a separate controller modules, but you will still need external circuitry. The two ways I've seen this done are through a USB to parallel printer cable or through a headphone jack as other answers here have suggested. In the USB to parallel approach, instead of trying to drive a motor directly off of a USB signal, you would use the USB serial interface per intended design and use other electronics, but not a separate micro controller, to provide the signal to the motor. Read more about this approach at http://terakuhn.weebly.com/phone_usb_controller.html.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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