TEI Studio

This commit is contained in:
dviid
2013-02-10 07:11:56 +01:00
parent bae5b3d412
commit 9c4ffb6e7b
82 changed files with 0 additions and 8254 deletions
-44
View File
@@ -1,44 +0,0 @@
//Center
//uses a variable force (pwm duty)
//If it feels like a mountain - pushing away from center, then
//reverse the motor leads
//or for a quick fix in the code: change if(f < 0) to if (f > 0)
#include "Motor.h"
#include "Music.h"
int posA, posB; // position from analogRead
int forceA, forceB; // computed from pos and k
int kA, kB = 2; // spring constant
//int duty; // pwm duty for Timer1 (range 0 - 1023) 10-bit resolution
void setup()
{
MotorA.init();
MotorB.init();
Music.init();
}
void loop()
{
posA = analogRead(A0);
posB = analogRead(A3);
Music.setFrequency1(posA);
Music.setFrequency2(posB);
forceA = - kA * (512 - posA);
forceB = - kB * (512 - posB);
//duty = abs(force);
//duty = min(512, duty);
MotorA.torque(forceA); //force can be -512 to +511
MotorB.torque(forceB); //force can be -512 to +511
//if(force < 0) MotorA.direction(FORWARD);
//else MotorA.direction(BACKWARD);
}
-34
View File
@@ -1,34 +0,0 @@
//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 = 10; // spring constant
int duty; // pwm duty for Timer1 (range 0 - 1023) 10-bit resolution
void setup()
{
MotorA.init();
}
void loop()
{
pos = analogRead(A0);
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,43 @@
// CenterAB - both motors
//CenterA at xB, CenterB at xA?
//feels like "Double Toggle"
//position on A0, pwm:D9, dir:D8,D7
//CenterB
//position on A3, pwm:D10, dir:D11,D12
#include <Motor.h>
int duty, count, fout;
int xA, xB, foutA, foutB;
void setup(){
Serial.begin(9600);
MotorA.init();
MotorB.init();
}
void loop(){
xA = analogRead(A0);
xB = analogRead(A3);
foutA = 6*(xB-512); // this will peak at x=1024/6
MotorA.torque(foutA); // 1/4 or 1/2 ?
foutB = 6*(xA-512); // this will peak at x=1024/6
MotorB.torque(foutB); // 1/4 or 1/2 ?
// print every 1000 cycles
if(count++>=0){
count=-500;
Serial.print(xA,DEC);
Serial.print(" ");
Serial.print(foutA,DEC);
Serial.print(" ");
Serial.print(xB,DEC);
Serial.print(" ");
Serial.println(foutB,DEC);
}
}
-36
View File
@@ -1,36 +0,0 @@
//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,41 +0,0 @@
//Center two motors control two frequencies. (jb&bv 25Jan13)
//uses a variable force (pwm duty)
//If it feels like a mountain - pushing away from center, then
//reverse the motor leads or the sign of forceA or forceB
//or for a quick fix in the code: change if(f < 0) to if (f > 0)
// notes to me (bv)
#include "Motor.h"
#include "Music.h"
int posA, posB; // position from analogRead
int forceA, forceB; // computed from pos and k
int kA = 2; // spring constant
int kB = 2; // spring constant
//int duty; // pwm duty for Timer1 (range 0 - 1023) 10-bit resolution
void setup()
{
MotorA.init();
Music.init(); // 12-bit sine default (see .cpp file)
//Music.setWaveform(0); // only works with 8bit waveforms
}
void loop()
{
posA = analogRead(A0);
posB = analogRead(A3);
Music.setFrequency1(posA);
Music.setFrequency2(posB);
forceA = - kA * (512 - posA); // check wiring???
forceB = kB * (512 - posB);
MotorA.torque(forceA); // forceA [-512 to +511] ???
MotorB.torque(forceB);
}
@@ -1,23 +0,0 @@
//Damp - measure velocity then f=Bv
#import <Motor.h>
int x; //position measured - then filtered
float v, f, t, xold; //velocity, force, time delta
byte c; //for debug print every 256th loop
void setup(){
Serial.begin(9600);
xold = analogRead(A0);
}
void loop(){
x = analogRead(A0);
v = x - xold; //lag v, too?
xold += 0.1*(x-xold); //slide xold with lag
if(c++==0){
//Serial.print(xold);
//Serial.print(" ");
Serial.println(100*v);
}
}
@@ -1,28 +0,0 @@
//Damp 2 with running average position
#define n 10 //number in buffer
int x; //position measured
float xf; // running average on n samples
int buff[n];
int index = 0;
float v, oldavg; // estimate of velocity
byte c;
void setup(){
Serial.begin(9600);
}
void loop(){
buff[index] = analogRead(A0);
index++;
if(index > n-1) index = 0;
int acc = 0;
for(int i=0; i<n; i++)acc+=buff[i];
float avg = acc/n;
v = avg - oldavg;
oldavg = avg;
if(c++==0)Serial.println(v);
}
@@ -1,20 +0,0 @@
//Damp3 trying integration to get velocity
// ala Kalman filtering?
int x; //position measured [0-1023]
float af, vf //acceleration, velocity estimates
float ff // force out
float K = 1.0 //spring
float B = 10.0 //damping (dominant)
float M = 1.0 //mass
void setup(){
Serial.begin(115200);
}
void loop(){
x = analogRead(A0);
ff = K*(xf-x) - B*vf; // the spring K
af = ff/M;
vf += af*T; //T is cycle time
xf += vf*T;
@@ -1,783 +0,0 @@
{
"patcher" : {
"fileversion" : 1,
"appversion" : {
"major" : 6,
"minor" : 0,
"revision" : 5
}
,
"rect" : [ 25.0, 82.0, 1184.0, 641.0 ],
"bglocked" : 0,
"openinpresentation" : 0,
"default_fontsize" : 12.0,
"default_fontface" : 0,
"default_fontname" : "Arial",
"gridonopen" : 0,
"gridsize" : [ 15.0, 15.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" : 12.0,
"id" : "obj-36",
"maxclass" : "flonum",
"numinlets" : 1,
"numoutlets" : 2,
"outlettype" : [ "float", "bang" ],
"parameter_enable" : 0,
"patching_rect" : [ 360.0, 393.0, 50.0, 20.0 ]
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-34",
"maxclass" : "number",
"numinlets" : 1,
"numoutlets" : 2,
"outlettype" : [ "int", "bang" ],
"parameter_enable" : 0,
"patching_rect" : [ 229.0, 421.0, 50.0, 20.0 ]
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-32",
"maxclass" : "newobj",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "int" ],
"patching_rect" : [ 289.0, 421.0, 32.5, 20.0 ],
"text" : "* 1"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-31",
"maxclass" : "flonum",
"numinlets" : 1,
"numoutlets" : 2,
"outlettype" : [ "float", "bang" ],
"parameter_enable" : 0,
"patching_rect" : [ 289.0, 452.0, 50.0, 20.0 ]
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-29",
"maxclass" : "newobj",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "int" ],
"patching_rect" : [ 289.0, 387.0, 32.5, 20.0 ],
"text" : "-"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-28",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 709.0, 345.0, 50.0, 18.0 ],
"text" : "76"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-26",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 649.0, 345.0, 50.0, 18.0 ],
"text" : "74"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-25",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 589.0, 345.0, 50.0, 18.0 ],
"text" : "71"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-24",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 529.0, 345.0, 50.0, 18.0 ],
"text" : "68"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-13",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 469.0, 345.0, 50.0, 18.0 ],
"text" : "66"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-3",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 409.0, 345.0, 50.0, 18.0 ],
"text" : "63"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-23",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 349.0, 345.0, 50.0, 18.0 ],
"text" : "61"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-1",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 289.0, 345.0, 50.0, 18.0 ],
"text" : "58"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-37",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 229.0, 345.0, 50.0, 18.0 ],
"text" : "57"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-27",
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 10,
"outlettype" : [ "int", "bang", "bang", "bang", "bang", "bang", "bang", "bang", "bang", "bang" ],
"patching_rect" : [ 206.25, 306.0, 519.5, 20.0 ],
"text" : "t i b b b b b b b b b"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-22",
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 5,
"outlettype" : [ "int", "bang", "bang", "bang", "bang" ],
"patching_rect" : [ 879.0, 313.0, 73.0, 20.0 ],
"text" : "t i b b b b"
}
}
, {
"box" : {
"id" : "obj-21",
"maxclass" : "button",
"numinlets" : 1,
"numoutlets" : 1,
"outlettype" : [ "bang" ],
"patching_rect" : [ 310.0, 6.0, 20.0, 20.0 ]
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-20",
"maxclass" : "newobj",
"numinlets" : 2,
"numoutlets" : 3,
"outlettype" : [ "bang", "bang", "int" ],
"patching_rect" : [ 325.0, 37.0, 56.0, 20.0 ],
"text" : "uzi 1024"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-19",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 41.0, 370.0, 37.0, 18.0 ],
"text" : "clear"
}
}
, {
"box" : {
"id" : "obj-17",
"maxclass" : "button",
"numinlets" : 1,
"numoutlets" : 1,
"outlettype" : [ "bang" ],
"patching_rect" : [ 292.0, 58.0, 20.0, 20.0 ]
}
}
, {
"box" : {
"hint" : "x 82 y -44",
"id" : "obj-15",
"maxclass" : "itable",
"name" : "",
"numinlets" : 2,
"numoutlets" : 2,
"outlettype" : [ "int", "bang" ],
"parameter_enable" : 0,
"patching_rect" : [ 150.0, 488.0, 1000.0, 145.0 ],
"range" : 128,
"signed" : 1,
"size" : 1024,
"table_data" : [ 0, 80, 4, 4, -32, -34, -36, -40, -40, -42, -50, -50, -18, -18, -22, -20, -20, -20, -16, -20, -20, -18, -14, -14, -16, -18, -22, -20, -18, -20, -18, -18, -18, -16, -14, -12, -6, -2, -2, 0, 4, 6, 8, 10, 6, 6, 6, 8, 6, 8, 8, 8, 10, 8, 8, 8, 8, 6, 8, 6, 6, 8, 8, 6, 6, 8, 6, 8, 6, 6, 6, 8, 8, 6, 8, 6, 6, 6, 6, 6, 6, 8, 6, 8, 8, 8, 8, 6, 8, 6, 8, 10, 10, 10, 10, 12, 12, 12, 10, 6, 8, 10, 10, 10, 8, 10, 12, 14, 14, 10, 10, 10, 10, 10, 8, 6, 6, 10, 10, 10, 12, 12, 12, 14, 12, 10, 10, 10, 10, 8, 8, 8, 8, 10, 10, 10, 8, 10, 12, 10, 10, 6, 8, 6, 8, 8, 6, 6, 8, 8, 8, 10, 8, 6, 8, 8, 6, 8, 10, 8, 10, 10, 10, 10, 12, 12, 10, 10, 10, 10, 10, 10, 8, 10, 8, 10, 10, 12, 12, 12, 14, 10, 12, 10, 8, 6, 6, 8, 6, 6, 6, 6, 8, 8, 8, 6, 6, 6, 6, 6, 4, 6, 6, 6, 6, 8, 6, 6, 6, 4, 0, -2, -4, -8, -10, -14, -18, -20, -20, -20, -20, -24, -22, -32, -36, -38, -44, -46, -50, -48, -50, -40, -32, -36, -32, -34, -34, -32, -38, -36, -38, -32, -30, -32, -32, -32, -24, -26, -26, -26, -26, -22, -22, -22, -24, -22, -22, -20, -18, -14, -8, -6, -4, -2, 0, 0, 2, 2, 4, 4, 4, 4, 4, 4, 2, 2, 0, 0, -2, -2, -2, -2, -2, -2, -2, -2, 0, 0, 0, 0, 0, -2, -2, -2, -2, -2, -2, -2, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 6, 2, 4, 4, 6, 6, 6, 6, 4, 4, 2, 2, 0, 0, 0, 0, 2, 2, 2, 4, 6, 146, 140, 134, 126, 116, 104, 102, 100, -38, -30, -24, -16, -4, 10, 12, 12, 12, 12, 12, 14, 12, 18, 22, 24, 22, 18, 14, 8, 2, -12, -20, -24, -28, -28, -26, -26, -22, -18, -22, -22, -18, -18, -14, -10, -4, 0, 10, -2, -14, -28, -38, -48, -54, -56, -66, -54, -50, -36, -32, -28, -26, -28, -22, -22, -14, -12, -6, -2, -2, 6, 6, 10, 10, 12, 12, 12, 12, 8, 10, 10, 10, 8, 6, 6, 6, 4, 2, 0, 0, 2, 2, 4, 6, 10, 18, 22, 26, 34, 36, 40, 40, 38, 28, 20, 12, 2, 0, -6, -8, -10, -8, -4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, -2, -2, -2, -2, -2, -2, -2, 0, 0, 0, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 4, 6, 4, 4, 4, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, -4, -4, -4, -4, -4, -6, -6, -4, -2, -2, -2, -2, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 6, 6, 6, 6, 6, 6, 6, 6, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, -2, -2, -2, -2, -2, -2, -2, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, -2, -2, -2, -2, -2, -4, -6, -4, -6, -8, -10, -12, -14, -16, -18, -26, -30, -34, -34, -34, -34, -34, -32, -24, -20, -18, -18, -18, -18, -14, -8, -6, 2, 8, 12, 26, 30, 40, 38, 40, 40, 40, 44, 34, 34, 26, 26, 24, 20, 20, 16, 16, 18, 18, 24, 26, 26, 34, 36, 46, 46, 44, 38, 36, 36, 26, 22, 10, 4, 0, -8, -12, -16, -26, -30, -34, -34, -30, -26, -30, -32, -26, -26, -26, -26, -28, -30, -26, -24, -22, -20, -20, -20, -20, -18, -20, -20, -22, -24, -22, -24, -28, -32, -28, -30, -30, -30, -30, -26, -20, -12, -8, 4, 16, 22, 26, 32, 38, 38, 36, 36, 30, 32, 32, 30, 34, 34, 34, 30, 32, 32, 40, 38, 30, 32, 36, 36, 40, 40, 30, 32, 34, 32, 28, 28, 20, 14, 12, 4, -4, -10, -20, -28, -38, -46, -48, -48, -46, -42, -38, -38, -34, -26, -26, -28, -32, -36, -38, -38, -38, -38, -42, -42, -36, -36, -32, -30, -26, -38, -32, -28, -36, -34, -32, -32, -30, -18, -18, -18, -12, -10, -12, -10, -10, -8, -6, -2, 2, 6, 10, 12, 16, 18, 20, 22, 24, 24, 26, 28, 28, 30, 32, 28, 28, 32, 30, 34, 32, 28, 24, 24, 20, 12, 10, 2, 0, 0, 0, 0, 0, -2, -2, -2, -2, -2, -2, -2, -2, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, -2, -2, -2, -2, -2, -2, -2, 0, 2, 4, 4, 6, 6, 6, 6, 6, 4, 4, 4, 2, 2, 2, 2, 4, 4, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 4, 4, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-14",
"maxclass" : "number",
"numinlets" : 1,
"numoutlets" : 2,
"outlettype" : [ "int", "bang" ],
"parameter_enable" : 0,
"patching_rect" : [ 150.0, 337.0, 50.0, 20.0 ]
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-12",
"maxclass" : "number",
"numinlets" : 1,
"numoutlets" : 2,
"outlettype" : [ "int", "bang" ],
"parameter_enable" : 0,
"patching_rect" : [ 451.0, 92.0, 50.0, 20.0 ]
}
}
, {
"box" : {
"id" : "obj-11",
"maxclass" : "toggle",
"numinlets" : 1,
"numoutlets" : 1,
"outlettype" : [ "int" ],
"parameter_enable" : 0,
"patching_rect" : [ 451.0, -4.0, 20.0, 20.0 ]
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-9",
"maxclass" : "newobj",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "bang" ],
"patching_rect" : [ 451.0, 27.0, 51.0, 20.0 ],
"text" : "metro 1"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-8",
"maxclass" : "newobj",
"numinlets" : 5,
"numoutlets" : 4,
"outlettype" : [ "int", "", "", "int" ],
"patching_rect" : [ 451.0, 60.0, 101.0, 20.0 ],
"text" : "counter 0 1 1024"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-7",
"maxclass" : "newobj",
"numinlets" : 0,
"numoutlets" : 0,
"patching_rect" : [ 310.0, 96.0, 100.0, 20.0 ]
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-6",
"maxclass" : "number",
"numinlets" : 1,
"numoutlets" : 2,
"outlettype" : [ "int", "bang" ],
"parameter_enable" : 0,
"patching_rect" : [ 150.0, 85.0, 50.0, 20.0 ]
}
}
, {
"box" : {
"hint" : "x 79 y 127",
"id" : "obj-4",
"maxclass" : "itable",
"name" : "",
"numinlets" : 2,
"numoutlets" : 2,
"outlettype" : [ "int", "bang" ],
"parameter_enable" : 0,
"patching_rect" : [ 150.0, 153.0, 1000.0, 145.0 ],
"range" : 128,
"size" : 1024,
"table_data" : [ 0, 56, 55, 54, 53, 51, 51, 50, 48, 48, 46, 45, 42, 41, 41, 40, 40, 38, 36, 36, 35, 34, 33, 31, 29, 28, 27, 26, 26, 25, 24, 23, 22, 22, 24, 25, 25, 25, 26, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 32, 32, 32, 33, 33, 33, 34, 34, 35, 36, 36, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 40, 41, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 46, 47, 47, 48, 50, 50, 51, 51, 52, 53, 53, 53, 53, 54, 56, 56, 57, 57, 58, 59, 60, 61, 61, 61, 62, 62, 63, 63, 63, 64, 66, 66, 67, 68, 69, 69, 70, 70, 71, 71, 72, 73, 73, 73, 74, 74, 76, 76, 77, 77, 78, 79, 79, 79, 79, 80, 80, 81, 82, 82, 82, 83, 83, 84, 85, 85, 85, 86, 86, 86, 87, 89, 89, 90, 90, 91, 91, 92, 93, 94, 94, 95, 95, 96, 96, 96, 98, 98, 99, 100, 101, 102, 102, 103, 103, 104, 104, 104, 104, 105, 106, 106, 106, 107, 107, 108, 108, 109, 109, 109, 109, 110, 110, 110, 111, 112, 112, 112, 113, 113, 113, 113, 113, 112, 111, 110, 109, 108, 106, 104, 103, 102, 101, 100, 97, 97, 90, 86, 84, 80, 78, 75, 73, 72, 70, 70, 66, 64, 61, 58, 57, 53, 52, 51, 50, 49, 45, 42, 41, 41, 39, 38, 37, 36, 34, 31, 30, 29, 28, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 29, 29, 29, 29, 29, 29, 29, 30, 30, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 35, 105, 102, 99, 96, 91, 85, 85, 85, 86, 87, 87, 88, 89, 90, 91, 91, 92, 93, 93, 95, 95, 99, 102, 103, 103, 102, 100, 99, 96, 93, 92, 91, 89, 88, 87, 86, 85, 84, 81, 80, 80, 79, 80, 81, 83, 84, 86, 79, 73, 65, 61, 57, 56, 56, 53, 52, 48, 47, 45, 43, 43, 42, 42, 41, 41, 41, 42, 42, 42, 45, 45, 46, 46, 47, 48, 48, 48, 49, 50, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 52, 52, 53, 54, 56, 60, 62, 64, 69, 70, 73, 74, 75, 74, 72, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 70, 70, 70, 70, 70, 70, 71, 71, 72, 72, 72, 73, 73, 73, 73, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 73, 72, 72, 72, 72, 72, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 72, 74, 74, 74, 74, 74, 74, 74, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 73, 73, 73, 73, 73, 73, 72, 71, 71, 70, 69, 68, 67, 66, 64, 62, 58, 55, 52, 51, 50, 49, 47, 46, 46, 45, 43, 42, 41, 40, 40, 42, 43, 46, 47, 48, 54, 55, 60, 61, 63, 66, 67, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 81, 82, 86, 88, 89, 94, 96, 102, 104, 104, 105, 106, 107, 107, 107, 107, 106, 104, 101, 100, 99, 94, 92, 90, 89, 89, 88, 85, 83, 81, 79, 77, 76, 75, 73, 72, 71, 70, 69, 67, 66, 65, 64, 62, 61, 59, 57, 56, 54, 51, 48, 48, 46, 44, 42, 41, 41, 41, 42, 44, 48, 52, 53, 54, 57, 60, 61, 62, 66, 67, 69, 70, 72, 77, 78, 79, 81, 83, 85, 90, 91, 92, 94, 97, 99, 103, 105, 105, 107, 109, 110, 111, 113, 113, 112, 111, 109, 107, 105, 101, 99, 94, 89, 87, 85, 84, 84, 82, 80, 77, 76, 74, 71, 68, 66, 63, 61, 58, 57, 53, 50, 50, 48, 47, 46, 45, 38, 37, 36, 32, 31, 31, 30, 30, 29, 28, 27, 26, 26, 25, 25, 25, 25, 25, 26, 27, 29, 30, 31, 33, 34, 35, 37, 39, 41, 43, 45, 47, 49, 51, 51, 53, 57, 58, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 66, 66, 67, 67, 67, 67, 67, 67, 68, 68, 68, 68, 68, 68, 69, 69, 69, 69, 69, 69, 69, 69, 69, 70, 70, 70, 70, 70, 70, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 73 ]
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-2",
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 63.0, 39.0, 150.0, 20.0 ],
"text" : "Plot Velocity from Position"
}
}
],
"lines" : [ {
"patchline" : {
"destination" : [ "obj-23", 1 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-1", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-9", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-11", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-15", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-12", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-4", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-12", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-24", 1 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-13", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-8", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-17", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-15", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-19", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-8", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-20", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-20", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-21", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-3", 1 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-23", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-25", 1 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-24", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-26", 1 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-25", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-28", 1 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-26", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-1", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-27", 2 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-13", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-27", 5 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-23", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-27", 3 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-24", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-27", 6 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-25", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-27", 7 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-26", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-27", 8 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-28", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-27", 9 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-3", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-27", 4 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-37", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-27", 1 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-37", 1 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-27", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-29", 1 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-28", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-32", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-29", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-34", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-29", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-13", 1 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-3", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-15", 1 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-31", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-31", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-32", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-32", 1 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-36", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-1", 1 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-37", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-29", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-37", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-14", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-4", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-27", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-4", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-4", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-6", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-12", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-8", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-8", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-9", 0 ]
}
}
],
"dependency_cache" : [ ]
}
}
@@ -1,28 +0,0 @@
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
@@ -1,29 +0,0 @@
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);
}
File diff suppressed because it is too large Load Diff
@@ -1,41 +0,0 @@
// 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);
}
}
File diff suppressed because it is too large Load Diff
-28
View File
@@ -1,28 +0,0 @@
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);
}
}
-576
View File
@@ -1,576 +0,0 @@
{
"patcher" : {
"fileversion" : 1,
"appversion" : {
"major" : 6,
"minor" : 0,
"revision" : 5
}
,
"rect" : [ 50.0, 94.0, 693.0, 652.0 ],
"bglocked" : 0,
"openinpresentation" : 0,
"default_fontsize" : 12.0,
"default_fontface" : 0,
"default_fontname" : "Arial",
"gridonopen" : 0,
"gridsize" : [ 15.0, 15.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" : 12.0,
"id" : "obj-23",
"maxclass" : "flonum",
"numinlets" : 1,
"numoutlets" : 2,
"outlettype" : [ "float", "bang" ],
"parameter_enable" : 0,
"patching_rect" : [ 561.0, 378.0, 50.0, 20.0 ]
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-20",
"maxclass" : "newobj",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "float" ],
"patching_rect" : [ 519.0, 429.0, 44.0, 20.0 ],
"text" : "+ 500."
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-18",
"maxclass" : "newobj",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "float" ],
"patching_rect" : [ 418.0, 414.0, 42.0, 20.0 ],
"text" : "* 100."
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-32",
"linecount" : 10,
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 479.0, 6.0, 344.0, 145.0 ],
"text" : "Graph\n\nThis patch takes a string, containing ASCII formatted number from 0 to 1023, with a carriage return and linefeed at the end. It converts the string to an integer and graphs it.\n\ncreated 2006\nby David A. Mellis\nmodified 14 Apr 2009\nby Scott Fitzgerald and Tom Igoe"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-30",
"maxclass" : "newobj",
"numinlets" : 3,
"numoutlets" : 3,
"outlettype" : [ "bang", "bang", "" ],
"patching_rect" : [ 327.0, 80.0, 62.0, 20.0 ],
"text" : "select 0 1"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-26",
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 412.0, 231.0, 206.0, 20.0 ],
"text" : "click here to close the serial port"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-27",
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 412.0, 205.0, 206.0, 20.0 ],
"text" : "click here to open the serial port"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-21",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 327.0, 231.0, 39.0, 18.0 ],
"text" : "close"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-19",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 349.0, 205.0, 41.0, 18.0 ],
"text" : "port a"
}
}
, {
"box" : {
"bgcolor" : [ 0.231373, 0.713726, 1.0, 1.0 ],
"candicane2" : [ 0.145098, 0.203922, 0.356863, 1.0 ],
"candicane3" : [ 0.290196, 0.411765, 0.713726, 1.0 ],
"candicane4" : [ 0.439216, 0.619608, 0.070588, 1.0 ],
"candicane5" : [ 0.584314, 0.827451, 0.431373, 1.0 ],
"candicane6" : [ 0.733333, 0.035294, 0.788235, 1.0 ],
"candicane7" : [ 0.878431, 0.243137, 0.145098, 1.0 ],
"candicane8" : [ 0.027451, 0.447059, 0.501961, 1.0 ],
"contdata" : 1,
"id" : "obj-1",
"maxclass" : "multislider",
"numinlets" : 1,
"numoutlets" : 2,
"outlettype" : [ "", "" ],
"parameter_enable" : 0,
"patching_rect" : [ 302.0, 450.0, 246.0, 167.0 ],
"peakcolor" : [ 0.498039, 0.498039, 0.498039, 1.0 ],
"setminmax" : [ 0.0, 1023.0 ],
"setstyle" : 3,
"settype" : 0,
"slidercolor" : [ 0.066667, 0.058824, 0.776471, 1.0 ]
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-2",
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 412.0, 179.0, 207.0, 20.0 ],
"text" : "Click here to get a list of serial ports"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-3",
"linecount" : 2,
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 153.0, 409.0, 138.0, 34.0 ],
"text" : "Here's the number from Arduino's analog input"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-4",
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 379.0, 378.0, 147.0, 20.0 ],
"text" : "Convert ASCII to symbol"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-5",
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 379.0, 355.0, 147.0, 20.0 ],
"text" : "Convert integer to ASCII"
}
}
, {
"box" : {
"bgcolor" : [ 0.866667, 0.866667, 0.866667, 1.0 ],
"fontname" : "Arial",
"fontsize" : 12.0,
"htextcolor" : [ 0.870588, 0.870588, 0.870588, 1.0 ],
"id" : "obj-6",
"maxclass" : "number",
"numinlets" : 1,
"numoutlets" : 2,
"outlettype" : [ "int", "bang" ],
"parameter_enable" : 0,
"patching_rect" : [ 302.0, 414.0, 37.0, 20.0 ],
"triscale" : 0.9
}
}
, {
"box" : {
"color" : [ 1.0, 0.890196, 0.090196, 1.0 ],
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-7",
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 302.0, 378.0, 74.0, 20.0 ],
"text" : "fromsymbol"
}
}
, {
"box" : {
"color" : [ 1.0, 0.890196, 0.090196, 1.0 ],
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-8",
"maxclass" : "newobj",
"numinlets" : 3,
"numoutlets" : 1,
"outlettype" : [ "int" ],
"patching_rect" : [ 302.0, 355.0, 46.0, 20.0 ],
"text" : "itoa"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-9",
"maxclass" : "newobj",
"numinlets" : 2,
"numoutlets" : 2,
"outlettype" : [ "", "" ],
"patching_rect" : [ 302.0, 332.0, 64.0, 20.0 ],
"text" : "zl group 4"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-10",
"maxclass" : "newobj",
"numinlets" : 3,
"numoutlets" : 3,
"outlettype" : [ "bang", "bang", "" ],
"patching_rect" : [ 244.0, 281.0, 77.0, 20.0 ],
"text" : "select 10 13"
}
}
, {
"box" : {
"id" : "obj-11",
"maxclass" : "toggle",
"numinlets" : 1,
"numoutlets" : 1,
"outlettype" : [ "int" ],
"parameter_enable" : 0,
"patching_rect" : [ 244.0, 43.0, 15.0, 15.0 ]
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-12",
"maxclass" : "newobj",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "bang" ],
"patching_rect" : [ 244.0, 80.0, 65.0, 20.0 ],
"text" : "qmetro 10"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-13",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 369.0, 179.0, 36.0, 18.0 ],
"text" : "print"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-14",
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 2,
"outlettype" : [ "int", "" ],
"patching_rect" : [ 244.0, 255.0, 84.0, 20.0 ],
"text" : "serial a 9600"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-15",
"linecount" : 2,
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 53.0, 72.0, 185.0, 34.0 ],
"text" : "Read serial input buffer every 10 milliseconds"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-16",
"linecount" : 3,
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 332.0, 269.0, 320.0, 48.0 ],
"text" : "If you get newline (ASCII 10), send the list. If you get return (ASCII 13) do nothing. Any other value, add to the list"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-17",
"linecount" : 2,
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 271.0, 32.0, 199.0, 34.0 ],
"text" : "Click to open/close serial port and start/stop patch"
}
}
],
"lines" : [ {
"patchline" : {
"destination" : [ "obj-9", 0 ],
"disabled" : 0,
"hidden" : 0,
"midpoints" : [ 311.5, 320.0, 311.5, 320.0 ],
"source" : [ "obj-10", 2 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-9", 0 ],
"disabled" : 0,
"hidden" : 0,
"midpoints" : [ 253.5, 308.0, 311.5, 308.0 ],
"source" : [ "obj-10", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-12", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-11", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-30", 0 ],
"disabled" : 0,
"hidden" : 0,
"midpoints" : [ 253.0, 71.0, 336.5, 71.0 ],
"source" : [ "obj-11", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-14", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-12", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-14", 0 ],
"disabled" : 0,
"hidden" : 0,
"midpoints" : [ 378.5, 200.5, 253.5, 200.5 ],
"source" : [ "obj-13", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-10", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-14", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-20", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-18", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-14", 0 ],
"disabled" : 0,
"hidden" : 0,
"midpoints" : [ 358.5, 228.5, 253.5, 228.5 ],
"source" : [ "obj-19", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-23", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-20", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-14", 0 ],
"disabled" : 0,
"hidden" : 0,
"midpoints" : [ 336.5, 251.5, 253.5, 251.5 ],
"source" : [ "obj-21", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-1", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-23", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-19", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-30", 1 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-21", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-30", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-1", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-6", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-18", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-7", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-7", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-8", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-8", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-9", 0 ]
}
}
],
"dependency_cache" : [ ]
}
}
-26
View File
@@ -1,26 +0,0 @@
{\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)\
}
-55
View File
@@ -1,55 +0,0 @@
#include <Motion.h>
/*
Two motion objects are available from the MMM Motions library
(1) MotionA
(2) MotionB
MOTION {
MOTIONA ,
MOTIONB1
};
Each objects needs intialisation with a specific input
from which ADC reading will be performed.
Users may choose and identify inputs aa INPUT[A0, ... ,A7].
ex: MotionA.init(INPOUTA5);
INPUT {
INPUTA0,
INPUTA1,
INPUTA2,
INPUTA3,
INPUTA4,
INPUTA5,
INPUTA6,
INPUTA7
}
All calculation of physics (position, velocity and acceleration)
are computed internally usign interrupts and timers. To access
such information, user may call getPosition(), getVelocity()
and getAcceleration() respectively on a initialised Motion object.
int getPosition();
float getVelocity();
float getAcceleration();
*/
void setup() {
MotionA.init(INPUTA0);
Serial.begin(9600);
}
void loop() {
Serial.print("position: "); Serial.println(MotionA.getPosition());
Serial.print("velocity: "); Serial.println(MotionA.getVelocity());
Serial.print("accel: "); Serial.println(MotionA.getAcceleration());
Serial.println("-------");
delay(100);
}
@@ -1,62 +0,0 @@
// "Pendulum" - spring-mass oscillator
#include <Motion.h>
#include <Motor.h>
byte incomingByte;
void setup()
{
// init MotionA & MotorA
MotionA.init(INPUTA0);
MotorA.init();
// provide MotionA with initial physics constants
MotionA.k = 0.2f; // spring
MotionA.m = 0.3f; // mass
MotionA.d = 0.02f; // damping
Serial.begin(9600);
}
void loop(){
if(MotionA.F < 0) MotorA.direction(FORWARD);
else MotorA.direction(BACKWARD);
float t = abs(MotionA.F);
MotorA.torque(t);
if (Serial.available() > 0) {
incomingByte = Serial.read();
if(incomingByte == '1'){
MotionA.m = MotionA.m * 1.1;
Serial.print("m: ");
Serial.println(MotionA.m);
}
else if(incomingByte == '!'){
MotionA.m = MotionA.m / 1.1;
Serial.print("m: ");
Serial.println(MotionA.m);
}
else if(incomingByte == '2'){
MotionA.k = MotionA.k * 1.1;
Serial.print("k: ");
Serial.println(MotionA.k);
}
else if(incomingByte == '@'){
MotionA.k = MotionA.k / 1.1;
Serial.print("k: ");
Serial.println(MotionA.k);
}
else if(incomingByte == '3'){
MotionA.d = MotionA.d * 1.1;
Serial.print("d: ");
Serial.println(MotionA.d);
}
else if(incomingByte == '#'){
MotionA.d = MotionA.d / 1.1;
Serial.print("d: ");
Serial.println(MotionA.d);
}
}
}
@@ -1,68 +0,0 @@
// "Pendulum" - spring-mass oscillator
// Spring-Mass oscillator (no damping)
//#include <TimerOne.h>
#include <Motor.h>
float dt = .005; //time per cycle
float m = 4.0; //time constant was .002
float k = 1.0; // spring constant was .15
float xf,vf,ff; // floating point versions of pendulum x and v and force
int x; // input from analogRead();
int f; // integer version of force
int duty; // abs(f)
byte c=0; //counts up until 0 then prints
byte incomingByte;
void setup()
{
MotorA.init(); //initializes Timer1, pinModes
Serial.begin(9600);
//initialize position (xf), velocity (vf), force (ff)
x = analogRead(A0) - 512; //middle of 0-1-23 range
xf = x;
vf = 0.0;
ff = 0.0;
}
void loop(){
x = analogRead(0) - 512; // position [0-1024]
ff = k*(x - xf); // spring
vf = vf + (ff/m)*dt; // integrate F/m to get velocity
xf = xf + vf*dt; // integrate velocity to get position
duty = abs(ff);
duty = min(duty,512); //Motor has max torque of 512
MotorA.torque(duty);
if(ff>0)MotorA.direction(FORWARD);
else MotorA.direction(BACKWARD);
if (c++ == 0){
Serial.println(xf);
}
/*
if (Serial.available() > 0) {
incomingByte = Serial.read();
if(incomingByte == '\''){
tf = tf * 1.1;
Serial.println(tf);
}
if(incomingByte == ';'){
tf = tf / 1.1;
Serial.println(tf);
}
if(incomingByte == '.'){
kf = kf / 1.1;
Serial.println(tf);
}
if(incomingByte == '/'){
kf = kf * 1.1;
Serial.println(tf);
}
}
*/
}
@@ -1,85 +0,0 @@
// Damped Spring-Mass Oscillator
// BV 24Jan13
#include <Motor.h>
int Fout, Xin, duty;
// mass sring damper model
float m = 4.0;
float k = 1.0;
float b = 0.0;
float dT = .005;
float X, V, F; // model parameters (2nd-order oscil)
byte c=0; //counts up until 0 then prints
byte incomingByte;
void setup(){
Serial.begin(9600);
MotorA.init(); // initializes Timer1, pinModes
Xin = analogRead(A0) - 512; //middle of 0-1023 range
// initialize model variables
X = Xin;
V = 0.0;
F = 0.0;
}
void loop(){
Xin = analogRead(A0) - 512;
F = k*(Xin - X) - b*V; //spring and damper
V += (F/m) * dT;
X += V * dT;
duty = abs(Fout);
duty = min(duty,512);
MotorA.torque(duty);
if(Fout>0)MotorA.direction(FORWARD);
else MotorA.direction(BACKWARD);
if (c++ == 0){
Serial.println(X);
}
/*
if (Serial.available() > 0) {
incomingByte = Serial.read();
if(incomingByte == '}''){
dT = dT * 1.1;
Serial.println(dT);
}
if(incomingByte == '\'){ shift \
dT = dT / 1.1;
Serial.println(dT);
}
if(incomingByte == '|'){
k = k / 1.1;
Serial.println(k);
}
if(incomingByte == '}'){ //shift ]
k = k * 1.1;
Serial.println(k);
}
if(incomingByte == '['){
b = b / 1.1;
Serial.println(b);
}
if(incomingByte == '{'){ //shift [
b = b * 1.1;
Serial.println(b);
}
if(incomingByte == '['){
m = m / 1.1;
Serial.println(m);
}
if(incomingBmyte == '{'){ //shift [
m = m * 1.1;
Serial.println(m);
}
}
}
*/
}
@@ -1,80 +0,0 @@
// "Pendulum" - spring-mass oscillator
//
#include <TimerOne.h>
#include <Motor.h>
float tf = 0.002; //time constant was .002
float kf = 0.2; // spring constant was .15
float xf,vf,ff; // floating point versions of pendulum x and v and force
int x, f; //int versions of position (from a/d) and force (to Pwm)
int duty; // abs(f)
byte c=0; //counts up until 0 then prints
float m = 0.3;
float k = 0.01;
float damp = 0.09;
byte incomingByte;
void setup()
{
//Timer1.initialize(64); //64 microsecond period
MotorA.torque(100); //initializes Timer1, pinModes
Serial.begin(9600);
}
void loop(){
x = analogRead(0); // position [0-1024]
ff = kf*(x - xf); // spring
f = max(ff,-1024);
f = min(f,1024);
// if(f>0)digitalWrite(DIRA,HIGH);
// else digitalWrite(DIRA,LOW);
duty = abs(f);
// Timer1.pwm(9,duty);
MotorA.torque(duty);
if(f>0)MotorA.direction(FORWARD);
else MotorA.direction(BACKWARD);
// update (integrate) floating versions of xf and vf
//integrate twice tf is deltaT/mass;
vf += ff*tf;
xf += vf*tf;
if(c++==0) // when c gets to 255 it's next == 0 and sends data
{
Serial.print(x);
Serial.print(" ");
Serial.print(xf);
Serial.print(" ");
Serial.println(ff);
}
if (c++ == 0)Serial.println(x); //
if (Serial.available() > 0) {
//Serial.print(v);
//Serial.print(" ");
//Serial.println(x);
incomingByte = Serial.read();
//Serial.write(incomingByte);
if(incomingByte == '\''){
m = m * 1.1;
Serial.println(m);
}
if(incomingByte == ';'){
m = m / 1.1;
Serial.println(m);
}
if(incomingByte == '.'){
k = k / 1.1;
Serial.println(k);
}
if(incomingByte == '/'){
k = k * 1.1;
Serial.println(k);
}
}
}
@@ -1,72 +0,0 @@
#include <Motion.h>
#include <Motor.h>
char buf[16] = "";
char b = 'x';
String inputString = "";
boolean stringComplete = false;
float k, m, d;
int duty;
void setup() {
MotorA.init();
MotionA.init(INPUTA0);
MotionA.k = 0.2f; // spring
MotionA.m = 1.0f; // mass
MotionA.d = 0.02f; // damping
Serial.begin(9600);
}
void loop() {
//send force out
if (MotionA.F > 0) MotorA.direction(FORWARD);
else MotorA.direction(BACKWARD);
duty = abs(MotionA.F);
duty = min(512,duty);
MotorA.torque(duty);
//send data to be plotted by Processing "plotter"
sprintf(buf, "%d %d %d %d", (int)MotionA.F, (int)MotionA.A, (int)MotionA.V, (int)MotionA.X);
Serial.println(buf);
delay(10);
if(stringComplete) {
if(b == 'k') {
MotionA.k = convertToFloat(inputString);
} else if(b == 'm') {
MotionA.m = convertToFloat(inputString);
} else if(b == 'd') {
MotionA.d = convertToFloat(inputString);
}
b = 'x';
stringComplete = false;
inputString = "";
}
}
void serialEvent() {
while (Serial.available()) {
char inChar = (char)Serial.read();
if(inChar == 'k' || inChar == 'm' || inChar == 'd') {
b = inChar;
} else {
if (inChar == ';') {
stringComplete = true;
} else
inputString += inChar;
}
}
}
float convertToFloat(String str) {
char buf[16] = "";
str.toCharArray(buf, str.length() + 1);
return atof(buf);
}
@@ -0,0 +1,35 @@
//"Pulse" - small duration positive then negative force
// parameters: F1, T1, D1, F2, T2, D2
#define BIT_DEPTH 12
#include <Motor.h>
#include <Music.h>
void setup(){
MotorB.init();
Music.init();
Music.setWaveform(SINE);
Music.enableEnvelope();
Music.setAttack(10);
Music.setDecay(10);
Music.setRelease(10);
}
void loop(){
//for (int i; i < 512; i + 100){
MotorB.torque(40);
Music.noteOn(map(analogRead(A3),0,1023,30,60));
delay (20);
Music.noteOff();
MotorB.torque(0);
delay (150);
MotorB.torque(-70);
Music.noteOn(map(analogRead(A3),0,1023,35,65));
delay (40);
Music.noteOff();
MotorB.torque(0);
delay (750);
//}
}
-26
View File
@@ -1,26 +0,0 @@
#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);
}