I guess this is the right section after all.
I needed a way to get an astro CCD camera sequenced with a stepper motor driven mechanism, which controls an equatorial mount hand controller, sequentially repositioning the RA and DEC axii between exposures to dither the images. A box shaped spiral was the best pattern for my purposes.
The stepper mecnanism was originally sequenced with a DSLR on the same mount. The CCD camera replaces the DSLR and is still under warranty, so soldering wires here and there is not an option. The mount is quite old, manual, but very accurate.
On the camera side, I used a Freetronics TEMT6000 light sensor break out board, connected to an analog pin to read the camera operation LED, which indicates whether the camera is exposing or not (doing other things).
On the mount side, I use a bipolar stepper, driven by an L293NE, on a home made arduino shield, to push the hand controller buttons between exposures.
The LED is either off, on or flashing. To differentiate flashing from on and off, I tied a capacitor between the sensor output and GND, which restricted the minimum and maximum values, sampling a mid range.
The code might be helpful to understand the concept fuller - though I warn you, it is very amateurish.
#include <Stepper.h>
/* This sketch activates a stepper motor/roller arm which
presses 4 buttons, RA and DEC, on a German Equatorial Mount
hand controller. The buttons are pressed in sequence between image
exposures by reading the camera operational state LED, using
a TEMT6000 light sensor.
Exposing, LED ON/OFF, 500ms. Not exposing LED ON.
No operation LED OFF.
Sensor trigger values derived experimentally - 22uf capacitor
across GND and sensor OUT to 'average' exposing value with LED
flashing.
*/
#define pin2 2
#define pin3 3
int frames = 0;
int pinval2;
int pinval3;
int steps;
int sensorPin = A1;
int sensor;
int exposure = 0;
bool exposing;
/* motor parameters */
#define motorSteps 200
#define motorspeed 5
#define motorPin1 4
#define motorPin2 5
#define motorPin3 6
#define motorPin4 7
Stepper stepper(motorSteps, motorPin1,motorPin2,motorPin3,motorPin4);
/* dither pattern steps */
#define steps0 50
#define steps1 50
#define steps2 -50
#define steps3 50
#define steps4 50
#define steps5 -50
#define steps6 50
#define steps7 50
#define steps8 -50
#define steps9 50
#define steps10 -50
#define steps11 50
#define steps12 50
#define steps13 -50
#define steps14 50
#define steps15 -50
#define steps16 50
#define steps17 50
#define steps18 -50
#define steps19 50
#define steps20 -50
#define steps21 50
#define steps22 -50
#define steps23 50
#define steps24 50
#define steps25 -50
#define steps26 50
#define steps27 -50
#define steps28 50
#define steps29 -50
#define steps30 50
#define steps31 50
#define steps32 -50
#define steps33 50
#define steps34 -50
#define steps35 50
#define steps36 -50
#define steps37 50
#define steps38 -50
#define steps39 50
void setup(void) {
// declare sensor INPUT
pinMode(sensorPin,INPUT);
// hardware switch - set as input
pinMode(pin2, INPUT);
pinMode(pin3, INPUT);
// pull-up resistors
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
Serial.begin(9600);
}
void dither() {
// read the light sensor
sensor = analogRead(sensorPin);
delay(250);
Serial.println(sensor);
if(sensor > 1 && sensor < 235){
exposing == true;
exposure = 1;
if (exposing == true) {
pause();
}
}
// dither during image download
if(exposure > 0 && sensor > 235) {
exposing = false;
if(exposing == false) {
exposure = 0;
frames++;
//Serial.println(frames);
if (frames == 1)
steps = steps0;
if (frames == 2)
steps = steps1;
if (frames == 3)
steps = steps2;
if (frames == 4)
steps = steps3;
if (frames == 5)
steps = steps4;
if (frames == 6)
steps = steps5;
if (frames == 7)
steps = steps6;
if (frames == 8)
steps = steps7;
if (frames == 9)
steps = steps8;
if (frames == 10)
steps = steps9;
if (frames == 11)
steps = steps10;
if (frames == 12)
steps = steps11;
if (frames == 13)
steps = steps12;
if (frames == 14)
steps = steps13;
if (frames == 15)
steps = steps14;
if (frames == 16)
steps = steps15;
if (frames == 17)
steps = steps16;
if (frames == 18)
steps = steps17;
if (frames == 19)
steps = steps18;
if (frames == 20)
steps = steps19;
if (frames == 21)
steps = steps20;
if (frames == 22)
steps = steps21;
if (frames == 23)
steps = steps22;
if (frames == 24)
steps = steps23;
if (frames == 25)
steps = steps24;
if (frames == 26)
steps = steps25;
if (frames == 27)
steps = steps26;
if (frames == 28)
steps = steps27;
if (frames == 29)
steps = steps28;
if (frames == 30)
steps = steps29;
if (frames == 31)
steps = steps30;
if (frames == 32)
steps = steps31;
if (frames == 33)
steps = steps32;
if (frames == 34)
steps = steps33;
if (frames == 35)
steps = steps34;
if (frames == 36)
steps = steps35;
if (frames == 37)
steps = steps36;
if (frames == 38)
steps = steps37;
if (frames == 39)
steps = steps38;
if (frames == 40)
steps = steps39;
// run stepper
stepper.setSpeed(motorspeed);
stepper.step(steps);
}
}
}
/* pause */
void pause() {
stepper.setSpeed(0);
stepper.step(0);
}
void loop() {
/* switch pause */
pinval2 = digitalRead(pin2);
pinval3 = digitalRead(pin3);
while (pinval2 == HIGH && pinval3 == LOW) {
pause();
break;
}
/* sense camera operation - read LED - wait for
integration then dither*/
pinval2 = digitalRead(pin2);
pinval3 = digitalRead(pin3);
if (pinval2 == HIGH && pinval3 == HIGH) {
dither();
}
}