Getting Synched
First time after a lot of tries. -Bill
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
//Center
|
||||
//uses a variable force (pwm duty)
|
||||
//If it feels like a "mountain" - pushing away from center, then
|
||||
//reverse the motor leads to make it feel like a "valley"
|
||||
//or for a quick fix in the code: change if(f < 0) to if (f > 0)
|
||||
|
||||
#include <Motor.h>
|
||||
|
||||
int pos; // position from analogRead
|
||||
int force; // computed from pos and k
|
||||
int k = 1; // spring constant
|
||||
int duty; // pwm duty for Timer1 (range 0 - 1023) 10-bit resolution
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
MotorA.torque(100); //is this necessary?
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
pos = analogRead(A3);
|
||||
|
||||
force = k * (512 - pos);
|
||||
duty = abs(force);
|
||||
duty = min(511, duty);
|
||||
|
||||
MotorA.torque(duty);
|
||||
|
||||
if(force < 0) MotorA.direction(FORWARD);
|
||||
else MotorA.direction(BACKWARD);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
//Center
|
||||
//uses a variable force (pwm duty)
|
||||
//If it feels like a "mountain" - pushing away from center, then
|
||||
//reverse the motor leads to make it feel like a "valley"
|
||||
//or for a quick fix in the code: change if(f < 0) to if (f > 0)
|
||||
|
||||
#include <Motor.h>
|
||||
|
||||
int pos; // position from analogRead
|
||||
int force; // computed from pos and k
|
||||
int k = 1; // spring constant
|
||||
int duty; // pwm duty for Timer1 (range 0 - 1023) 10-bit resolution
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
MotorB.torque(100); //is this necessary?
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
pos = analogRead(A3);
|
||||
|
||||
force = k * (512 - pos);
|
||||
duty = abs(force);
|
||||
duty = min(1023, duty);
|
||||
|
||||
MotorB.torque(duty);
|
||||
|
||||
if(force < 0) MotorB.direction(FORWARD);
|
||||
else MotorB.direction(BACKWARD);
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
//Damp - measure velocity then f=Bv
|
||||
#import <Motor.h>
|
||||
int x; //position measured
|
||||
int x; //position measured - then filtered
|
||||
float v, f, t, xold; //velocity, force, time delta
|
||||
byte c; //for debug print every 256th loop
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
int x, v, t; //position velocity time
|
||||
#define n 10
|
||||
int xtab[n]; //table of x
|
||||
int i; // index for table
|
||||
|
||||
void setup()
|
||||
{
|
||||
// start serial port at 9600 bps:
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// if we get a valid byte, read analog ins:
|
||||
if (Serial.available() > 0) {
|
||||
x = analogRead(A0)/4; //just for this test
|
||||
xtab[i] = x; //put it in array of x
|
||||
i = i + 1; //index to last x (9 times ago)
|
||||
if(i>9)i=0; //increment index
|
||||
v = x - xtab[i]; //difference x vs old x
|
||||
t = (t+1)%256;
|
||||
// send sensor values:
|
||||
Serial.write(x); // sends one byte [0-255]
|
||||
Serial.write(v+128);
|
||||
Serial.write(t);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,29 @@
|
||||
int x, v, t; //position velocity time
|
||||
#define n 10
|
||||
int xtab[n]; //table of x
|
||||
int i; // index for table
|
||||
|
||||
void setup()
|
||||
{
|
||||
// start serial port at 9600 bps:
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// if we get a valid byte, read analog ins:
|
||||
//if (Serial.available() > 0) {
|
||||
x = analogRead(A0)/4; //just for this test
|
||||
xtab[i] = x; //put it in array of x
|
||||
i = i + 1; //index to last x (9 times ago)
|
||||
if(i>9)i=0; //increment index
|
||||
v = x - xtab[i]; //difference x vs old x
|
||||
t = (t+1)%256;
|
||||
// send sensor values:
|
||||
Serial.print(x); // sends one byte [0-255]
|
||||
Serial.print(",");
|
||||
Serial.print(v+128);
|
||||
Serial.print(",");
|
||||
Serial.println(t);
|
||||
}
|
||||
|
||||
+75
-363
@@ -7,7 +7,7 @@
|
||||
"revision" : 5
|
||||
}
|
||||
,
|
||||
"rect" : [ 0.0, 44.0, 1280.0, 706.0 ],
|
||||
"rect" : [ 350.0, 44.0, 901.0, 670.0 ],
|
||||
"bglocked" : 0,
|
||||
"openinpresentation" : 0,
|
||||
"default_fontsize" : 12.0,
|
||||
@@ -27,6 +27,55 @@
|
||||
"digest" : "",
|
||||
"tags" : "",
|
||||
"boxes" : [ {
|
||||
"box" : {
|
||||
"fontname" : "Arial",
|
||||
"fontsize" : 12.0,
|
||||
"id" : "obj-42",
|
||||
"maxclass" : "newobj",
|
||||
"numinlets" : 2,
|
||||
"numoutlets" : 1,
|
||||
"outlettype" : [ "int" ],
|
||||
"patching_rect" : [ 826.0, 620.0, 38.0, 20.0 ],
|
||||
"text" : "- 127"
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"box" : {
|
||||
"hint" : "x 186 y 210",
|
||||
"id" : "obj-40",
|
||||
"maxclass" : "itable",
|
||||
"name" : "",
|
||||
"numinlets" : 2,
|
||||
"numoutlets" : 2,
|
||||
"outlettype" : [ "int", "bang" ],
|
||||
"parameter_enable" : 0,
|
||||
"patching_rect" : [ 128.0, 762.0, 706.0, 121.0 ],
|
||||
"range" : 128,
|
||||
"signed" : 1,
|
||||
"size" : 255,
|
||||
"table_data" : [ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 1, 1, 1, 1, 1, 2, 1, 0, 1, 1, 2, 1, 1, 2, 0, 1, 1, 1, 1, 0, 1, 2, 0, 1, 1, 1, 2, 1, 1, 1, 0, 2, 1, 1, 1, 0, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 2, 1, 1, 1, 2, 2, 1, 1, 1, 0, 1, 1, 2, 0, 0, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 0, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 2, 2, 1, 1, 1, 1, 2, 1, 1, 0, 0, 1, 1, 1, 1, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"box" : {
|
||||
"hint" : "x 0 y 236",
|
||||
"id" : "obj-41",
|
||||
"maxclass" : "itable",
|
||||
"name" : "",
|
||||
"numinlets" : 2,
|
||||
"numoutlets" : 2,
|
||||
"outlettype" : [ "int", "bang" ],
|
||||
"parameter_enable" : 0,
|
||||
"patching_rect" : [ 128.0, 663.0, 706.0, 114.0 ],
|
||||
"range" : 255,
|
||||
"size" : 255,
|
||||
"table_data" : [ 0, 115, 115, 115, 115, 115, 115, 115, 115, 115, 116, 115, 115, 115, 115, 115, 115, 115, 115, 115, 116, 115, 115, 115, 115, 115, 115, 116, 115, 115, 115, 115, 116, 115, 115, 116, 115, 115, 115, 115, 115, 115, 115, 116, 115, 115, 115, 115, 116, 115, 115, 115, 115, 116, 115, 115, 115, 115, 115, 115, 115, 116, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 116, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 116, 115, 115, 115, 116, 116, 115, 115, 115, 115, 115, 115, 116, 115, 115, 115, 116, 115, 115, 116, 115, 116, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 116, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 116, 115, 115, 115, 115, 116, 115, 115, 115, 115, 115, 115, 115, 116, 115, 115, 115, 115, 115, 115, 115, 116, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 116, 115, 115, 115, 115, 115, 115, 115, 116, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 116, 116, 115, 115, 115, 115, 116, 115, 115, 115, 115, 115, 115, 115, 115, 115, 116, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 116, 115, 115, 115, 115, 115, 115, 115, 115, 115 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"box" : {
|
||||
"fontname" : "Arial",
|
||||
"fontsize" : 12.0,
|
||||
@@ -114,7 +163,7 @@
|
||||
"fontname" : "Arial",
|
||||
"fontsize" : 12.0,
|
||||
"id" : "obj-31",
|
||||
"items" : [ "usbserial-AH01D7PO", ",", "Bluetooth-PDA-Sync", ",", "Bluetooth-Modem" ],
|
||||
"items" : [ "usbserial-AH01D7PK", ",", "Bluetooth-PDA-Sync", ",", "Bluetooth-Modem" ],
|
||||
"maxclass" : "umenu",
|
||||
"numinlets" : 1,
|
||||
"numoutlets" : 3,
|
||||
@@ -265,20 +314,6 @@
|
||||
"text" : "sel 1"
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"box" : {
|
||||
"fontname" : "Arial",
|
||||
"fontsize" : 12.0,
|
||||
"id" : "obj-5",
|
||||
"linecount" : 13,
|
||||
"maxclass" : "comment",
|
||||
"numinlets" : 1,
|
||||
"numoutlets" : 0,
|
||||
"patching_rect" : [ 411.0, 686.0, 540.0, 186.0 ],
|
||||
"text" : "Serial Call-Response ASCII \n\nSends a byte out the serial port, and reads 3 ASCII enoded, comma separated in, truncated by a linefeed. It then sets foregound color, xpos, and ypos of a circle using the values returned from the serial port. \n\nNote: This patch assumes that the device on the other end of the serial port is going to send a single byte of value 65 (ASCII A) on startup. The sketch waits for that byte, then sends an ASCII A whenever it wants more data. \n\ncreated 14 Apr 2009\nby Scott Fitzgerald and Tom Igoe\nupdated 31 October 2011"
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"box" : {
|
||||
@@ -321,327 +356,6 @@
|
||||
"text" : "checks for the ascii value of newline to begin communication. After initial communication is made, this block shuts down. A byte is sent back to the Arduino, indicating the patch is ready to receive information."
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"box" : {
|
||||
"fontname" : "Verdana",
|
||||
"fontsize" : 10.0,
|
||||
"id" : "obj-62",
|
||||
"maxclass" : "newobj",
|
||||
"numinlets" : 3,
|
||||
"numoutlets" : 1,
|
||||
"outlettype" : [ "" ],
|
||||
"patcher" : {
|
||||
"fileversion" : 1,
|
||||
"appversion" : {
|
||||
"major" : 6,
|
||||
"minor" : 0,
|
||||
"revision" : 5
|
||||
}
|
||||
,
|
||||
"rect" : [ 54.0, 94.0, 640.0, 480.0 ],
|
||||
"bglocked" : 0,
|
||||
"openinpresentation" : 0,
|
||||
"default_fontsize" : 10.0,
|
||||
"default_fontface" : 0,
|
||||
"default_fontname" : "Verdana",
|
||||
"gridonopen" : 0,
|
||||
"gridsize" : [ 25.0, 25.0 ],
|
||||
"gridsnaponopen" : 0,
|
||||
"statusbarvisible" : 2,
|
||||
"toolbarvisible" : 1,
|
||||
"boxanimatetime" : 200,
|
||||
"imprint" : 0,
|
||||
"enablehscroll" : 1,
|
||||
"enablevscroll" : 1,
|
||||
"devicewidth" : 0.0,
|
||||
"description" : "",
|
||||
"digest" : "",
|
||||
"tags" : "",
|
||||
"boxes" : [ {
|
||||
"box" : {
|
||||
"fontname" : "Arial",
|
||||
"fontsize" : 11.595187,
|
||||
"id" : "obj-47",
|
||||
"maxclass" : "message",
|
||||
"numinlets" : 2,
|
||||
"numoutlets" : 1,
|
||||
"outlettype" : [ "" ],
|
||||
"patching_rect" : [ 375.0, 150.0, 98.0, 18.0 ],
|
||||
"text" : "frgb 255 255 255"
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"box" : {
|
||||
"fontname" : "Arial",
|
||||
"fontsize" : 11.595187,
|
||||
"id" : "obj-46",
|
||||
"maxclass" : "message",
|
||||
"numinlets" : 2,
|
||||
"numoutlets" : 1,
|
||||
"outlettype" : [ "" ],
|
||||
"patching_rect" : [ 275.0, 125.0, 59.0, 18.0 ],
|
||||
"text" : "frgb 0 0 0"
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"box" : {
|
||||
"fontname" : "Verdana",
|
||||
"fontsize" : 12.0,
|
||||
"id" : "obj-45",
|
||||
"maxclass" : "newobj",
|
||||
"numinlets" : 3,
|
||||
"numoutlets" : 3,
|
||||
"outlettype" : [ "bang", "bang", "" ],
|
||||
"patching_rect" : [ 300.0, 100.0, 66.0, 21.0 ],
|
||||
"text" : "sel 255 0"
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"box" : {
|
||||
"fontname" : "Verdana",
|
||||
"fontsize" : 12.0,
|
||||
"id" : "obj-43",
|
||||
"maxclass" : "newobj",
|
||||
"numinlets" : 4,
|
||||
"numoutlets" : 1,
|
||||
"outlettype" : [ "" ],
|
||||
"patching_rect" : [ 50.0, 125.0, 180.0, 21.0 ],
|
||||
"text" : "pack 0 0 0 0"
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"box" : {
|
||||
"fontname" : "Verdana",
|
||||
"fontsize" : 12.0,
|
||||
"id" : "obj-42",
|
||||
"maxclass" : "newobj",
|
||||
"numinlets" : 2,
|
||||
"numoutlets" : 1,
|
||||
"outlettype" : [ "int" ],
|
||||
"patching_rect" : [ 200.0, 100.0, 40.0, 21.0 ],
|
||||
"text" : "+ 10"
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"box" : {
|
||||
"fontname" : "Verdana",
|
||||
"fontsize" : 12.0,
|
||||
"id" : "obj-41",
|
||||
"maxclass" : "newobj",
|
||||
"numinlets" : 2,
|
||||
"numoutlets" : 1,
|
||||
"outlettype" : [ "int" ],
|
||||
"patching_rect" : [ 75.0, 100.0, 40.0, 21.0 ],
|
||||
"text" : "+ 10"
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"box" : {
|
||||
"fontname" : "Arial",
|
||||
"fontsize" : 11.595187,
|
||||
"id" : "obj-40",
|
||||
"maxclass" : "message",
|
||||
"numinlets" : 2,
|
||||
"numoutlets" : 1,
|
||||
"outlettype" : [ "" ],
|
||||
"patching_rect" : [ 50.0, 150.0, 152.0, 18.0 ],
|
||||
"text" : "clear, paintoval $1 $2 $3 $4"
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"box" : {
|
||||
"comment" : "",
|
||||
"id" : "obj-58",
|
||||
"maxclass" : "inlet",
|
||||
"numinlets" : 0,
|
||||
"numoutlets" : 1,
|
||||
"outlettype" : [ "int" ],
|
||||
"patching_rect" : [ 57.5, 40.0, 25.0, 25.0 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"box" : {
|
||||
"comment" : "",
|
||||
"id" : "obj-59",
|
||||
"maxclass" : "inlet",
|
||||
"numinlets" : 0,
|
||||
"numoutlets" : 1,
|
||||
"outlettype" : [ "int" ],
|
||||
"patching_rect" : [ 120.0, 40.0, 25.0, 25.0 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"box" : {
|
||||
"comment" : "",
|
||||
"id" : "obj-60",
|
||||
"maxclass" : "inlet",
|
||||
"numinlets" : 0,
|
||||
"numoutlets" : 1,
|
||||
"outlettype" : [ "int" ],
|
||||
"patching_rect" : [ 300.0, 40.0, 25.0, 25.0 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"box" : {
|
||||
"comment" : "",
|
||||
"id" : "obj-61",
|
||||
"maxclass" : "outlet",
|
||||
"numinlets" : 1,
|
||||
"numoutlets" : 0,
|
||||
"patching_rect" : [ 228.333344, 228.0, 25.0, 25.0 ]
|
||||
}
|
||||
|
||||
}
|
||||
],
|
||||
"lines" : [ {
|
||||
"patchline" : {
|
||||
"destination" : [ "obj-61", 0 ],
|
||||
"disabled" : 0,
|
||||
"hidden" : 0,
|
||||
"source" : [ "obj-40", 0 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"patchline" : {
|
||||
"destination" : [ "obj-43", 2 ],
|
||||
"disabled" : 0,
|
||||
"hidden" : 0,
|
||||
"source" : [ "obj-41", 0 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"patchline" : {
|
||||
"destination" : [ "obj-43", 3 ],
|
||||
"disabled" : 0,
|
||||
"hidden" : 0,
|
||||
"source" : [ "obj-42", 0 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"patchline" : {
|
||||
"destination" : [ "obj-40", 0 ],
|
||||
"disabled" : 0,
|
||||
"hidden" : 0,
|
||||
"source" : [ "obj-43", 0 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"patchline" : {
|
||||
"destination" : [ "obj-46", 0 ],
|
||||
"disabled" : 0,
|
||||
"hidden" : 0,
|
||||
"source" : [ "obj-45", 0 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"patchline" : {
|
||||
"destination" : [ "obj-47", 0 ],
|
||||
"disabled" : 0,
|
||||
"hidden" : 0,
|
||||
"source" : [ "obj-45", 1 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"patchline" : {
|
||||
"destination" : [ "obj-61", 0 ],
|
||||
"disabled" : 0,
|
||||
"hidden" : 0,
|
||||
"source" : [ "obj-46", 0 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"patchline" : {
|
||||
"destination" : [ "obj-61", 0 ],
|
||||
"disabled" : 0,
|
||||
"hidden" : 0,
|
||||
"source" : [ "obj-47", 0 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"patchline" : {
|
||||
"destination" : [ "obj-41", 0 ],
|
||||
"disabled" : 0,
|
||||
"hidden" : 0,
|
||||
"source" : [ "obj-58", 0 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"patchline" : {
|
||||
"destination" : [ "obj-43", 0 ],
|
||||
"disabled" : 0,
|
||||
"hidden" : 0,
|
||||
"source" : [ "obj-58", 0 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"patchline" : {
|
||||
"destination" : [ "obj-42", 0 ],
|
||||
"disabled" : 0,
|
||||
"hidden" : 0,
|
||||
"source" : [ "obj-59", 0 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"patchline" : {
|
||||
"destination" : [ "obj-43", 1 ],
|
||||
"disabled" : 0,
|
||||
"hidden" : 0,
|
||||
"source" : [ "obj-59", 0 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"patchline" : {
|
||||
"destination" : [ "obj-45", 0 ],
|
||||
"disabled" : 0,
|
||||
"hidden" : 0,
|
||||
"source" : [ "obj-60", 0 ]
|
||||
}
|
||||
|
||||
}
|
||||
],
|
||||
"dependency_cache" : [ ]
|
||||
}
|
||||
,
|
||||
"patching_rect" : [ 128.0, 636.0, 269.0, 19.0 ],
|
||||
"saved_object_attributes" : {
|
||||
"fontface" : 0,
|
||||
"fontsize" : 10.0,
|
||||
"default_fontface" : 0,
|
||||
"digest" : "",
|
||||
"default_fontname" : "Verdana",
|
||||
"fontname" : "Verdana",
|
||||
"tags" : "",
|
||||
"default_fontsize" : 10.0,
|
||||
"description" : "",
|
||||
"globalpatchername" : ""
|
||||
}
|
||||
,
|
||||
"text" : "p \"draw the circle\""
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"box" : {
|
||||
@@ -724,17 +438,6 @@
|
||||
"text" : "sel 10"
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"box" : {
|
||||
"id" : "obj-39",
|
||||
"maxclass" : "lcd",
|
||||
"numinlets" : 1,
|
||||
"numoutlets" : 4,
|
||||
"outlettype" : [ "list", "list", "int", "" ],
|
||||
"patching_rect" : [ 128.0, 673.0, 1000.0, 1000.0 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"box" : {
|
||||
@@ -759,7 +462,7 @@
|
||||
"numinlets" : 1,
|
||||
"numoutlets" : 0,
|
||||
"patching_rect" : [ 449.0, 596.0, 37.0, 21.0 ],
|
||||
"text" : "val3"
|
||||
"text" : "t"
|
||||
}
|
||||
|
||||
}
|
||||
@@ -786,7 +489,7 @@
|
||||
"numinlets" : 1,
|
||||
"numoutlets" : 0,
|
||||
"patching_rect" : [ 321.0, 596.0, 37.0, 21.0 ],
|
||||
"text" : "val2"
|
||||
"text" : "v"
|
||||
}
|
||||
|
||||
}
|
||||
@@ -799,7 +502,7 @@
|
||||
"numinlets" : 1,
|
||||
"numoutlets" : 0,
|
||||
"patching_rect" : [ 193.0, 596.0, 37.0, 21.0 ],
|
||||
"text" : "val1"
|
||||
"text" : "x"
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1182,7 +885,7 @@
|
||||
}
|
||||
, {
|
||||
"patchline" : {
|
||||
"destination" : [ "obj-62", 1 ],
|
||||
"destination" : [ "obj-42", 0 ],
|
||||
"disabled" : 0,
|
||||
"hidden" : 0,
|
||||
"source" : [ "obj-22", 0 ]
|
||||
@@ -1191,7 +894,7 @@
|
||||
}
|
||||
, {
|
||||
"patchline" : {
|
||||
"destination" : [ "obj-62", 0 ],
|
||||
"destination" : [ "obj-41", 1 ],
|
||||
"disabled" : 0,
|
||||
"hidden" : 0,
|
||||
"source" : [ "obj-23", 0 ]
|
||||
@@ -1249,7 +952,16 @@
|
||||
}
|
||||
, {
|
||||
"patchline" : {
|
||||
"destination" : [ "obj-62", 2 ],
|
||||
"destination" : [ "obj-40", 0 ],
|
||||
"disabled" : 0,
|
||||
"hidden" : 0,
|
||||
"source" : [ "obj-3", 0 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"patchline" : {
|
||||
"destination" : [ "obj-41", 0 ],
|
||||
"disabled" : 0,
|
||||
"hidden" : 0,
|
||||
"source" : [ "obj-3", 0 ]
|
||||
@@ -1371,6 +1083,15 @@
|
||||
"source" : [ "obj-4", 0 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"patchline" : {
|
||||
"destination" : [ "obj-40", 1 ],
|
||||
"disabled" : 0,
|
||||
"hidden" : 0,
|
||||
"source" : [ "obj-42", 0 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"patchline" : {
|
||||
@@ -1456,15 +1177,6 @@
|
||||
"source" : [ "obj-6", 0 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"patchline" : {
|
||||
"destination" : [ "obj-39", 0 ],
|
||||
"disabled" : 0,
|
||||
"hidden" : 0,
|
||||
"source" : [ "obj-62", 0 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"patchline" : {
|
||||
@@ -0,0 +1,41 @@
|
||||
// Velosity sends only one byte values
|
||||
|
||||
int x, v, t; //position velocity time
|
||||
|
||||
#define n 10
|
||||
int xtab[n]; //table of x
|
||||
int i; // index for table
|
||||
|
||||
void setup()
|
||||
{
|
||||
// start serial port at 9600 bps:
|
||||
Serial.begin(9600);
|
||||
establishContact(); // send a byte to establish contact until receiver responds
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// if we get a valid byte, read analog ins:
|
||||
if (Serial.available() > 0) {
|
||||
x = analogRead(A0)/4;
|
||||
xtab[i] = x; //put it in array of x
|
||||
i = i + 1; //index to last x (9 times ago)
|
||||
if(i>9)i=0; //increment index
|
||||
v = x - xtab[i]; //difference x vs old x
|
||||
t = (t+1)%256;
|
||||
// send sensor values:
|
||||
Serial.write(x);
|
||||
Serial.write(",");
|
||||
Serial.write(v+128);
|
||||
Serial.write(",");
|
||||
Serial.write(t);
|
||||
}
|
||||
}
|
||||
|
||||
void establishContact() {
|
||||
while (Serial.available() <= 0) {
|
||||
Serial.println("0,0,0"); // send an initial string
|
||||
delay(300);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
|
||||
int firstSensor = 0; // first analog sensor
|
||||
int secondSensor = 0; // second analog sensor
|
||||
int thirdSensor = 0; // digital sensor
|
||||
int inByte = 0; // incoming serial byte
|
||||
|
||||
void setup()
|
||||
{
|
||||
// start serial port at 9600 bps and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
|
||||
pinMode(2, INPUT); // digital sensor is on digital pin 2
|
||||
establishContact(); // send a byte to establish contact until receiver responds
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// if we get a valid byte, read analog ins:
|
||||
if (Serial.available() > 0) {
|
||||
// get incoming byte:
|
||||
inByte = Serial.read();
|
||||
// read first analog input:
|
||||
firstSensor = analogRead(A0);
|
||||
// read second analog input:
|
||||
secondSensor = analogRead(A1);
|
||||
// read switch, map it to 0 or 255L
|
||||
thirdSensor = map(digitalRead(2), 0, 1, 0, 255);
|
||||
// send sensor values:
|
||||
Serial.print(firstSensor);
|
||||
Serial.print(",");
|
||||
Serial.print(secondSensor);
|
||||
Serial.print(",");
|
||||
Serial.println(thirdSensor);
|
||||
}
|
||||
}
|
||||
|
||||
void establishContact() {
|
||||
while (Serial.available() <= 0) {
|
||||
Serial.println("0,0,0"); // send an initial string
|
||||
delay(300);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
//Damp Euler
|
||||
|
||||
#define n 10 //number in buffer "window size"
|
||||
// finite difference with n samples between x(i)
|
||||
int x[n]; //last n samples of position
|
||||
int index = 0;
|
||||
float v; // estimate of velocity
|
||||
byte c;
|
||||
|
||||
void setup(){
|
||||
Serial.begin(9600);
|
||||
for(int i=0; i<n; i++) x[i]=analogRead(A0);
|
||||
}
|
||||
|
||||
void loop(){
|
||||
x[index] = analogRead(A0); //position measured
|
||||
v = (x[index] - x[index++%n])/n;
|
||||
if(index > n-1) index = 0;
|
||||
v = buff[index] - buff[(index-n)%n];
|
||||
if(c++==0)Serial.println(v);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
//DampMass
|
||||
@@ -0,0 +1,26 @@
|
||||
{\rtf1\ansi\ansicpg1252\cocoartf1138\cocoasubrtf510
|
||||
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
|
||||
{\colortbl;\red255\green255\blue255;}
|
||||
\margl1440\margr1440\vieww10800\viewh8400\viewkind0
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
|
||||
|
||||
\f0\fs24 \cf0 "Hello, World" Apps\
|
||||
\
|
||||
Wall (spring with and without damping) - how stiff without instability? - does damping help?\
|
||||
Center (full range of force and position) - \
|
||||
\
|
||||
Music -\
|
||||
position -> pitch (linear, non-linear)\
|
||||
gain -> FSR (second device?)\
|
||||
\
|
||||
Motor -\
|
||||
timed (open-loop) - "tick" "rumble" "\
|
||||
ramp - up,stay,dn,stay, etc.\
|
||||
rhythm - march, waltz, \'85\
|
||||
position - table/function (no time dependence) [ is this part of Motion?]\
|
||||
\
|
||||
Motion - \
|
||||
spring (position)\
|
||||
damping (velocity)\
|
||||
inertia (acceleration)\
|
||||
}
|
||||
@@ -44,7 +44,7 @@ void loop(){
|
||||
vf += ff*tf;
|
||||
xf += vf*tf;
|
||||
|
||||
if(c++==0) // when c gets to 255 it next == 0 and send data
|
||||
if(c++==0) // when c gets to 255 it's next == 0 and sends data
|
||||
{
|
||||
Serial.print(x);
|
||||
Serial.print(" ");
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#include <Motor.h>
|
||||
|
||||
float pos, fin, finmax, fout;
|
||||
byte c; // used as a counter from 0 to 255
|
||||
int duty;
|
||||
|
||||
void setup(){
|
||||
digitalWrite(A4,HIGH);
|
||||
digitalWrite(A5,LOW);
|
||||
pinMode(A4, INPUT);
|
||||
pinMode(A5, OUTPUT);
|
||||
//MotorB._period(32);
|
||||
}
|
||||
|
||||
void loop(){
|
||||
fin += .01*(analogRead(A4)-fin);
|
||||
fout = 0.5*fin*(1024+random(1024));
|
||||
duty = min(1024,fout);
|
||||
duty = abs(duty);
|
||||
//duty = min(duty,1024);
|
||||
MotorB.torque(duty);
|
||||
if(fout<0)MotorB.direction(FORWARD);
|
||||
else MotorB.direction(BACKWARD);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
//motortest
|
||||
//.5 sec forward, .5 sec back
|
||||
|
||||
#include <Motor.h>
|
||||
|
||||
int led = 13;
|
||||
|
||||
void setup()
|
||||
{
|
||||
MotorA.torque(511); //what is max torque?
|
||||
pinMode(13, OUTPUT);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
MotorA.direction(FORWARD);
|
||||
delay(500);
|
||||
MotorA.direction(BACKWARD);
|
||||
delay(500);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//position
|
||||
//sends A0 (MotorA), A3 (MotorB) to Serial Monitor
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Serial.print(analogRead(A3));
|
||||
Serial.print(" ");
|
||||
Serial.println(analogRead(A0));
|
||||
}
|
||||
@@ -11,7 +11,7 @@ void setup() {
|
||||
// We initialise the sound engine by calling Music.init() which outputs a tone
|
||||
Music.init();
|
||||
|
||||
Music.setSquare();
|
||||
Music.setSine();
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user