Jump to content

Banner.jpg.b89429c566825f6ab32bcafbada449c9.jpg

Arduino controlled focussing


Gina

Recommended Posts

I am in the process of converting my DC motor/gearbox scope and lens focussing motors to steppers with Arduino control. I also want to arrange the selected imaging device to be controlled by software via the ASCOM driver. Two systems to control - but not at the same time (probably).

  1. ED80 with Baader SteelTrack focuser which already has a timing belt sprocket/pulley as part of the slow focus knob and I shall use that with timing belt and stepper motor with pulley mounted on my dual mounting plate.
  2. Camera lens in my wide field setup as shown below. Since this needs high ratio reduction gearing, I plan to use the same gearbox system but drive it with a stepper motor (with fewer gears).

post-13131-0-67875500-1360532520_thumb.j post-13131-0-89486400-1360530963_thumb.j post-13131-0-64010800-1360530971_thumb.j

Link to comment
Share on other sites

  • Replies 180
  • Created
  • Last Reply

i will follow this as i plan to do something like this myself. i have a question have you thought of your many foreys into controlling your devices. what happens when one or all lose power in a session or the automation just stops functioning. is there a easy manual way of control without tearing it all down at once. i hope the question was clear enough.

james 'doc' underwood

Link to comment
Share on other sites

I have been considering these for a focuser for the SLT. The motors themselves are only 64 step but the attached gearbox makes them 4096 steps per revolution. I suspect there is a bit of backlash in the gearbox but this could be compensated for in software.

Simon

Link to comment
Share on other sites

I have been considering these for a focuser for the SLT. The motors themselves are only 64 step but the attached gearbox makes them 4096 steps per revolution. I suspect there is a bit of backlash in the gearbox but this could be compensated for in software.

Simon

Those are exactly what I have :) Yes, there is a bit of backlash in the gearbox but not much - I'll see if I can measure it.
Link to comment
Share on other sites

i will follow this as i plan to do something like this myself. i have a question have you thought of your many foreys into controlling your devices. what happens when one or all lose power in a session or the automation just stops functioning. is there a easy manual way of control without tearing it all down at once. i hope the question was clear enough.

james 'doc' underwood

In everything that has automatic or remote control I have allowed for failure of the control system - everything has and will have a manual override. I consider this essential.
Link to comment
Share on other sites

Hi Gina,

I have been doing exactly what you are doing :grin: .

I salvaged 2 stepper motors from an old epson printer I had laying around, and used the SGL automation groups sketch. But as you have said I wanted to control the focuser on my scope and my guide scope. So I have used 2 easydrivers and set them up so that I can switch between the 2 using a toggle switch through an Arduino Nano.

I will be controlling them through ascom and BYEOS.

I have the board ready to go into my hub, just need time to put it in.

DSC_0153_zpscacd90c2.jpgDSC_0152_zpsdd885fd3.jpg

I have modded the sketch to respond to the switch and change the the output pins to switch between each easy driver:

#include <SPI.h>

//START OF FOCUS CONTROL INITIALISE

// include the library code:

#include <EEPROM.h>

#include <eepromRW.h>

#include <HalfStepper.h>

#include <AFMotor.h>

AF_Stepper motor(200, 2); // steps per rev and the connection of the stepper to AFmotor shield (2nd chip M3/M4)

#define MAX_COMMAND_LEN (5)

#define MAX_PARAMETER_LEN (6)

#define COMMAND_TABLE_SIZE (11)

#define TO_UPPER(x) (((x >= 'a') && (x <= 'z')) ? ((x) - ('a' - 'A')) : (x))

// initialize the library with the numbers of the interface pins

int dirPin = 6; // Easy Driver Direction Output Pin

int stepperPin = 7; // EasyDriver Stepper Step Output Pin

int powerPin = 5; //Sets the output used to power the Driver board, conect to enable pin on easydriver.

unsigned long powerMillis = 0; // used to remember when EasyDriver power was enabled

