├── .gitattributes ├── .gitignore └── Startracker_v5.ino /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear on external disk 35 | .Spotlight-V100 36 | .Trashes 37 | 38 | # Directories potentially created on remote AFP share 39 | .AppleDB 40 | .AppleDesktop 41 | Network Trash Folder 42 | Temporary Items 43 | .apdisk 44 | -------------------------------------------------------------------------------- /Startracker_v5.ino: -------------------------------------------------------------------------------- 1 | // STARTRACKER MOTOR CONTROL: STEPPER MOTOR CONTROL FOR JJROBOTS POV DISPLAY 2 | // This code is designed for JJROBOTS arDusplay Stepper Motor Control board 3 | // Author: JJROBOTS.COM (Jose Julio & Juan Pedro) 4 | // Licence: GNU GPL 5 | // Stepper : NEMA17 6 | // Driver : A4988 or DRV8825 7 | // Microstepping : configured to 1/16 8 | // Arduino board: Pro micro (leonardo equivalent) 9 | 10 | // STEPPER DRIVER CONNECTED TO: 11 | // ENABLE pin: D10 (PB6) 12 | // DIR pin: D9 (PB5) 13 | // STEP pin: D8 (PB4) 14 | // Button1 : START/STOP D4 15 | // Button2 : DEC D5 16 | // Button3 : CHANGE ROTATION DIRECTION (go back to original position) D6 17 | 18 | //DO NO TAKE PHOTOS WITH AN EXPOSITION LONGER THAN 5 MINUTES. THE DRIFT WOULD BE NOTICEABLE. 19 | 20 | //Theory behind this CODE 21 | //----------------------------------------- 22 | // 360º (rotation of the Earth every 1436min) 23 | // *Using a M8 rod coming up 1.25mm every complete rotation 24 | 25 | #define COMINGUPSPEED 1.25 //milimeters that the rod comes up every complete rotation (360º). In a M8 rod/bolt is usually 1.25 mm. In a M6, only 1.00mm 26 | 27 | 28 | //other info needed: 29 | //ratio between the large gear and the small one=0.2549 30 | 31 | //MEASURE THIS VALUE AS GOOD AS YOU CAN AND SET THE LENGHT BELOW 32 | #define LENGTH 228 //distance from the centre of the hinge to the centre of the hole for the rod in milimiters 33 | 34 | 35 | // Calculus here: 36 | #define STEP ((2*3.14159)/1436)*LENGTH //rotational velocity of the small gear 37 | 38 | #define RPS (STEP/(60*0.2549))/COMINGUPSPEED //rotational velocity of the large gear 39 | 40 | 41 | #define ZERO_SPEED 65535 42 | #define STEPS_PER_REV 3200 // 200 steps motor with 1/16 microstepping 43 | #define MAX_RPM (RPS*60.0) 44 | 45 | // BIT functions 46 | #define CLR(x,y) (x&=(~(1<MAX_RPM) 80 | rpm = MAX_RPM; 81 | temp = (rpm/60.0)*STEPS_PER_REV; 82 | temp = 2000000 / temp; // 2000000 = (16000000/8) timer1 16Mhz with 1/8 preescaler 83 | if (period<600000) 84 | period=60000; 85 | period = temp; 86 | while (TCNT1 < 30); // Wait until a pulse to motor has finished 87 | //cli(); 88 | ICR1 = period; //+ userCommand; 89 | if (TCNT1 > ICR1) // Handle when we need to reset the timer 90 | TCNT1=0; 91 | //sei(); 92 | } 93 | } 94 | 95 | void setup() 96 | { 97 | 98 | pinMode(7,OUTPUT); // LED pin 99 | pinMode(8,OUTPUT); // STEP pin 100 | pinMode(9,OUTPUT); // DIR pin 101 | pinMode(10,OUTPUT); // ENABLE pin 102 | 103 | // Button input with pullups enable 104 | pinMode(4,INPUT_PULLUP); 105 | pinMode(5,INPUT_PULLUP); 106 | pinMode(6,INPUT_PULLUP); 107 | 108 | digitalWrite(10,HIGH); // Disable motor 109 | digitalWrite(9,HIGH); // Motor direction 110 | 111 | Serial.begin(115200); 112 | 113 | digitalWrite(7,HIGH); 114 | delay(200); // Initial delay 115 | Serial.println("ArduPOV MOTOR Stepper motor driver v1.0"); 116 | digitalWrite(7,LOW); 117 | 118 | motor_enable = 0; 119 | 120 | // PWM SETUP 121 | // Fast PWM mode => TOP:ICR1 122 | TCCR1A =(1<