diff --git a/Arduino/SatNOGS.ino b/Arduino/SatNOGS.ino new file mode 100644 index 0000000000000000000000000000000000000000..1df4c03d0e11fa4df92b2dca8435b14d5a22008d --- /dev/null +++ b/Arduino/SatNOGS.ino @@ -0,0 +1,60 @@ +#include +#include +#include + +#define DIR_AZ 8 +#define STEP_AZ 9 +#define EN_AZ 7 + +#define DIR_EL 10 +#define STEP_EL 11 +#define EN_EL 12 + +#define SPD 200 //step per degree +#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); + pinMode(EN_AZ, OUTPUT); + digitalWrite(EN_AZ, LOW); + digitalWrite(DIR_AZ, LOW); + + pinMode(DIR_EL, OUTPUT); + pinMode(STEP_EL, OUTPUT); + pinMode(EN_EL, OUTPUT); + digitalWrite(EN_EL, LOW); + digitalWrite(DIR_EL, LOW); + + Serial.begin(19200); +} + +void loop() +{ + /*Time Check*/ + if (t1 == 0) + t1 = millis(); + if (stepAz == 0 && stepEl == 0 && millis()-t1 > T_DEALY) + { + digitalWrite(EN_AZ, HIGH); + digitalWrite(EN_EL, HIGH); + } + else + { + digitalWrite(EN_AZ, LOW); + digitalWrite(EN_EL, LOW); + } + + cmd_proc(); + + stepper_move(); +} diff --git a/Arduino/Serial.ino b/Arduino/Serial.ino new file mode 100644 index 0000000000000000000000000000000000000000..39076afbf27922e59685f8240a6ef36d54585037 --- /dev/null +++ b/Arduino/Serial.ino @@ -0,0 +1,51 @@ +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++; + } + } +} diff --git a/Arduino/Stepper.ino b/Arduino/Stepper.ino new file mode 100644 index 0000000000000000000000000000000000000000..bb63030f6aa6d1d537aebd0071867776fe63baf5 --- /dev/null +++ b/Arduino/Stepper.ino @@ -0,0 +1,49 @@ +/* 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)); +} diff --git a/Pics/Block Diagram.dia b/Pics/Block Diagram.dia new file mode 100644 index 0000000000000000000000000000000000000000..16b32e0854c03d1b1502f6ffc831e12be28c9870 Binary files /dev/null and b/Pics/Block Diagram.dia differ diff --git a/Pics/Block Diagram.png b/Pics/Block Diagram.png new file mode 100644 index 0000000000000000000000000000000000000000..4183f163fc321027ea4932b4bf34ef5fc4f4ae72 Binary files /dev/null and b/Pics/Block Diagram.png differ diff --git a/README.md b/README.md index b37ef4ab02e537b12792623d9b13e33f2d48d118..5f295df29d1b2eccefc6c76320a784cfeca51c52 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,7 @@ SatNOGS Arduino =============== -Repository of Arduino code and Arduino PCB for SatNOGS project. +Repository of Arduino code for SatNOGS project. Refer to block diagram in the repository for wiring documentation. -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_V1_1.png) \ No newline at end of file +![satnogs_Diagram](https://raw.github.com/satnogs/satnogs-arduino/master/Pics/Block Diagram.png) \ No newline at end of file