int motorSteps =3200; //number if steps for the motor to turn 1 revolution

int SWITCHpin =2;

int LED1pin =3;

int LED2pin =4;

volatile long NoOfSteps = 1000; //required number of steps to make

volatile long Position = 0; //used to keep track of the current motorposition

volatile long MaxStep = 19250; //define maximum no. of steps, max travel

volatile int SPEED = 500;

volatile byte MotorType = 0; // Motortypes, default is 0, Stepper motor, 1=Servo, 2=DC motor

volatile int BoardType = 0; // Boardtypes, default is 0, EasyDriver, 1=L293 chip, 2=LadyAda AFmotor board

boolean Direction = true;//True is one way false is other.Change to false if motor is moving in the wrong direction

boolean IsMoving = false;

boolean Absolute = true;

volatile long MaxIncrement=16384;//not yet used

HalfStepper myHalfStepper = HalfStepper(960, 9, 10, 11, 12);

//END OF FOCUS CONTROL INITIALISE

//Serial comms setup

char incomingByte = 0; // serial in data byte

byte serialValue = 0;

boolean usingSerial = true; // set to false to have the buttons control everything

char gCommandBuffer[MAX_COMMAND_LEN + 1];

char gParamBuffer[MAX_PARAMETER_LEN + 1];

long gParamValue;

volatile boolean UPDATE = true;

struct config_t //Memory Structure for Parking, Unparking the Focuser and other config settings

{

long parkposition;

boolean parked;

boolean stepperdirection;

long controlboardtype;

} configuration;

typedef struct {

char const *name;

void (*function)(void);

}

command_t;

//Set up a command table. when the command "IN" is sent from the PC and this table points it to the subroutine to run

command_t const gCommandTable[COMMAND_TABLE_SIZE] = {

{

"IN1", FocusINFun, }

,

{

"OUT", FocusOUTFun, }

,

{

"STP", FocusSTEPSFun, }

,

{

"SPD", FocusSPEEDFun, }

,

{

"LMT", FocusSLimitFun, }

,

{

"POS", FocusSPositionFun, }

,

{

"MDE", FocusSModeFun, }

,

{

"TYP", FocusSTypeFun, }

,

{

"PRK", ParkFocuserFun, }

,

{

"BRD", FocusBoardTypeFun, }

,

{

NULL, NULL }

};

//Serial Comms setup end

void setup() {

EEPROM_readAnything(0, configuration); //PARKING:- Read the Position and Parked info

if (configuration.parked == true) { //If the Focuser was Parked then load the Position information

Position = configuration.parkposition; //Load the Position information

Direction = configuration.stepperdirection;

BoardType = configuration.controlboardtype;

}

pinMode(LED1pin, OUTPUT);

pinMode(LED2pin, OUTPUT);

pinMode(SWITCHpin, INPUT);

pinMode(dirPin, OUTPUT); //Initialise Easydriver output

pinMode(stepperPin, OUTPUT); //Initialise easy driver output

//START OF FOCUS CONTROL SETUP

//END OF FOCUS CONTROL SETUP

Serial.begin(19200);// start the serial

myHalfStepper.setSpeed(SPEED);

NoOfSteps=1000;

pinMode(13,OUTPUT);

pinMode(powerPin,OUTPUT); //Easydriver Sleep mode or power off

digitalWrite(powerPin, HIGH); //Easydriver Pwer off (high = powered down)

}

