Delete unwanted files.

v1
Agis Zisimatos 2014-09-22 22:31:47 +03:00
parent b0ba746729
commit 167bc4f7e7
3 changed files with 0 additions and 160 deletions

View File

@ -1,61 +0,0 @@
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define DIR_AZ 5
#define STEP_AZ 4
#define DIR_EL 6
#define STEP_EL 7
#define MS1 9
#define EN 8
#define SPR 200 //step per revolution
#define T_DEALY 10000
#define T_STEPPER 1
int stepPosAz = 0;
int stepAz = 0;
int stepPosEl = 0;
int stepEl = 0;
long t1 = 0;
void setup()
{
pinMode(DIR_AZ, OUTPUT);
pinMode(STEP_AZ, OUTPUT);
digitalWrite(EN_AZ, LOW);
digitalWrite(DIR_AZ, LOW);
pinMode(DIR_EL, OUTPUT);
pinMode(STEP_EL, OUTPUT);
digitalWrite(EN_EL, LOW);
digitalWrite(DIR_EL, LOW);
/* Enable/Disable Motors*/
pinMode(EN, OUTPUT);
digitalWrite(EN, HIGH);
/* Step size */
pinMode(MS1, OUTPUT);
digitalWrite(MS1, LOW); //Full step
Serial.begin(19200);
}
void loop()
{
/*Time Check*/
if (t1 == 0)
t1 = millis();
/*Disable Motors*/
if (stepAz == 0 && stepEl == 0 && millis()-t1 > T_DEALY)
digitalWrite(EN, HIGH);
/*Enable Motors*/
else
digitalWrite(EN, LOW);
cmd_proc();
stepper_move();
}

View File

@ -1,51 +0,0 @@
void cmd_proc()
{
/*Serial*/
static char buffer[256];
char incomingByte;
static int counter=0;
char data[100];
/*Read from serial*/
while (Serial.available() > 0)
{
incomingByte = Serial.read();
/*new data*/
if (incomingByte == '\n' || incomingByte == ' ' || incomingByte == '\r')
{
buffer[counter]=0;
if (buffer[0] == 'A' && buffer[1] == 'Z')
{
strncpy(data, buffer+2, 100);
double cmdAz = atof(data);
stepAz = deg2step(cmdAz)-stepPosAz;
}
else if (buffer[0] == 'E' && buffer[1] == 'L')
{
strncpy(data, buffer+2, 10);
double cmdEl = atof(data);
stepEl = deg2step(cmdEl)-stepPosEl;
}
else if (buffer[0] == 'S' && buffer[1] == 'A')
{
stepAz = 0;
}
else if (buffer[0] == 'S' && buffer[1] == 'E')
{
stepEl = 0;
}
counter = 0;
//Reset time
t1 = 0;
}
/*Fill the buffer with incoming data*/
else {
buffer[counter] = incomingByte;
counter++;
}
}
}

View File

@ -1,48 +0,0 @@
void stepper_move()
{
if(stepAz>0)
{
digitalWrite(DIR_AZ, HIGH);
digitalWrite(STEP_AZ, HIGH);
stepPosAz++;
stepAz--;
}
else if(stepAz<0)
{
digitalWrite(DIR_AZ, LOW);
digitalWrite(STEP_AZ, HIGH);
stepPosAz--;
stepAz++;
}
if(stepEl>0)
{
digitalWrite(DIR_EL, LOW);
digitalWrite(STEP_EL, HIGH);
stepPosEl++;
stepEl--;
}
else if(stepEl<0)
{
digitalWrite(DIR_EL, HIGH);
digitalWrite(STEP_EL, HIGH);
stepPosEl--;
stepEl++;
}
delay(T_STEPPER);
digitalWrite(STEP_AZ, LOW);
digitalWrite(STEP_EL, LOW);
delay(T_STEPPER);
}
int deg2step(double deg)
{
return(60*SPD*deg/360);
}
float step2deg(int Step)
{
return(360*Step/(SPD*60));
}