5.24.2015

mapping test_000

First mapping test on rotating form_001 3d printed object.




This is part of arduino code for serial communication with openframeworks.


#include <Streaming.h>
#include <SerialCommand.h>

#define DIR_PIN 10
#define STEP_PIN 11

float speed = 0.0;
float rotation = 0.0;
SerialCommand scmd;

void setup() {
   Serial.begin(9600);
   Serial << "# Serial port connected at 9600 bauds" << endl;
 
   pinMode(DIR_PIN, OUTPUT);
   pinMode(STEP_PIN, OUTPUT);
 
   scmd.addCommand("S", cmd_setspeed);
   scmd.addCommand("R", cmd_getrotation);
   scmd.addCommand("0", cmd_reset);
}

void loop() {
   scmd.readSerial();
   if(speed < 0.0001) return;
     digitalWrite(DIR_PIN, HIGH);
 
   float deg = 0.51;
   int steps = abs(deg)*(1.0/0.225);
   float usDelay = (1/speed) * 70;
 
   for(int i=0; i < steps; i++){
     digitalWrite(STEP_PIN, HIGH);
     delayMicroseconds(usDelay);
     digitalWrite(STEP_PIN, LOW);
     delayMicroseconds(usDelay);
   
     rotation += 0.225;


//this rotation +=0.225; need to be recalibrated to match the rotation from software hardware,
//stepper motor. Since every motor and its driver has different spec for voltage, current and so on.
//For my nema 17 stepper motor and easy driver 4.4, rotation +=0.22549;


...