void loop() {

int switchvalue =digitalRead(SWITCHpin);

if (switchvalue==LOW)

{

powerPin=5;//set powerPin to stepper 1

dirPin=6;//set dirPin to stepper 1

stepperPin=7;//set stepperPin to stepper 1

digitalWrite(10,HIGH);//set to high to disable stepper 2 12v power.

delay (100);

digitalWrite(LED1pin,HIGH);//stepper 1 LED on

digitalWrite(LED2pin,LOW);//stepper 2 LED off

}

else

{

powerPin=10;//set powerPin to stepper 2

dirPin=12;//set dirPin to stepper 2

stepperPin=11;//set stepperPin to stepper 2

digitalWrite(5,HIGH);//set to high to disable stepper 1 12v power.

digitalWrite(LED1pin,LOW);//stepper 1 LED off

digitalWrite(LED2pin,HIGH);//stepper 2 LED on

}

int bCommandReady = false;

//FocuserControl Power off command

if (millis() > (powerMillis + 20000)) // check if power has been on for more than 20 seconds

{

digitalWrite(powerPin, HIGH); // if yes, then disable power

}

//If There is information in the Serial buffer read it in and start the Build command subroutine

if (usingSerial && Serial.available() >= 1) {

// read the incoming byte:

incomingByte = Serial.read();

delay(5);

if (incomingByte == '#') {

/* Build a new command. */

bCommandReady = cliBuildCommand(incomingByte);

}

}

else

{

incomingByte=0;

//Serial.flush();

}

//If there is a command in the buffer then run the process command subroutine

if (bCommandReady == true) {

bCommandReady = false; // reset the command ready flag

cliProcessCommand(); // run the command

}

if ((Position != configuration.parkposition)) {

configuration.parked = 0;

EEPROM_writeAnything(0, configuration);

}

if (UPDATE){

UPDATE=false;

SerialDATAFun(); // Used to send the current state of the focuser to the PC over serial comms

}

}

//***************************************************

//*****Start of User defined Functions **************

//***************************************************

//START OF FOCUS CONTROL FUNCTIONS

void EasyDriverStep(boolean dir,long steps){

digitalWrite(powerPin, LOW); // enable power to the EasyDriver

powerMillis = millis(); // remember when power was switched on

delayMicroseconds(10); // wait a bit after switching on power

digitalWrite(dirPin,dir);

delay(100);

for(int i=0;i<steps;i++){

digitalWrite(stepperPin, HIGH);

delayMicroseconds(SPEED);

digitalWrite(stepperPin, LOW);

delayMicroseconds(SPEED);

}

}

void ParkFocuserFun (void) {//Park the focuser by setting the Park bit to 1 and the current Focuser Position in Configuration

if (configuration.parked == false){

configuration.parkposition = Position;

configuration.stepperdirection = Direction;

configuration.parked = true;

configuration.controlboardtype = BoardType;

EEPROM_writeAnything(0, configuration);

}

UPDATE=true; //Update even if the focuser was already parked

}

void FocusINFun (void) {//Move the Stepper IN.

long Steps = 0;

if (Absolute == false) { //If not Absolute move the number of steps

if ((Position-NoOfSteps)>=0) {

switch (BoardType) {

case 0:

EasyDriverStep(Direction,NoOfSteps);

break;

case 1:

digitalWrite(13,HIGH); myHalfStepper.step (NoOfSteps); digitalWrite(13,LOW);

break;

case 2:

motor.step(NoOfSteps, FORWARD, MICROSTEP); motor.release();

break;

default:

// if nothing else matches, do the default

// default is optional

break;

}

Position=Position-NoOfSteps;

}

}

else if (NoOfSteps < MaxStep) //Absolute :- work out the number of steps to take based on current position

{

if (NoOfSteps<Position){

Steps=(Position-NoOfSteps);

switch (BoardType) {

case 0:

EasyDriverStep(Direction,Steps);

break;

case 1:

digitalWrite(13,HIGH); myHalfStepper.step (Steps); digitalWrite(13,LOW);

break;

case 2:

motor.step(Steps, FORWARD, MICROSTEP); motor.release();

break;

default:

// if nothing else matches, do the default

// default is optional

break;

}

Position=NoOfSteps;

}

else

{

Steps=(NoOfSteps-Position);

switch (BoardType) {

case 0:

EasyDriverStep(!Direction,Steps);

break;

case 1:

digitalWrite(13,HIGH); myHalfStepper.step (-Steps); digitalWrite(13,LOW);

break;

case 2:

motor.step(Steps, BACKWARD, MICROSTEP); motor.release();

break;

default:

break;

}

Position=NoOfSteps;

}

}

// set the update flag so that the new position is displayed

IsMoving=true;

UPDATE=true;

}

