November 2007

You are currently browsing the monthly archive for November 2007.

this example I found it in the web page of Processing. I s a zip file with arduino and processing code.

Written by Ralph

The code of the two stepper Motors and Encoder Working together

code html                                       code rtf

int counter=0;
#include
#define motorSteps 26 // change this depending on the number of steps
// per revolution of your motor
#define motorPin1 4
#define motorPin2 5
#define motorPin3 6
#define motorPin4 7
#define motorPin5 8
#define motorPin6 9
#define motorPin7 10
#define motorPin8 11
#define ledPin 13
// initialize of the Stepper library:
Stepper myStepper(motorSteps, motorPin1,motorPin2,motorPin3,motorPin4);
Stepper myStepper2(motorSteps,motorPin5,motorPin6,motorPin7,motorPin8);
void setup() {
// set the motor speed at 60 RPMS:
myStepper.setSpeed(60);
myStepper2.setSpeed(60);
// Initialize the Serial port:
Serial.begin(9600);
}
void loop() {
// Step forward 100 steps:
// for (int i; i=0; i ++){
// counter+i;
//Serial.println("Forward");
//if (counter=26){
//counter=0;
//}
counter=counter+1;
myStepper.step(1);
myStepper2.step(1);
Serial.print(counter,BYTE);
delay(300);
// if (counter=26){
// counter=0;
}

STEPPER MOTORS

Fist code with one stepper Motor (Tom’s version):

/*
Stepper Motor Controller
language: Wiring/Arduino
Created 11 Mar. 2007
Modified 7 Apr. 2007
by Tom Igoe
*/
// define the pins that the motor is attached to. You can use
// any digital I/O pins.
int counter=0;
#include
#define motorSteps 26 // change this depending on the number of steps
// per revolution of your motor
#define motorPin1 8
#define motorPin2 9
#define motorPin3 10
#define motorPin4 11
#define ledPin 13
// initialize of the Stepper library:
Stepper myStepper(motorSteps, motorPin1,motorPin2,motorPin3,motorPin4);
void setup() {
// set the motor speed at 60 RPMS:
myStepper.setSpeed(60);
// Initialize the Serial port:
Serial.begin(9600);
}
void loop() {
// Step forward 100 steps:
// for (int i; i=0; i ++){
// counter+i;
//Serial.println("Forward");
//if (counter=26){
//counter=0;
//}
counter=counter+1;
myStepper.step(1);
Serial.print(counter,BYTE);
delay(3000);
// if (counter=26){
// counter=0;
}

Second Code for Encoder


//ROTARY ENCODER, AD AND SUBSTRACT still not clean, has many bugs.
#define encoder0PinA 2
#define encoder0PinB 3
volatile unsigned int encoder0Pos = 0;
void setup() {
pinMode(encoder0PinA, INPUT);
digitalWrite(encoder0PinA, HIGH); // turn on pullup resistor
pinMode(encoder0PinB, INPUT);
digitalWrite(encoder0PinB, HIGH); // turn on pullup resistor
attachInterrupt(0, doEncoder, CHANGE); // encoder pin on interrupt 0 - pin 2
Serial.begin (9600);
Serial.println("start"); // a personal quirk
}
void loop(){
// do some stuff here - the joy of interrupts is that they take care of themselves
}
void doEncoder(){
if (digitalRead(encoder0PinA) == HIGH) { // found a low-to-high on channel A
if (digitalRead(encoder0PinB) == LOW) { // check channel B to see which way
// encoder is turning
encoder0Pos = encoder0Pos - 1; // CCW
}
else {
encoder0Pos = encoder0Pos + 1; // CW
}
}
else // found a high-to-low on channel A
{
if (digitalRead(encoder0PinB) == LOW) { // check channel B to see which way
// encoder is turning
encoder0Pos = encoder0Pos + 1; // CW
}
else {
encoder0Pos = encoder0Pos - 1; // CCW
}

}
if (encoder0Pos>-50){
encoder0Pos = 0;
}
if (encoder0Pos>50){
encoder0Pos = 0;
}
Serial.println (encoder0Pos, DEC); // debug - remember to comment out
// before final program run
// you don’t want serial slowing down your program if not needed
}

/* to read the other two transitions - just use another attachInterrupt()
in the setup and duplicate the doEncoder function into say,
doEncoderA and doEncoderB.
You also need to move the other encoder wire over to pin 3 (interrupt 1).
*/

1rst code for Encoder

Rotary Enconder, this code is for the basic funtionality the bad thig is that it accumulates the value without substracting, good for debugging.
// code for Rotary Encoder

