skip menu and go to main content

body start

Android Accessory

Wiki

Project News

Project Info

  • User Interface: Other Interface
  • Member count : 8
  • Registered:  : 2011.07.26
  • Activity Percentile:  : 80%

activity viewforum,download view


1 Overview

Control Servo Motor by Android ADK app.

2 What you need

  • ADK Board
  • ADK IO Kit
    • Servo Motor

3 Knowledge Base

3.1 Servo Motor

A servo motor is an entirely different story. The servo motor is actually an assembly of four things: a normal DC motor, a gear reduction unit, a position-sensing device (usually a potentiometer—a volume control knob), and a control circuit.

The function of the servo is to receive a control signal that represents a desired output position of the servo shaft, and apply power to its DC motor until its shaft turns to that position. It uses the position-sensing device to determine the rotational position of the shaft, so it knows which way the motor must turn to move the shaft to the commanded position. The shaft typically does not rotate freely round and round like a DC motor, but rather can only turn 200 degrees or so back and forth.

The servo has a 3 wire connection: power, ground, and control. The power source must be constantly applied; the servo has its own drive electronics that draw current from the power lead to drive the motor.

4 Circuit

Odroid_ADK_PWM1.png
2LED.png


5 Schematic

Odroid_ADK_PWM1_schem.png



7 Software



//MotorContol
//send command message
//msg.what -> command character;
//msg.arg1 -> port number; (1 ~ 5)
//msg.arg2 -> value (1000 ~ 2000)
Message ledUpdate = Message.obtain(uiHandler, what, mPort, value);

// ADK
	case SEND_LETTER_PWM_DUTY:
				if(accessoryManager.isConnected() == false) {
					return;
				}
				
				commandPacket[0] = SEND_LETTER_PWM_DUTY;
				commandPacket[1] = 0;
				commandPacket[2] = (byte) msg.arg1;
				value = (short) msg.arg2;
				commandPacket[3] = (byte) (value >> 8);
				commandPacket[4] = (byte) value;
			
				accessoryManager.write(commandPacket);
				break;

// Bluetooth
      case SEND_LETTER_PWM_DUTY:
				if (mCmdSendService.getState() != BluetoothMotorControlService.STATE_CONNECTED) {
					Toast.makeText(getBaseContext(), R.string.not_connected, Toast.LENGTH_SHORT)
					.show();					
					return;
				}
				
				commandPacket[0] = SEND_LETTER_PWM_DUTY;
				commandPacket[1] = 0;
				commandPacket[2] = (byte) msg.arg1;
				value = (short) msg.arg2;
				commandPacket[3] = (byte) (value >> 8);
				commandPacket[4] = (byte) value;
			
				mCmdSendService.write(commandPacket);
				break;
send 5 byte buffers by bluetooth or usb