void FocusOUTFun (void) {//Move the Stepper OUT.

long Steps = 0;

if (Absolute == false) { //If not Absolute move the number of steps

if ((Position+NoOfSteps)<=MaxStep) {

switch (BoardType) {

case 0:

EasyDriverStep(!Direction,NoOfSteps);

break;

case 1:

digitalWrite(13,HIGH); myHalfStepper.step (-NoOfSteps); digitalWrite(13,LOW);

break;

case 2:

motor.step(NoOfSteps, BACKWARD, MICROSTEP); motor.release();

break;

default:

// if nothing else matches, do the default

// default is optional

break;

}

Position=Position+NoOfSteps;

}

}

else if (NoOfSteps < MaxStep) //Absolute :- work out the number of steps to take based on current position

{

if (NoOfSteps>Position){

Steps=(NoOfSteps-Position);

switch (BoardType) {

case 0:

EasyDriverStep(!Direction,Steps);

break;

case 1:

digitalWrite(13,HIGH); myHalfStepper.step (-Steps); digitalWrite(13,LOW);

break;

case 2:

motor.step(Steps, BACKWARD, MICROSTEP); motor.release();

break;

default:

// if nothing else matches, do the default

// default is optional

break;

}

Position=NoOfSteps;

}

else

{

Steps=(Position-NoOfSteps);

switch (BoardType) {

case 0:

EasyDriverStep(Direction,Steps);

break;

case 1:

digitalWrite(13,HIGH); myHalfStepper.step (Steps); digitalWrite(13,LOW);

break;

case 2:

motor.step(Steps, FORWARD, MICROSTEP); motor.release();

break;

default:

// if nothing else matches, do the default

// default is optional

break;

}

Position=NoOfSteps;

}

}

// set the update flag so that the new position is displayed

IsMoving=true;

UPDATE=true;

}

void FocusSTEPSFun (void) {//Set the number of Steps.

NoOfSteps = gParamValue;

// set the update flag so that the new position is displayed

UPDATE=true;

}

// function to set the RPM of the stepper motor

// user sends :speed:500:

void FocusSPEEDFun (void) {

myHalfStepper.setSpeed(gParamValue); // Set the stepper objects speed.

SPEED = gParamValue;

UPDATE=true;

}

// Set max limit for focus travel, for absolute positioning focusers

void FocusSLimitFun (void) {

MaxStep = gParamValue;

UPDATE=true;

}

// set current focuser position, used for calibrating absolute positioning focusers

void FocusSPositionFun (void) {

Position = gParamValue;

UPDATE=true;

}

// set the focuser mode to relative 0 or absolute positioning 1

void FocusSModeFun (void) {

switch (gParamValue){

case 0:

Absolute=false;

//Serial.println("Relative Mode"); // debug only

break;

case 1:

Absolute=true;

//Serial.println("Absolute Mode"); // debug only

break;

default:

//Serial.println("0 or 1 for relative or absolute, try again"); // debug only

break;

}

UPDATE=true;

}

// to add different motor types, stepper, servo or DC

void FocusSTypeFun(void){

MotorType=gParamValue;

UPDATE=true;

}

// to add different motor types, stepper, servo or DC

void FocusBoardTypeFun(void){

BoardType=gParamValue;

UPDATE=true;

}

//END OF FOCUS CONTROL FUNCTIONS

//Start of serial control functions

