diff --git a/AstroEQ5/AstroEQ5.ino b/AstroEQ5/AstroEQ5.ino index 8426cd5a6da1a2871b6253cae468b466bbafb6b4..b52c4a8189b26d299c3d53b7b30dc065f2d9291e 100644 --- a/AstroEQ5/AstroEQ5.ino +++ b/AstroEQ5/AstroEQ5.ino @@ -100,9 +100,21 @@ //to make it smaller than that limit. In my case I have chosen 10 as it nicely scales the //a and s values. Hence below, I have set scalar to 10. + + + + //This is the initialistation code. If using the excel file, replace this line with what it gives. // aVal bVal sVal scalar + +//Example for same ratio per axis Synta synta(1281, 13271040, 95493, 16, 92160, 3); +//Example for different ratio per axis (see excel file). +//Synta synta(1281, 9024000, 9011200, 64933, 64841, 62667, 62578, 16, 1); + + + + //Define the two axes (swap the 0 and 1 if R.A. and Dec. motors are reversed) #define RA 0 @@ -400,9 +412,9 @@ void calculateRate(byte motor){ remainder = (unsigned long)floatRemainder; //Now truncate to an unsigned int with a sensible max value (the int is to avoid register issues with the 16 bit timer) - if(rate > 64997L){ - rate = 64997L; - } else if (rate < 36L) { + if(rate > 64997UL){ + rate = 64997UL; + } else if (rate < 36UL) { rate = 36L; } for (int i = 0; i < distributionWidth[motor]; i++){ diff --git a/AstroEQ5/Open me first/Initialisation Variable Calculator.xlsx b/AstroEQ5/Open me first/Initialisation Variable Calculator.xlsx index 60373fa6e27dbd9489321f9c035fb173aaf3002c..9f38db7413040d2670511055998e106d233b631a 100644 Binary files a/AstroEQ5/Open me first/Initialisation Variable Calculator.xlsx and b/AstroEQ5/Open me first/Initialisation Variable Calculator.xlsx differ diff --git a/AstroEQ5/Open me first/hardware/arduino/variants/AstroEQ/pins_arduino.h b/AstroEQ5/Open me first/hardware/arduino/variants/AstroEQ/pins_arduino.h index 66587c167398485354e0c16d56a988418bf04e33..a8994b2ba8b073373c45fb913969a0ca09b69a28 100644 --- a/AstroEQ5/Open me first/hardware/arduino/variants/AstroEQ/pins_arduino.h +++ b/AstroEQ5/Open me first/hardware/arduino/variants/AstroEQ/pins_arduino.h @@ -56,8 +56,7 @@ const static uint8_t LED_BUILTIN = 13; #ifdef ARDUINO_MAIN // On the Arduino board, digital pins are also used -// for the analog output (software PWM). Analog input -// pins are a separate set. +// for the analog output (software PWM). // ATMEL ATMEGA162 / ARDUINO // diff --git a/AstroEQ5/commands.cpp b/AstroEQ5/commands.cpp index 607cc8c52e635fcbd5cca239d4a735cc6edb1146..9a582d31ecc28e8148d564e5d151539b11a1c050 100644 --- a/AstroEQ5/commands.cpp +++ b/AstroEQ5/commands.cpp @@ -23,7 +23,24 @@ #endif #include "commands.h" - +void Commands::init(unsigned long eVal,unsigned long aVal1,unsigned long aVal2,unsigned long bVal1,unsigned long bVal2,unsigned long sVal1,unsigned long sVal2,byte gVal){ + for(byte i = 0;i < 2;i++){ + _flag[i] = 0x100; + _jVal[i] = 0x800000; //Current position, 0x800000 is the centre + _IVal[i] = 0; //Recieved Speed + _GVal[i] = 0; //Mode recieved from :G command + _HVal[i] = 0; //Value recieved from :H command + _eVal[i] = eVal; //version number + _gVal[i] = gVal; //High speed scalar + } + _aVal[0] = aVal1; //steps/axis + _aVal[1] = aVal2; //steps/axis + _bVal[0] = bVal1; //sidereal rate + _bVal[1] = bVal2; //sidereal rate + _sVal[0] = sVal1; //steps/worm rotation + _sVal[1] = sVal2; //steps/worm rotation +} + void Commands::init(unsigned long eVal,unsigned long aVal,unsigned long bVal,byte gVal,unsigned long sVal){ for(byte i = 0;i < 2;i++){ _flag[i] = 0x100; diff --git a/AstroEQ5/commands.h b/AstroEQ5/commands.h index bd78e968dbd1d205760299f0f22fccf9d3db75ac..8dc127f857fb66c998ab69d5276f7360354d90ab 100644 --- a/AstroEQ5/commands.h +++ b/AstroEQ5/commands.h @@ -24,6 +24,7 @@ class Commands{ public: + void init(unsigned long eVal,unsigned long aVal1,unsigned long aVal2,unsigned long bVal1,unsigned long bVal2,unsigned long sVal1,unsigned long sVal2,byte gVal); void init(unsigned long eVal,unsigned long aVal,unsigned long bVal,byte gVal,unsigned long sVal); //Command definitions diff --git a/AstroEQ5/synta.cpp b/AstroEQ5/synta.cpp index e5b19d7c2c36c1d3687f8481a5adb544d999a5e0..95c3d3be91618be96b4d996956d392c950688228 100644 --- a/AstroEQ5/synta.cpp +++ b/AstroEQ5/synta.cpp @@ -10,6 +10,15 @@ Synta::Synta(unsigned long eVal,unsigned long aVal,unsigned long bVal,byte gVal, cmd.init(eVal, aVal, bVal, gVal, sVal); } +Synta::Synta(unsigned long eVal,unsigned long aVal1,unsigned long aVal2,unsigned long bVal1,unsigned long bVal2,unsigned long sVal1,unsigned long sVal2,byte gVal,byte scalar){ + validPacket = 0; + _axis = 0; + commandIndex = 0; + clearBuffer(commandString,sizeof(commandString)); + _scalar = scalar; + cmd.init(eVal, aVal1, aVal2, bVal1, bVal2, sVal1, sVal2, gVal); +} + const char Synta::startInChar = ':'; const char Synta::startOutChar = '='; const char Synta::errorChar = '!'; diff --git a/AstroEQ5/synta.h b/AstroEQ5/synta.h index a698025af3cc5da89ba47321dc49dc786557e2ad..8d12d90c5d30e4f1bdaa96f7feb82fe3e63d9124 100644 --- a/AstroEQ5/synta.h +++ b/AstroEQ5/synta.h @@ -12,6 +12,7 @@ class Synta{ public: Synta(unsigned long eVal,unsigned long aVal,unsigned long bVal,byte gVal,unsigned long sVal,byte scalar); + Synta(unsigned long eVal,unsigned long aVal1,unsigned long aVal2,unsigned long bVal1,unsigned long bVal2,unsigned long sVal1,unsigned long sVal2,byte gVal,byte scalar); Commands cmd; void assembleResponse(char* dataPacket, char commandOrError, unsigned long responseData); char recieveCommand(char* dataPacket, char character);