milana
v1.4.2
Published
CSUN ASME Arduino Integrations (Spring 2017)
Downloads
13
Maintainers
Readme
Milana
This is the code that will pilot the Arduino-based project, under ASME 2017 - CSUN.
Installation
OS X & Linux:
npm install milana --save
Windows:
edit autoexec.bat
Development Setup
Installing Firmata on the Arduino
Johnny-Five communicates with the Arduino microcontroller; for the Arduino to run Johnny-Five, the Arduino relies on a host computer to run the Johnny-Five library, using a Serial I/O protocol, named Firmata. Where, Firmata is utilized to run the hardware pins, using Bluetooth.
go to the node.js website to download the latest node.js installer. If you are done with this step, go onto the next step below
go to the computer's command line and run
npm install milana
. If you are done with this step, go onto the next step belowconnect the Arduino to the Mac computer via USB. Where, the USB provides both power, and a method to upload software to the Arduino board. If you see a green light start to flicker after plugging in the board, this is a good sign. If you are done with this step, go onto the next step below
open the Arduino IDE. If you are done with this step, go onto the next step below
go to the Mac's tool bar at the top of the computer's screen, click on "Tools", then scroll down to "Serial Port", and make sure that the "checkmark" is on the right option; if you're not sure, just do trial-and-error. If you have figured out the right option, go onto the next step below
go to the tool bar at the top of the computer screen, click on "Tools", then scroll down to "Board", and make sure the correct type of Arduino is checked (i.e. Arduino Uno, etc..). If you're done with this step, go onto the next step below
go to the tool bar at the top of the computer's screen, click on "File", then scroll down to "Examples", then scroll to "Firmata", then scroll down to "StandardFirmata", where a new window will open. Then "upload" the file by mousing to the top of that window, then pressing :arrow_right:. If you are done with this step, go onto the next step below
on the bottom of the Arduino IDE window, you will see "Uploading..."; wait until it says "Done uploading". If you are done with this step, go onto the next step below
congratulations! You have sucessfully downloaded the Firmata software onto the Arduino board
run Milana by going onto the command line, then typing
npm start
to turn off the board, type "control-c", then "control-c" once more
Script Commands
- these commands are listed within the
package.json
file:
npm start
:information_source: npm start
uses Bash to run the app.js
file, which is Milana's "entry point".
REPL Commands
- while running the Milana application, feel free to run these commands within the REPL:
:triangular_flag_on_post: ledStatus.on()
; ledStatus.off()
; ledStatus.toggle()
; ledStatus.strobe(500)
; ledStatus.blink(500)
; ledStatus.stop()
; ledStatus.brightness(256)
:triangular_flag_on_post: sprintRelay.close()
; sprintRelay.open()
:triangular_flag_on_post: liftRelay.close()
; liftRelay.open()
:triangular_flag_on_post: throwRelay.close()
; throwRelay.open()
;
:triangular_flag_on_post: sprintRelay.close()
; sprintRelay.open()
;
Module Documentation
Why ASME-CSUN Chose Node.js
- Node.js handles multi-threading in the background, while the user implements a single-threaded model, which translates to the benefits of a high throughput rate, based on I/O bound-tasks. Also, by choosing Node.js for its implementation enviroment, ASME-CSUN benefits from handling lower-resource requirements for concurrent I/O bound requests.
Dependencies
:small_orange_diamond: johnny-five
:small_orange_diamond: bluebird
:small_orange_diamond: xbox-controller
:small_orange_diamond: keypress
Dependency Illustrations
:ballot_box_with_check: johnny-five
the package to run Node.js on the Arduino.
:ballot_box_with_check: bluebird
a package to implement "promises" within the application; promises are objects for handling asynchronous responses. The returned value of a promise is an object, where promises provide functionality for
.then(fn)
, where the passed function is called with the result if the given promise resolves. Also, a user who implements promises within their code may use the.catch(fn)
functionality, where the passed function is called with the given error, if the promise is rejected.
the result of a function, which is wrapped inside a promise, can be either another promise, or an actual value.
if the result of a function is not a promise, the function will be wrapped as a resolved promise automatically.
the benefits of promise-behavior is the allowance of promises to be chained together, easily, without having to unwrap resulting-promises.
:ballot_box_with_check: xbox-controller
the behavior of the motors on the robot are mapped to the controlls to the Xbox controller.
:information_source: useage of xbox-controller
var XboxController = require('xbox-controller');
var xbox = new XboxController;
xbox.on('b:release', function(key) {
console.log(key + ' release');
});
xbox.on('lefttrigger', function(position) {
console.log('lefttrigger', position);
});
xbox.on('righttrigger', function(position) {
console.log('righttrigger', position);
});
xbox.on('left:move', function(position) {
console.log('left:move', position);
});
xbox.on('right:move', function(position) {
console.log('right:move', position);
});
xbox.on('connected', function() {
console.log('Xbox controller connected');
});
xbox.on('not-found', function() {
console.log('Xbox controller could not be found');
});
:ballot_box_with_check: keypress
make any Node.js ReadableStream emit "keypress" events (e.g. needed for
xbox-controller
).
Hardware Properties
:white_check_mark: Relays
:white_check_mark: Transistors
:white_check_mark: Actuators
:white_check_mark: DC Motors
:white_check_mark: Bluetooth Module
:white_check_mark: Xbox Controller
:white_check_mark: L293D H-Bridge
Relays are physical mechanisms that allow to connect a switch; relays are electronically-controlled physical switches. Where, relays leverage a small-amount of power to control a high-amount of power; relays have three pins that need a connection: a common pin, a normally-connected pin, and a normally-open pin; whenever you close that relay, that causes the switch from the normally-closed to the the normally-open, and connect those two. And, when the switch is being opened, it goes back to the other-point.
Transistors are physical mechanisms for a switch; instead of making a switch move like a relay, transistors make the switch move within silicone; transitors will be used to give-enough power to the relays.
Actuators have an electric motor that turns a threaded rod; attached to the threaded rob is a nut, which is also threaded. Where depending on the rotation of the motor, the threaded rod can move both up and down, or left and right.
DC Motors give the bot the property of motion.
Bluetooth Module has a latency of about 500 milliseconds, which is due to Bluetooth in-of-itself; this latency-factor may pose a problem with steering, while using the Xbox controller; the Bluetooth module connects the Arduino microcontroller to the host-computer, using a Serial I/O protocol, defined under Firmata.
Xbox Controller is node-module, which allows to the ability of using the Xbox contoller.
;
;
Meta
American Society of Mechanical Engineers, CSUN Chapter – Facebook - CSUN ASME
Distributed under the MIT license. See LICENSE
for more information.