void SerialDATAFun (void) {//Update All information over comms if there has been any change in the state of the focuser

Serial.print("#POS:");

Serial.print(Position);

Serial.println(";");

Serial.print("#STP:" );

Serial.print(NoOfSteps);

Serial.println(";");

Serial.print("#MDE:");

if (Absolute){

Serial.print("1");

}

else{

Serial.print("0");

}

Serial.println(";");

Serial.print("#LMT:");

Serial.print(MaxStep);

Serial.println(";");

Serial.print("#SPD:");

if (SPEED==0){

Serial.print(char(SPEED));

}

else{

Serial.print(SPEED);

}

Serial.println(";");

if (IsMoving==true) {

Serial.print("#MOV:");

Serial.print("1");

Serial.println(";");

IsMoving=false;

}

Serial.print("#BRD:0");

Serial.print(BoardType);

Serial.println(";");

Serial.print("#PRK:");

if (configuration.parked == 1) Serial.print("01"); else Serial.print("00");

Serial.println(";");

}

//Process Command. This searches the command table to see if the command exits if it does then the required subroutine is run

void cliProcessCommand(void)

{

int bCommandFound = false;

int idx;

/* Convert the parameter to an integer value.

* If the parameter is emplty, gParamValue becomes 0. */

gParamValue = strtol(gParamBuffer, NULL, 0);

/* Search for the command in the command table until it is found or

* the end of the table is reached. If the command is found, break

* out of the loop. */

for (idx = 0; gCommandTable[idx].name != NULL; idx++) {

if (strcmp(gCommandTable[idx].name, gCommandBuffer) == 0) {

bCommandFound = true;

break;

}

}

/* If the command was found, call the command function. Otherwise,

* output an error message. */

if (bCommandFound == true) {

(*gCommandTable[idx].function)();

}

}

//When data is in the Serial buffer this subroutine is run and the information put into a command buffer.

// The character : is used to define the end of a Command string and the start of the parameter string

// The character ; is used to define the end of the Parameter string

int cliBuildCommand(char nextChar) {

static uint8_t idx = 0; //index for command buffer

static uint8_t idx2 = 0; //index for parameter buffer

int loopchk = 0;

nextChar = Serial.read();

do

{

gCommandBuffer[idx] = TO_UPPER(nextChar);

idx++;

nextChar = Serial.read();

loopchk=loopchk+1;

}

while ((nextChar != ':') && (loopchk < 100));

loopchk=0;

nextChar = Serial.read();

do

{

gParamBuffer[idx2] = nextChar;

idx2++;

nextChar = Serial.read();

}

while ((nextChar != ';')&& (idx2 < 100));

gCommandBuffer[idx] = '\0';

gParamBuffer[idx2] = '\0';

idx = 0;

idx2 = 0;

return true;

}

//END of serial control functions

I dont have it fitted to the scope yet, I still have to make some brackets.

It all works on the bench tho.

Jason.

Link to comment
Share on other sites

Gina,

What are you going to use to power the Arduino? I have just built a controller recently and found that if you are going to use the 'Enable' pin on the stepper driver you will need at least 6v into the Arduino Nano, the USB alone will not be enough to provide enough power to the digital when 'high' connected to enable on the stepper. (well that what I found)

My Duemilanove on the other hand, was happy with just the usb.

Steve

Link to comment
Share on other sites

Gina,

What are you going to use to power the Arduino? I have just built a controller recently and found that if you are going to use the 'Enable' pin on the stepper driver you will need at least 6v into the Arduino Nano, the USB alone will not be enough to provide enough power to the digital when 'high' connected to enable on the stepper. (well that what I found)

My Duemilanove on the other hand, was happy with just the usb.

Steve

I have +12v available and also +8v which powers the 1100D DSLR I use as electronic finder. The latter might be better to cut down the regulator dissipation in the Arduino.
Link to comment
Share on other sites

No problem Gina, glad to help :smiley: As you have done for me, and many others on more than one ocasion :icon_salut: .

I have only used this setup on the bench, but as you can see in the sketch I am using the enable pin on each easy stepper. I only have the usb powering the Nano but I have not had any issues with powering the enable pins. I do have 9v feeding the Mega in my hub, so I might tap into that if any issues come up.