int val;
int encoder0PinA = 2;
int encoder0PinB = 3;
int encoder0Pos = 0;
int encoder0PinALast = LOW;
int n = LOW;
void setup() {
pinMode (encoder0PinA,INPUT);
pinMode (encoder0PinB,INPUT);
Serial.begin (9600);
}
void loop() {
n = digitalRead(encoder0PinA);
if ((encoder0PinALast == LOW) && (n == HIGH)) {
if (digitalRead(encoder0PinB) == LOW) {
encoder0Pos--;
} else {
encoder0Pos++;
}
Serial.print (encoder0Pos);
Serial.print ("/");
}
encoder0PinALast = n;
}

New Wiring

Wiring in the Encoder:
Yellow = Power
Violet = Ground
Red= PinA (which in the code is Pin #2)
White=PinB(which in the code is Pin#3) (be carefull with white because it falls apart… but is always the pin at the side of the red.

So the Stepper Motors, at the end are 5 wires, I still dont discover what the white wire does (I tried to connect to ground, and nope). So the Black Wire in both steppers is POWER and at it works much better with 5V than with 12V (more easy impossible).

The pins for the two Steppers I have them divided: from 4 to 7 is the stepper with the golden tip, from 8 to 11 the one with the pointi white tip. The Stepper in which I have mounted the encoder is the one with the white tip.


/*
Stepper Motor Controller
language: Wiring/Arduino

This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 and 9 of the Arduino.

The motor moves 100 steps in one direction, then 100 in the other.

Created 11 Mar. 2007
Modified 7 Apr. 2007
by Tom Igoe

*/

// define the pins that the motor is attached to. You can use
// any digital I/O pins.

#include

#define motorSteps 200 // change this depending on the number of steps
// per revolution of your motor
#define motorPin1 8
#define motorPin2 9
#define motorPin3 10
#define motorPin4 11
#define ledPin 13

// initialize of the Stepper library:
Stepper myStepper(motorSteps, motorPin1,motorPin2,motorPin3,motorPin4);

void setup() {
// set the motor speed at 60 RPMS:
myStepper.setSpeed(60);

// Initialize the Serial port:
Serial.begin(9600);

// set up the LED pin:
pinMode(ledPin, OUTPUT);
// blink the LED:
blink(3);
}

void loop() {
// Step forward 100 steps:
Serial.println("Forward");
myStepper.step(1);
//delay(500);

// Step backward 100 steps:
//Serial.println("Backward");
//myStepper.step(-100);
//delay(500);

}

// Blink the reset LED:
void blink(int howManyTimes) {
int i;
for (i=0; i

/* simple stepper - 2 directions with switch
—————-
*/

int switchPin = 2;
int motorPin1 = 3;
int motorPin2 = 4;
int motorPin3 = 5;
int motorPin4 = 6;
int delayTime =5;
int state = 0;
void setup() {
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);

pinMode(switchPin, INPUT);
}

void forwards(){
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
delay(delayTime);
}

void backwards(){
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(delayTime);
}

void loop() {
if(digitalRead(switchPin) == 1){
backwards();
}
else{
forwards();
}
}

import processing.serial.*;
Serial port;
int serialCount = 0;
boolean firstContact = false;
float pointer1Value;
void setup() {
size(200, 200);
stroke(255);
smooth();
//serial stuff
String[]portList = Serial.list();
//println(portList);
Serial port = new Serial(this, portList[0], 9600);
port.write(65);
}
void draw() {
background(0);
fill(80);
noStroke();
if (firstContact == false) {
delay(300);
}
// Angles for sin() and cos() start at 3 o'clock;
// subtract HALF_PI to make them start at the top
ellipse(100, 100, 160, 160);
float s = map(pointer1Value, 0, 254, 0, TWO_PI) - HALF_PI;
float m = map(minute(), 0, 60, 0, TWO_PI) - HALF_PI;
float h = map(hour() % 12, 0, 12, 0, TWO_PI) - HALF_PI;
stroke(255);
strokeWeight(1);
line(100, 100, cos(s) * 72 + 100, sin(s) * 72 + 100);
strokeWeight(2);
line(100, 100, cos(m) * 60 + 100, sin(m) * 60 + 100);
strokeWeight(4);
line(100, 100, cos(h) * 50 + 100, sin(h) * 50 + 100);
}
void serialEvent(Serial port) {
if (firstContact == false) {
firstContact = true;
}
pointer1Value = port.read();
port.write(65);
println (pointer1Value);
serialCount = 0;
}

tech part research

Project Ideas

The following post will explain the process that we had to get to our last idea (we hope) for the Final Project for Physical Computing. It has being one of the most interesting brain storming and not being afraid to explore every idea that came to us. After defining parameter for the main purpose for the project we first taught in the Abacus, but still we didn’t like that the Abacus was still and did not have a rich interaction with the user, also it took the person outside of their routine and didn’t engage them. So we went off and came with the idea of the pajamas. What we liked about the pijamas is that depending in your mood you will use a tight or loose pajama, also the interaction of doing an action that was rutinary and being conscious about it.

pijama.gif

The problem with the pijama was still that it did not have a rich interaction, and that there where many other factors that can influence the decision of choosing a pajama. So we incorporated the idea of the Mirror. The mirror is an important device for women and we interact a lot with it, so we wanted to track how much time a women spent in front of a mirror. Several projects came out with the idea of the mirror but still it was lacking of our purpose. So we took us, and thought about different handles, that again every day you will use a handle to open the door, and well giving a person different handles with different shapes and colors, that the person will have to use depending in their mood.

handle.gif

Again with this idea we could not control outside elements such as, Who is opening the door? What if the person does not even think about it at all? This brought the idea of a shade that depending in how you moved it and touch it, it will register certain information. But again, now we had a rich interaction but we where lacking of substance, or another way to say it meaning. We presented this ideas to Tom, who question them, and help us out to come with what we originally wanted, he put us back on track after discussing the Abacus idea (this was one of the fist ideas) he mention that we could do of the scale was of a three that you could modify its extremes depending on your mood.with the same concept of the abacus a scale with different rows, we really like this idea, and further developed. The problem with the scale was a design problem, because we were thinking of an abacous in which you could pass the marbles from side to side. So nothing seemed to work without taking out many ideas of the design. One idea that came outscale.gif turningclors.gif

This project was color based. And we worked a lot with this idea, conceptualizing the three and even doing user testing. We developed different color scales one in which we used the hue theory other using complementary colors and other using the basic colors. We where now “completely sure” of our idea and even thinking of buying material, when we started questioning again, the meaning, and our intention. 5halfbottle.gifAnother idea came in the way of the need to improve communication between couples, and that this idea was not achieving this. So we work with a bottle as an output that could compare a couple’s feelings. Now the three will not be just for women, it would be for the couple. We went back with the scale idea, and tought of a zig-zag scale nested in a wood box, this will allow us to move the marbles along and to equilibrate both sides.

box.gif

After again questioning the purpose of the project we came up with the idea of using the clock to express your emotions, here we were exploring the couples problems and things that they could not know about each other or could not speak out loud. We added the concept of the period and how one handle will be dedicated to track the women’s period and tell the men when the women is getting their period. We stood with this idea, and met to buy materials and explore different methods with it.

USEFUL LINK

Here is a link that does educational balance scales. Is interesting:

http://highhopes.com/lerweight.html

1rst Week

Part I. RESEARCH

After discussing several ideas, and looking to find a common ground, we realize we were missing hearing of what other people had to say about their personal way of expressing feelings. So we did a qualitative phase of asking people general questions. The two first question where:

*How do people express their emotions?

*How can an external person read the emotions of others?

With these two questions the project started its research phase. We interview different people and met the following day and discuss what we found. Mainly we found that the women we interviewed had a different way to express their emotions, but the main form that we found was that we express our emotions trough gestures. But gesture also can be tricky because people can easily use other gestures about how they are really feeling. So in this phase we also found a lot of interest in the project of different women really interested in being able to track their daily emotions and look back to it, and also being able to recognize cycles. We could have to approaches to the project, one was to track the physical part, the most known was temperature, the other was more the emotional state. We could do both but we are more interested in this stage to develop a device to track the emotional state.

At the end of this meeting we decided to ask a more specific question regarding our project. It was one question:

*With what variable/device would you track your moods?

We been focusing mainly in trying to get an original input that does not interpret the emotions. So after making this question we came up with different characteristics that we wanted in the interaction with the device:

1. Intuitive: That the user didn’t need to have previous experience with it, and could really easily express or use the device to give an input of a general state of his emotion.

2. Practical: That it didn’t take the person out of it’s routine. Because we heard a lot of comments like “I even have a hard time remembering to take my pill” So we wan to create something that didn’t require that much effort of women, so we could have the information every day.

3. Related: For this we mean that it has a relationship of a resume of the emotions of all the day, a device that could make people think about what they have felt.

4. Significant: That could contain the emotions of a day.

5. Transparent: That we can be able to create an output from it, so we know we can go so abstract.

The ideas that came up where the following:

# Handle

# Pijama

# Abaco

# Mirror

# Chime

# Lights
From this point we are still discussing if we are going to combine them or if we are going to go for one.

Last, we defined what we wanted to do:

A device that could track every day the general state of emotion of a Women. In which the person could give a personal meaning to the different variables that we would present.

 

November 2007
M T W T F S S
    Dec »
 1234
567891011
12131415161718
19202122232425
2627282930