Jump to content

NLCbanner2024.jpg.2478be509670e60c2d6efd04834b8b47.jpg

Quad remote focussing system


Gina

Recommended Posts

This follows on from my Power supply issues thread but as this has little to do with power supplies, I'm starting a new thread.

My main imaging rig is going to have four telescopes, all of which I would like to focus separately.  Though not necessarily all at the same time.

I have been working on a system using an Arduino Mega 2560 providing 16 digital outputs driving 4 stepper motors via ULN2003A driver modules.  The Uno and Nano versions have only 12 digital outputs so a limit of 3 stepper motors.

ATM I'm trying to debug my sketch but having found and corrected a couple of mistakes the Arduino USB has stopped working.  It's getting power but the PC is not seeing the USB data port.  I have tried rebooting the PC and another USB port but no joy.  After a couple of false starts another Mega worked as far as finding the USB and uploading the sketch was concerned.  Can't tell if the upload was successful as this Mega isn't connected to any hardware other than the PC.

I'm wondering if the other Mega has failed or if there's some other reason the USB port isn't visible.

I've had this problem before with Nanos using the mini USB but not before on an Arduino using the standard USB B type connection.

Does anyone have any ideas other than to replace the original Mega with the new one, please?  Due to the construction, replacing the Arduino Mega means disconnecting several other components to get at it :(  OK so it's a bad design! :(

Link to comment
Share on other sites

I've got the Arduino Mega out by removing the box from the aluminium plate and taking it out from the bottom.  It's an open bottom box to aid printing it.  Now I have decided that putting both the power distribution and focus control system in the same box is not such a good idea.  We live and learn as they say :D

Link to comment
Share on other sites

plug in the usb of the mega, then uninstall the serial Com port that gets configured, next unplug the usb and reinstall it 

the pc will create a new com port with a new number i.e. will go from COM12 to COM13 etc 

Thank you - I'll try that :)  The new Mega is using a different COM port (from COM9 to COM15).  I think the other board is probably faulty though as connecting to a computer doesn't produce any reaction.

Link to comment
Share on other sites

The PC will create a COM port for each device you connect, another trick is to move it to an alternate usb port on the PC that can sometimes be driven by an alternate usb bus interface, and hence will re address the drivers 

can be a quick fix in a problem 

Link to comment
Share on other sites

Focus controller all working now :)  A few mods to the Arduino sketch to correct errors and add a couple of extras.  Sketch now turns stepper motors off after 10s of inactivity.  Only selected focuser stepper motor is operated - others remain off.  If the Arduino IDE is run and the Serial Monitor selected, the focuser number and focus count will be displayed.

Here is the latest sketch.