Jason.

Link to comment
Share on other sites

Gina,

I would be gratefull if you could give the Ascom driver and code a go from the SGL automation yahoo site (see my signature). I haven´t had much time to improve it over the last year so it would be good to have someone new have a play.

It´s basically the code JAS posted.

The code has a comms routine which works over serial for example #TAM:00; gets the Ambient Temperature from the cloud sensor or in the case of the focuser #IN1:200; sends the command to move the focuser IN 200 steps or in the case of absolute TO position 200.

If you need local control you could add some buttons to the Arduino or use an LED with built in buttons (I have one of these but gave up using it as I just use Ascom).

It works very well when you get it setup but there are still a few bugs kicking around. (needs backlash compensation, the VisualStudio VB user parameters keep reseting, park has never worked properly....which has annoyed the heck out of me)

The Ascom driver is written in VisualBasic 2010 express, I keep meaning to move it to 2012 and see what improvements MS have made. I also plan....one day...to do a C version.

The Ascom driver just copies info between the Arduino and the Ascom layer. It really is not at all complicated.

It would be great if you have any other code examples you wouldn´t mind posting there. I´m trying to get as many examples and free code as possible so people can use what they want.

Thanks!

Neil C

Link to comment
Share on other sites

Hi Neil

So you're the author of the code for all this - that's great :) I'll join the Yahoo group and have a look. I'll be interested in the coding and I might possibly be able to make some suggestions. Programming was part of my career and I do have some experience, it's just that I'm getting "a bit long in the tooth" now.

Link to comment
Share on other sites

I've joined the yahoo group :) Bit of bother - it didn't recognise my yahoo ID although I'm currently using it for other groups. So I created a new one - ginafromdevon.

Link to comment
Share on other sites

Hi Neil

So you're the author of the code for all this - that's great :) I'll join the Yahoo group and have a look. I'll be interested in the coding and I might possibly be able to make some suggestions. Programming was part of my career and I do have some experience, it's just that I'm getting "a bit long in the tooth" now.

I do industrial automation which uses ladder, grafcet, sfc, structured text. Problem is i only know a bit about c, vb etc from uni and bodging stuff when i have to communicate to sql. So well enough to know what i should be doing and then ignore it.

There have been a few people helping with the code, mainly when they need a focuser, so its not just my work :D

Link to comment
Share on other sites

To keep things tidy I have decided to put all my control devices and power distribution in one box. This will contain 2 Arduinos one for focuser control and the other for dew heater control. The drivers for the stepper motors and dew heaters power control will also be in the box. Finally another circuit board will carry the voltage regulator components to provide 8v for my 1100D finder (and Peltier cooled 1100D imaging camera if used).

post-13131-0-56398600-1361316078_thumb.p

Link to comment
Share on other sites

To keep things tidy I have decided to put all my control devices and power distribution in one box. This will contain 2 Arduinos one for focuser control and the other for dew heater control. The drivers for the stepper motors and dew heaters power control will also be in the box. Finally another circuit board will carry the voltage regulator components to provide 8v for my 1100D finder (and Peltier cooled 1100D imaging camera if used).

post-13131-0-56398600-1361316078_thumb.p

