The setup is the usual, ASI 224MC, TSO ADC, N250/1200, HEQ5 with the home made motorized focuser and the home made arduino noszogtató mount guider. I would like to call this the soapbox project — it is mounted inside a soap box, though in Hungarian and Romanian we use soapbox to denote compact and dumb cameras too.
The soapbox device:
The arduino source code used to pull down the ST4’s input pins, through an optocoupler much like here:
#include "timer.h" #define TIMER_INTERVAL_MS 10 auto timer = timer_create_default(); #define TIMER2_DIVIDER 21 // for some reason that extra 1 is needed, and below, comparing to 1 works, to zero does not int timerDivider; const int READ_BUFFER_LEN = 15; char readBuffer[READ_BUFFER_LEN]; #define RA_PLUS 9 #define RA_MINUS 10 #define DEC_PLUS 11 #define DEC_MINUS 12 typedef struct HEQ5_Pin { int pinNumber; int inPairWithPinNumber; int timeLeft; int currentState; } HEQ5_Pin; HEQ5_Pin heq5Pins[5]; //--------------------------------------------------------------------- void pins_add(int pin, int ms){ if (pin > 4){ return ; } if (pin < 0){ return ; } if (ms > 0){ // valid ms, increment the time left heq5Pins[pin].timeLeft += ms; if (heq5Pins[pin].inPairWithPinNumber > 0){ for (ms =0; ms < 5; ms++){ if (heq5Pins[ms].pinNumber == heq5Pins[pin].inPairWithPinNumber){ heq5Pins[ms].timeLeft = 0; } } } }else{ //invalid ms given, stop the motion heq5Pins[pin].timeLeft = 0; if (heq5Pins[pin].inPairWithPinNumber > 0){ for (ms =0; ms < 5; ms++){ if (heq5Pins[ms].pinNumber == heq5Pins[pin].inPairWithPinNumber){ heq5Pins[ms].timeLeft = 0; } } } } } //--------------------------------------------------------------------- void pins_process(){ for (int i=0; i<5; i++){ if (heq5Pins[i].timeLeft > 0){ if (heq5Pins[i].currentState != HIGH){ digitalWrite(heq5Pins[i].pinNumber, HIGH); heq5Pins[i].currentState = HIGH; } }else{ if (heq5Pins[i].currentState != LOW){ digitalWrite(heq5Pins[i].pinNumber, LOW); heq5Pins[i].currentState = LOW; } } } } void timerCallback(){ for (int i = 0; i<5; i++){ if (heq5Pins[i].timeLeft > 0){ heq5Pins[i].timeLeft -= TIMER_INTERVAL_MS; if (heq5Pins[i].timeLeft < 0){ heq5Pins[i].timeLeft = 0; } } } timerDivider--; } void setup() { // put your setup code here, to run once: readBuffer[0] = 0; Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for native USB } heq5Pins[0].pinNumber = RA_MINUS; heq5Pins[0].inPairWithPinNumber = RA_PLUS; heq5Pins[1].pinNumber = RA_PLUS; heq5Pins[1].inPairWithPinNumber = RA_MINUS; heq5Pins[2].pinNumber = DEC_MINUS; heq5Pins[2].inPairWithPinNumber = DEC_PLUS; heq5Pins[3].pinNumber = DEC_PLUS; heq5Pins[3].inPairWithPinNumber = DEC_MINUS; // sanity check led heq5Pins[4].pinNumber = 13; heq5Pins[3].inPairWithPinNumber = 0; for (int i=0; i<5; i++){ heq5Pins[i].timeLeft = 0; heq5Pins[i].currentState = LOW; pinMode(heq5Pins[i].pinNumber, OUTPUT); digitalWrite(heq5Pins[i].pinNumber, heq5Pins[i].currentState); } timerDivider = TIMER2_DIVIDER; timer.every(TIMER_INTERVAL_MS, timerCallback); } void reportStatus(){ Serial.print("STATUS "); for (int i=0; i<5; i++){ if (heq5Pins[i].pinNumber == RA_MINUS){ Serial.print("ra-,"); }; if (heq5Pins[i].pinNumber == RA_PLUS){ Serial.print("ra+,"); }; if (heq5Pins[i].pinNumber == DEC_MINUS){ Serial.print("dec-,"); }; if (heq5Pins[i].pinNumber == DEC_PLUS){ Serial.print("dec+,"); }; Serial.print(heq5Pins[i].timeLeft); Serial.print(" "); } Serial.println("STATUSEND"); } void loop() { if (Serial.available() > 0) { char c = Serial.read(); if (c == '#'){ readBuffer[0] = 0; }else{ if (c == '/'){ //process the command pin, #P,TTTTTTT/ // #rap,TTTTTT/ int pinIndex = readBuffer[0] - 48; if (readBuffer[0] == 'r'){ // rap, ran if (strncmp(readBuffer, "rap", 3) == 0){ for (int pi = 0; pi<5; pi++){ if (heq5Pins[pi].pinNumber == RA_PLUS){ pinIndex = pi; } } } if ((strncmp(readBuffer, "ran", 3) == 0) || (strncmp(readBuffer, "ram", 3) == 0)){ for (int pi = 0; pi<5; pi++){ if (heq5Pins[pi].pinNumber == RA_MINUS){ pinIndex = pi; } } } } if (readBuffer[0] == 'd'){ // decp, decm/n if (strncmp(readBuffer, "decp", 4) == 0){ for (int pi = 0; pi<5; pi++){ if (heq5Pins[pi].pinNumber == DEC_PLUS){ pinIndex = pi; } } } if ((strncmp(readBuffer, "decm", 4) == 0) || (strncmp(readBuffer, "decn", 4) == 0)){ for (int pi = 0; pi<5; pi++){ if (heq5Pins[pi].pinNumber == DEC_MINUS){ pinIndex = pi; } } } } char * timeString = strstr(readBuffer, ","); int timeAdd = 0; if (timeString){ timeAdd = atoi(timeString+1); pins_add(pinIndex, timeAdd); } Serial.print("ECHO: "); Serial.println(readBuffer); Serial.print("pin["); Serial.print(pinIndex); Serial.print("] += "); Serial.print(timeAdd); Serial.println(""); }else{ //continue to concat int n = strlen(readBuffer); if (n < READ_BUFFER_LEN-2){ readBuffer[n] = c; readBuffer[n+1] = 0; } } } }; timer.tick(); pins_process(); if (timerDivider <= 1){ timerDivider = TIMER2_DIVIDER; reportStatus(); } }