// Updated 2014-11-23 14:30// Gina's quadruple remote focussing system using manual control// with resistor values selected by toggle switches to select // which focus stepper motor to control and push buttons to choose// 1 - Fast Backwards// 2 - 10 Steps Back// 3 - One Step Back// 4 - One Step Forwards// 5 - Fast Forwards// No button pressed represents no action (case 0).//// Stepper motors used are 28BYJ-48 12v version with ULN2003 drivers// 4 phase, 8-beat motor, geared down by a factor of 64. // Step angle is 5.625/64 degrees.//// Arduino Sketch for triple imaging refractor rig plus MN190 Mak Newt focus control// This uses an Arduino Mega 2560.////////////////////////////////////////////////////declare variables for the motor pinsint motorPin1a = 22;	// Blue   - 28BYJ48 pin 1int motorPin2a = 24;	// Pink   - 28BYJ48 pin 2int motorPin3a = 26;	// Yellow - 28BYJ48 pin 3int motorPin4a = 28;	// Orange - 28BYJ48 pin 4                        // Red    - 28BYJ48 pin 5 (power)int motorPin1b = 30;	// Blue   - 28BYJ48 pin 1int motorPin2b = 32;	// Pink   - 28BYJ48 pin 2int motorPin3b = 34;	// Yellow - 28BYJ48 pin 3int motorPin4b = 36;	// Orange - 28BYJ48 pin 4//int motorPin1c = 38;	// Blue   - 28BYJ48 pin 1int motorPin2c = 40;	// Pink   - 28BYJ48 pin 2int motorPin3c = 42;	// Yellow - 28BYJ48 pin 3int motorPin4c = 44;	// Orange - 28BYJ48 pin 4//int motorPin1d = 46;	// Blue   - 28BYJ48 pin 1int motorPin2d = 48;	// Pink   - 28BYJ48 pin 2int motorPin3d = 50;	// Yellow - 28BYJ48 pin 3int motorPin4d = 52;	// Orange - 28BYJ48 pin 4////////////////////////////int motorSpeed = 1200;  //variable to set stepper speedint count = 0;          // count of steps madeint countsperrev = 512; // number of steps per full revolutionint lookup[8] = {B01000, B01100, B00100, B00110, B00010, B00011, B00001, B01001};//////////////////////////////////int wfPin = 1;  // Focuser select switchesint controlPin = 0;  //  Input control line pinint wf =0; // which focuserint focusCount[4] = {0, 0, 0, 0};  // // int focusCount_b = 0;  // focus count for scope// int focusCountPrev_a = 0;// int focusCountPrev_b = 0;int val = 0;  //  value of control input voltage - functionint opCode = 0;  //  corresponding operation codeint wfval = 0;  //  value of control input voltage for which focuserint stepSize[4] = {5, 5, 1, 1};  // how many motor steps correspond to one focussing step - array for different focusersboolean busy = false;  // used to provide single action buttons - wait for "up" before continuingint timeOut = 0;  // Interval counter for turning all steppers off after a no activiuty period//////////////////////////////////////////////////////////////////////////////void setup() {  //declare the motor pins as outputs  pinMode(motorPin1a, OUTPUT);  pinMode(motorPin2a, OUTPUT);  pinMode(motorPin3a, OUTPUT);  pinMode(motorPin4a, OUTPUT);  pinMode(motorPin1b, OUTPUT);  pinMode(motorPin2b, OUTPUT);  pinMode(motorPin3b, OUTPUT);  pinMode(motorPin4b, OUTPUT);  pinMode(motorPin1c, OUTPUT);  pinMode(motorPin2c, OUTPUT);  pinMode(motorPin3c, OUTPUT);  pinMode(motorPin4c, OUTPUT);  pinMode(motorPin1d, OUTPUT);  pinMode(motorPin2d, OUTPUT);  pinMode(motorPin3d, OUTPUT);  pinMode(motorPin4d, OUTPUT);  Serial.begin(9600);}////////////////////////////////////////////////////////////////////////////////set pins to ULN2003 high in sequence from 1 to 4//delay "motorSpeed" between each pin setting (to determine speed)void serialDisplay(){  Serial.print ("Focuser ");  Serial.print (wf+1);  Serial.print (" - Focus Count ");  Serial.println (focusCount[wf]);}void moveBackward(){  for (int s = 0; s < stepSize[wf]; s++) {    for(int i = 0; i < 8; i++)    {      setOutput(i);      delayMicroseconds(motorSpeed);      timeOut = 0;    }  }  focusCount[wf]--;  serialDisplay();}///////////////////////////void moveForward(){  for (int s = 0; s < stepSize[wf]; s++) {    for(int i = 7; i >= 0; i--)    {      setOutput(i);      delayMicroseconds(motorSpeed);      timeOut = 0;    }  }  focusCount[wf]++;  serialDisplay();}////////////////////////void setOutput(int out){  switch(wf) {    case 0 :  {      digitalWrite(motorPin1a, bitRead(lookup[out], 0));      digitalWrite(motorPin2a, bitRead(lookup[out], 1));      digitalWrite(motorPin3a, bitRead(lookup[out], 2));      digitalWrite(motorPin4a, bitRead(lookup[out], 3));      break;   }    case 1 :  {      digitalWrite(motorPin1b, bitRead(lookup[out], 0));      digitalWrite(motorPin2b, bitRead(lookup[out], 1));      digitalWrite(motorPin3b, bitRead(lookup[out], 2));      digitalWrite(motorPin4b, bitRead(lookup[out], 3));      break;  }    case 2 :  {      digitalWrite(motorPin1c, bitRead(lookup[out], 0));      digitalWrite(motorPin2c, bitRead(lookup[out], 1));      digitalWrite(motorPin3c, bitRead(lookup[out], 2));      digitalWrite(motorPin4c, bitRead(lookup[out], 3));      break;  }    case 3 :  {      digitalWrite(motorPin1d, bitRead(lookup[out], 0));      digitalWrite(motorPin2d, bitRead(lookup[out], 1));      digitalWrite(motorPin3d, bitRead(lookup[out], 2));      digitalWrite(motorPin4d, bitRead(lookup[out], 3));      break;  }  }}///////////////////////void moveB10() {   if (busy == false) {  // do it once then wait for button release     for (int i = 9; i >= 0; i--) {    moveBackward(); }    busy = true; }}////////////////////////////void moveB1() {    if (busy == false) {    moveBackward();    busy = true; }}//////////////////////////void moveF1() {    if (busy == false) {    moveForward();    busy = true; }}///////////////////////void loop() {  wfval = analogRead(wfPin);  // Select which focuser to control// Break points 250, 500 and 750  if (wfval < 250) {  //  allow for small variations in control line voltage by separating into bands    wf = 3;  } else if (wfval < 500) {    wf = 2;  } else if (wfval < 750) {    wf = 1;  } else {    wf = 0;  }  val = analogRead(controlPin);// Break points 102, 307, 512, 717 and 922  if (val < 102) {  //  allow for small variations in control line voltage by separating into bands    opCode = 5;  } else if (val < 307) {    opCode = 4;  } else if (val < 512) {    opCode = 3;  } else if (val < 717) {    opCode = 2;  } else if (val < 922) {    opCode = 1;  } else {    opCode = 0;  //  no button pressed  }//  switch(opCode) {    case 0 : busy = false; delay(100); checkTimeout(); break;  // clear busy flag and wait for button state to settle (switch bounce)    case 1 : moveBackward(); break;    case 2 : moveB10(); break;    case 3 : moveB1(); break;    case 4 : moveF1(); break;    case 5 : moveForward(); break;  }}void checkTimeout(){  timeOut++;   if (timeOut > 100) {    allOff();  } }void allOff() {      digitalWrite(motorPin1a, 0);      digitalWrite(motorPin2a, 0);      digitalWrite(motorPin3a, 0);      digitalWrite(motorPin4a, 0);      digitalWrite(motorPin1b, 0);      digitalWrite(motorPin2b, 0);      digitalWrite(motorPin3b, 0);      digitalWrite(motorPin4b, 0);      digitalWrite(motorPin1c, 0);      digitalWrite(motorPin2c, 0);      digitalWrite(motorPin3c, 0);      digitalWrite(motorPin4c, 0);      digitalWrite(motorPin1d, 0);      digitalWrite(motorPin2d, 0);      digitalWrite(motorPin3d, 0);      digitalWrite(motorPin4d, 0);      timeOut = 0;      Serial.println ("All Off");}
Link to comment
Share on other sites

Just tried the focussing unit out in the obsy but it's not working :(  Some of the stepper motors are showing LEDs on and running when they shouldn't be.  Strange, it was fine indoors.  I haven't got the Arduino IDE on the opsy laptop but that shouldn't matter - the sketch is already on board.

Focussing system box back indoors and it's working perfectly.

Link to comment
Share on other sites

It's all working now out in the observatory with stepper motors connected for the Esprit and ST80.  ATM I'm only using the MN190 for guiding so I can connect that up tonight if necessary but focussing doesn't need to be accurate for guiding.  The focus steps seem fine with 5 stepper motor steps per focus step for the Esprit (which has 11:1 reduction on the focuser) and 1 motor step per focus step for the ST80.  I have set up on the tree on the far hill.

The only change I've made AFAIK is to install the Arduino IDE on the obsy laptop.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. By using this site, you agree to our Terms of Use.