I'm doing something similar, but I'm going about it in a very different way. Our plans match up to the "two-Arduinos-in-one-box" point, but I've written/hacked my own code for both Arduinos, I'm not using ASCOM (I have nothing against ASCOM, but I wanted to learn how to use Arduinos - I didn't want to/know how to adapt the SGL code for all the other things I want an Arduino to do, and I felt that two pins was a serious underuse of the Arduino. But I don't discourage anyone from using the SGL setup, which was after all my introduction to stepper motor control - thanks Neil and all others who've commented, added and modded) as well as my own desktop application code - I wanted a small desktop footprint, as I use a 10" netbook and have other things running. This sounds all good so far, but I have very little experience of coding ... I played around with BBC Basic in the 80s, one or two other BASIC dialects since then, and very little else (well, I did write an animated fractal prog in BBC Basic a few years back, so maybe I know more than I think I do). So I've had to refresh what I knew, learn new BBC Basic (I use BBC Basic for Windows - it's basic but it does what I want it to do) and learn a bit of C++. After a few months, and thanks to the huge and helpful Arduino community and the principle of open source software, I have a pretty good handle on managing serial data for commands and sensors (I've done little astronomy this winter due to clouds and some medical stuff I'm going through, but I've done lots of geekery) so I'm happy to say I must have learned a lot.

At the moment my main imaging camera is a Nikon D3000 dSLR. Not the greatest, but not too bad. To trip the shutter I got a cheap IR remote (less than £3 on eBay) and hacked the circuit so that it's closed by a relay, and mounted the IR LED in a small case which can be stuck on to the end of the 'scope near the camera. So the PC can deal with exposure times too.

One thing I've found is that it's cheaper to buy ATMega chips than it is to buy Arduinos or clones. It's hard to make an Arduino as small as a Nano, so if size is an issue then that may be the route to go, but for testing and breadboard purposes, I find it handy to have a few chips about. Other than the chip, it takes just a few small components to make a working Arduino. It does require a UART device to connect to USB - basically a CP2102 chip - and a 5v regulator.

A trick I discovered - I hope someone more knowledgeable than me will please tell me if I'm doing something stupid! - is to split the serial input and output lines from the UART between two chips, so that one chip deals with PC output, all the commands and settings - motor, relays, etc - while the other deals with sending data from sensors - temp, humidity, light, etc., to the PC. Both can have their own LCD displays, if need be (I quite like LCD displays, and it's good to know what the Arduinos think is going on! I'm sure I've confused them as often as they've confused me). This trick was born more of necessity than design, as my PC doesn't recognise more than one at a time of the UART devices I'm using, so the whole thing gets run by one USB lead. Given that the whole rig makes fairly full use of all onboard USB ports as well as a 10-port hub, this is a useful economy. It's also possible to use the command chip to trigger the sensor chip.

It's all still at prototype stage and needs much work, but I'll pop up a pic or two if you're interested.

Link to comment
Share on other sites

Thank you for that :) In fact I plan to get the focussing part running just from my netbook to start with then add ASCOM control later. I too like to develop my own code so that I know exactly how it all works, while taking examples from other people's code. I also like to add copious comments so that I can pick up later and understand what's going on. I find object orientation with nicely modular code helps with fault finding and testing. Several of the code modules can be ported directly from one project to another. I expect some would consider this to be overkill for a simple little thing like the Arduino but it's amazing how complicated a sketch can become when dealing with multiple sensors and output devices.

Link to comment
Share on other sites

Thank you for that :) In fact I plan to get the focussing part running just from my netbook to start with then add ASCOM control later. I too like to develop my own code so that I know exactly how it all works, while taking examples from other people's code. I also like to add copious comments so that I can pick up later and understand what's going on. I find object orientation with nicely modular code helps with fault finding and testing. Several of the code modules can be ported directly from one project to another. I expect some would consider this to be overkill for a simple little thing like the Arduino but it's amazing how complicated a sketch can become when dealing with multiple sensors and output devices.

I was trying to keep the software structured and was hoping people would help improve it....sadly most people aren't interested in, or able to, improve it...so it is what it is.

