Unify arduino files, add arduino micro shield.

v1
Agis Zisimatos 2014-11-11 20:56:48 +02:00
parent 03abf6fb09
commit 5d27da97af
8 changed files with 12884 additions and 139 deletions

View File

@ -2,59 +2,171 @@
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
#define DIR_AZ 8 #define DIR_AZ 18
#define STEP_AZ 9 #define STEP_AZ 10
#define EN_AZ 7
#define DIR_EL 10 #define DIR_EL 6
#define STEP_EL 11 #define STEP_EL 7
#define EN_EL 12
#define SPD 200 //step per degree #define MS1 9
#define T_DEALY 10000 #define EN 8
#define T_STEPPER 1
int stepPosAz = 0; #define SPR 200 //Step Per Revolution
int stepAz = 0; #define RATIO 60 //Gear ratio
int stepPosEl = 0; #define T_DEALY 10000 //Time to disable the motors
int stepEl = 0; #define T_STEPPER 1000 //2*T_STEPPER is the period of pulses
long t1 = 0;
/*Global Variables*/
long t_DIS = 0; //time to disable the Motors
void setup() void setup()
{ {
/*Define the Stepper drivers PIN's*/
pinMode(DIR_AZ, OUTPUT); pinMode(DIR_AZ, OUTPUT);
pinMode(STEP_AZ, OUTPUT); pinMode(STEP_AZ, OUTPUT);
pinMode(EN_AZ, OUTPUT);
digitalWrite(EN_AZ, LOW);
digitalWrite(DIR_AZ, LOW);
pinMode(DIR_EL, OUTPUT); pinMode(DIR_EL, OUTPUT);
pinMode(STEP_EL, OUTPUT); pinMode(STEP_EL, OUTPUT);
pinMode(EN_EL, OUTPUT); digitalWrite(STEP_AZ, LOW);
digitalWrite(EN_EL, LOW); digitalWrite(DIR_AZ, LOW);
digitalWrite(STEP_EL, LOW);
digitalWrite(DIR_EL, LOW); digitalWrite(DIR_EL, LOW);
/*Enable Motors*/
pinMode(EN, OUTPUT);
digitalWrite(EN, LOW);
/*Step size */
pinMode(MS1, OUTPUT);
digitalWrite(MS1, LOW); //Full step
Serial.begin(19200); Serial.begin(19200);
} }
void loop() void loop()
{ {
/*Define the steps*/
static int AZstep = 0;
static int ELstep = 0;
/*Define the steps from the start of motion*/
static int AZstepPos = 0;
static int ELstepPos = 0;
/*Time Check*/ /*Time Check*/
if (t1 == 0) if (t_DIS == 0)
t1 = millis(); t_DIS = millis();
if (stepAz == 0 && stepEl == 0 && millis()-t1 > T_DEALY) /*Disable Motors*/
{ if (AZstep == 0 && ELstep == 0 && millis()-t_DIS > T_DEALY)
digitalWrite(EN_AZ, HIGH); digitalWrite(EN, HIGH);
digitalWrite(EN_EL, HIGH); /*Enable Motors*/
}
else else
digitalWrite(EN, LOW);
/*Read the steps from serial*/
cmd_proc(AZstep, ELstep, AZstepPos, AZstepPos);
/*Move the Azimuth & Elevation Motor*/
stepper_move(AZstep, ELstep, AZstepPos, ELstepPos);
Serial.print(AZstepPos);Serial.print("\t");
Serial.println(AZstep);
}
/*EasyComm 2 Protocol & Calculate the steps*/
void cmd_proc(int &stepAz, int &stepEl, int stepPosAz, int stepPosEl)
{
/*Serial*/
static char buffer[256];
char incomingByte;
static int counter=0;
char data[100];
/*Read from serial*/
while (Serial.available() > 0)
{ {
digitalWrite(EN_AZ, LOW); incomingByte = Serial.read();
digitalWrite(EN_EL, LOW); /*new data*/
if (incomingByte == '\n' || incomingByte == ' ' || incomingByte == '\r')
{
buffer[counter]=0;
if (buffer[0] == 'A' && buffer[1] == 'Z')
{
strncpy(data, buffer+2, 100);
/*Get the absolute value of angle*/
double angleAz = atof(data);
/*Calculate the steps*/
stepAz = deg2step(angleAz) - stepPosAz;
}
else if (buffer[0] == 'E' && buffer[1] == 'L')
{
strncpy(data, buffer+2, 10);
/*Get the absolute value of angle*/
double angleEl = atof(data);
/*Calculate the steps*/
stepEl = deg2step(angleEl) - stepPosEl;
}
else if (buffer[0] == 'S' && buffer[1] == 'A')
{
stepAz = 0;
}
else if (buffer[0] == 'S' && buffer[1] == 'E')
{
stepEl = 0;
}
counter = 0;
/*Reset the disable motor time*/
t_DIS = 0;
}
/*Fill the buffer with incoming data*/
else {
buffer[counter] = incomingByte;
counter++;
}
}
}
/*Send pulses to stepper motor drivers*/
void stepper_move(int &stepAz, int &stepEl, int &stepPosAz, int &stepPosEl)
{
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++;
} }
cmd_proc(); 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++;
}
stepper_move(); delayMicroseconds(T_STEPPER);
digitalWrite(STEP_AZ, LOW);
digitalWrite(STEP_EL, LOW);
delayMicroseconds(T_STEPPER);
}
/*Convert degrees to steps*/
int deg2step(double deg)
{
return(RATIO*SPR*deg/360);
}
/*Convert steps to degrees*/
double step2deg(int Step)
{
return(360*Step/(SPR*RATIO));
} }

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,49 +0,0 @@
/* Send pulses to stepper motor drivers */
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);
}
/* Convert degrees to steps */
int deg2step(double deg)
{
return(60*SPR*deg/360);
}
/* Convert steps to degrees */
float step2deg(int Step)
{
return(360*Step/(SPR*60));
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1484
PCB/satnogs.lbr 100644

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View File

@ -1,7 +1,9 @@
SatNOGS Arduino SatNOGS Arduino
=============== ===============
Repository of Arduino code for SatNOGS project. Repository of Arduino code and Arduino PCB for SatNOGS project.
Refer to block diagram in the repository for wiring documentation. Refer to block diagram in the repository for wiring documentation.
![satnogs_Diagram](https://raw.github.com/satnogs/satnogs-arduino/master/Pics/Block Diagram.png) The PCB is based in [Arduino Pro Micro](https://www.sparkfun.com/products/12640) and the [Pololu stepper motor driver](http://www.pololu.com/product/1182). In the picture below you can see the PCB.
![satnogs_PCB](https://raw.github.com/satnogs/satnogs-arduino/master/Pics/SatNOGS_Board.png)