No description, website, or topics provided.
JavaScript Other HTML
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
RemoteMotors
webapp
.gitignore
LICENSE
README.md
remote-control-motors-schematic.png

README.md

remote-control-motors

Purpose

This is a proof-of-concept project to actuate devices via an HTML5/CSS3/JavaScript app targeted for mobile devices. (There is also a basic TCP/IP protocol, REST API, and some hardware thrown in for good measure). I realize there are cloud services to do many parts of this process for you, but I wanted to roll my own from the ground up to find out what it was like. There are four parts to this project:

  1. User Interface: HTML5/CSS3/JavaScript targeted to small-screen mobile devices.

  2. Middleware: Connects to the user interface via a REST API (via HTTP) and to the the motor controller via a basic (non-HTTP) TCP/IP protocol. I made a separate middleware layer for two reasons: First, there is more logic in the middleware layer than I wanted to put onto a little Arduino. Second, later versions of this project will coordinate several independent hardware devices.

  3. Embedded Controller Software: This creates a simple TCP port that accepts text-based commands to control the motors. It could be retooled to control other things with PWM.

  4. Physical Circuit: This operates the motors based on signals from the Arduino software.

Directories

There are two directories of source code for this project.

RemoteControlMotors Enables a simple (not HTTP) protocol to remotely control 4 motors. This is written in C and covers parts 3 and 4 (Embedded Controller Software and Physical Circuit) of the project.

webapp A webapp made with Express and jQuery Mobile built on Node.js to provide a mobile interface to a mobile device. This is written in JavaScript and covers parts 1 and 2 (User Interface and Middleware) of this project.

Hardware

This section is supplemental to the page at akey7.com/remote-control-motors. Go there to see more pictures and other things I did to stick this prpject together.

This project wasn't necessarily designed to set any electrical engineering high-water marks, just to hook up motors to a web interface. I will later use more elaborate motor drivers.

Parts List

Here are the parts as of the time of this writing

I listed the sources for the parts only because those are the places where I obtained the parts. You can probably find them somewhere else if you prefer.

Note on power requirements

For the motor power supplies, I used 2 sets of 2 AA holders. Each AA holder supplies 3 VDC, and I wired the holders in parallel to supply more and maintain longer batter life. Other power 3 VDC power supplies are possible, as long as they supply enough current to run all the motors at the same time (according to the datasheet this is 4 x 320ma = 1280 ma)

For the Arduino power supply, I used the wall adapater. Again, other power sources are possible.

Finally, I wired the grounds together in this experiment. This is a simple design and does not protect the motor circuitry from the Arduino circuitry. This doesn't appear to be a problem here, but could be an isue in more complex designs.

Embedded Controller Software

The controller software should be customized for your network installation. Anecdotally, I had heard of repeatedly reloading Arduino sketches that use DHCP leases would take out a bunch of leases for the same device. So I used a static IP. Customize the following lines to setup the interface for your network, located at approximately line 90.

const int serverPort = 17;
EthernetServer server(serverPort);
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xD7, 0xD2 };
IPAddress gateway(192, 168, 0, 1);
IPAddress subnet(255, 255, 255, 0);
IPAddress ip(192, 168, 0, 33);

By default, the controller opens TCP server port 17. It accepts strings sent to this port to operate the motors. The 3 supported commands are the following:

  • full speed Runs all the motors at full speed.

  • all stop Stops all motors

  • motor,[motor number],[motor speed] This sets the speed for an individual motor. Speeds range from 0 to 100, and motor numbers are 0, 1, 2, or 3. For example, the following commands would set motors 0 and 2 to a high speed and motors 1 and 3 to a low speed.

motor,0,95
motor,2,95
motor,1,23
motor,3,23

Test commands can be sent with the telnet command. For example telnet 192.168.0.1 17 with the default configuration given above. Substitute your own IP address.

Use the MAC address that came with your device if it came with one. Otherwise, create a MAC address unique to your network. See the Arduino Ethernet Board page for more information.

Middleware and User Interface

First: You will need Node.js to operate the middle ware and the user interface. Install it on your system.

Second: You need to install the npm files for the web app server. From the webapp/ directory, execute the command

npm install

Third: There is one change to webapp/motor-driver.js to be made to connect the middleware to the controller. Customize the following lines to match th IP address and TCP port.

var controller_hostname = '192.168.0.33';
var controller_port = 17;

Fourth Execute the server with the following command:

node server.js

Fifth: Connect to the interface with a browser. It runs on port 8088. For example, the following IP address will access it from a browser running on the same machine as the server http://127.0.0.1:8088

Legal and License Stuff

Copyright (c) 2013 Alicia M. F. Key

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.