The Arduino code was designed so that all instructions follow the same syntax over serial comms as i thought it would allow anyone to build their own front end...but no-one has. :(

But i know it's helped a couple of people who have no programming ability so i'll keep plugging away. The best tinkerers seem to be on sgl anyway!

Just rebuilding my dev computer to see if visual studio 2012 works better with user parameters and ascom.

I Look forward to seeing your efforts :D

Link to comment
Share on other sites

I was trying to keep the software structured and was hoping people would help improve it....sadly most people aren't interested in, or able to, improve it...so it is what it is.

The Arduino code was designed so that all instructions follow the same syntax over serial comms as i thought it would allow anyone to build their own front end...but no-one has. :(

But i know it's helped a couple of people who have no programming ability so i'll keep plugging away. The best tinkerers seem to be on sgl anyway!

Just rebuilding my dev computer to see if visual studio 2012 works better with user parameters and ascom.

I Look forward to seeing your efforts :D

I'm hoping I can contribute to the project as I have programing experience but at present I have very little time and unfortunately other things are having to take priority over astro projects (except for actual imaging - I make time for that :D ) Actually, I'm dying to get onto this - it's very interesting.

I've just been looking into Visual Studio - looks like it costs half a grand! :eek: In which case I shall have to find something else. Maybe a multi-platform GPU licensed IDE such as Python which I used to develop my weather station software. I was running that under Linux but I believe it can be ported to Windows.

Link to comment
Share on other sites

Had a bit of time today to progress this project a little bit. I've connected the stepper motor I'm going to use for the ED80 focuser via the ULN2003A driver board to the Arduino Nano. I've used the stepper sketch from the Arduino website to check things out. This uses a pot connected to an analogue input to provide the control. This provides a voltage of 0v to 5v to the input and the sketch reads this. Around mid-way the control is off but either side it drives the stepper with increasing frequency pulses the further from mid-point the pot is turned. This is working fine :) I'm running the 5v power for the ULN2003A and stepper from the 5v Arduino pin which in turn is derived from the USB. This is quite sufficient to drive the stepper motor I'm using.

This was a test but thinking about it, this would provide a perfectly adequate control until I get the full computer control sorted out. I can have the pot in a box beside the computer in the warm room fed from 5v. The currently installed wires through the cable trunking to the DC motor focuser can carry this signal to the Arduino. This would provide a similar remote focussing control to my present DC system.

Link to comment
Share on other sites


/* Stepper Unipolar Advanced
* -------------------------
*
* Program to drive a stepper motor coming from a 5'25 disk drive
*
* --- snip ---
*
* @author: David Cuartielles
* @date: 20 Oct. 2005
*/
int motorPins[] = {2, 3, 4, 5};
int count = 0;
int count2 = 0;
int delayTime = 500;
int val = 0;
void setup() {
for (count = 0; count < 4; count++) {
pinMode(motorPins[count], OUTPUT);
}
}
void moveForward() {
if ((count2 == 0) || (count2 == 1)) {
count2 = 16;
}
count2>>=1;
for (count = 3; count >= 0; count--) {
digitalWrite(motorPins[count], count2>>count&0x01);
}
delay(delayTime);
}
void moveBackward() {
if ((count2 == 0) || (count2 == 1)) {
count2 = 16;
}
count2>>=1;
for (count = 3; count >= 0; count--) {
digitalWrite(motorPins[3 - count], count2>>count&0x01);
}
delay(delayTime);
}
void loop() {
val = analogRead(0);
if (val > 540) {
// move faster the higher the value from the potentiometer
delayTime = 2048 - 1024 * val / 512 + 1;
moveForward();
} else if (val < 480) {
// move faster the lower the value from the potentiometer
delayTime = 1024 * val / 512 + 1;
moveBackward();
} else {
delayTime = 1024;
}
}
Link to comment
Share on other sites

Here is the circuit diagram of the Arduino and Stepper Drivers. At the top are two 5 pin sockets for connecting the stepper motors. At the bottom we have two voltage control lines - one for each focus motor. The voltage control will be variable from 0 to +5v. At +2.5v the stepper motors would be off and either side would rotate either one way or the other with the speed dependent on the difference between 2.5v and the control voltage. These voltages would be provided by a pair of pots in a box in the warm room.

post-13131-0-35432200-1361911565_thumb.p post-13131-0-95527600-1361911583_thumb.p

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.