Hi everyone, so here it is.
I'm using the stepper library to control a step by step engine. (
http://www.eminebea.com/content/html/en/motor_list/pm_motor/pg15s020.shtml)
Until here, no problem. This engine as 1000 steps, and i would like to return to processing the actual step of the engine, so i use a serial. It works but processing is missing a lot of data, and wiring keeps messing up a bit.
Here is my wiring code:
Code:#include <Stepper.h>
int steps = 1000;
char val;
int pas;
Stepper stepper(steps, 0, 1, 2, 3);
void setup(){
pas = 0;
Serial.begin(9600);
pinMode(48, OUTPUT); //Wiring led pin 48.
digitalWrite(48, HIGH);
}
void loop(){
if( Serial.available() ) val = Serial.read();
if(val == 'Q'){
stepper.step(1);
if (pas == 999) pas = 0;
else pas++;
Serial.print(pas);
val = 'x';
}
if(val == 'q'){
stepper.step(-1);
if (pas == 0) pas = 999;
else pas--;
Serial.print(pas);
val = 'x';
}
if(val == 'W'){
stepper.step(1);
if (pas == 999) pas = 0;
else pas++;
Serial.print(1);
}
if(val == 'w'){
stepper.step(-1);
if (pas == 0) pas = 999;
else pas--;
Serial.print(1);
Serial.flush();
}
delay(100);
}
And here is the processing applet:
Code:// Built by Florian | SIGMA6 to work with stepper05 in Wiring 0021
//____________________SETUP____________________
//
boolean debug = false;
//
//_____________________________________________
import processing.net.*;
import processing.serial.*;
// Configuration serial port
Serial port1;
int pas;
byte zero = 0;
void setup() {
size(200,150);
background(125);
frameRate(200);
//--------------------------------------- Déclaration des ports série
if (!debug) println(Serial.list());
if (!debug) port1 = new Serial(this, Serial.list()[0], 9600); //Port wiring
}
void draw(){}
void serialEvent(Serial port1) {
pas = port1.read();
println("test -------- "+pas);*/
port1.clear();
}
The idea is that processing is controlling the engine, but he need to know the position (step) of the engine.
For know it's working, but processing gets only half of the steps.
Here is a video to get the idea.
http://www.sigma6.ch/nightly/2009/11/360-degres-projection-test/And here is an example of some things we managed to do with this version, but could be a lot more precise
Thanks for reading until here.