以åã«è£½ä½ãããLX200ã®Motor Focuser ã³ã³ããã¼ã© ã®ã½ããæ¹ä¿®ãè¡ã£ããããã¤ããããã主ãªå¤æ´ç¹ã¯ãMotor Focuser ãåããã¦ãããä¸å®æéçµã¤ã¨ãé§åãã¦ããã¹ãããã³ã°MOTORã®é»æºOFFã«ãããã¨ã
MOTOR Focuser ã¯ãã®ããã«ãæé é¡ã®ãã³ããããã¹ãããã³ã°ã¢ã¼ã¿ã¼ã§åãã¦ããã®ã ããéæ¢ãã¦ããæéãå§åçã«é·ãã®ã§ããã®ééé»ãã¦ããã®ã¯ããã¾ãæ°æã¡ã®ãããã®ã§ã¯ãªããã¢ã¼ã¿ã¼ããã©ã¤ãåºæ¿ãããªãç±ãæã¤ããªã®ã§ãSSRã§ã¢ã¼ã¿ã¼åè·¯ãé§ååºæ¿ã®é»æºãã³ã³ããã¼ã«ã§ããããã«ããã
ä¾ã«ãã£ã¦ããã®ãããªãã®ãå¿
è¦ãªäººã¯éããã¦ããã¨æããããã¼ãã»ã½ãããè¨ãã¦ããã
ãã¼ãã¯ãä¸ã®å³ã®ã¨ããã§ããã¤ã¯ãã³ã³ããã¼ã©ã¯ãArduino ï½ï½ï½ï½ ã®äºæåãã¢ã¼ã¿ã¼ãã©ã¤ãåºæ¿ã¯ãAï½ï½ï½
ï½ï½ï½ ã§è³¼å
¥ããã¢ã¸ã¥ã¼ã«ã使ã£ã¦ãããã¡ãªã¿ã«ãã¹ãããã³ã°ã¢ã¼ã¿ã¼ã¯ãç§æã®ã®ã¢ä»ã®ãã®ã
Aï½ï½ï½ï½ï½ï½ï½ ã®ã¹ã±ããï¼ããã°ã©ã ï¼ã¯ä»¥ä¸ã®ã¨ããã
ç°¡åã«è§£èª¬ããã¨ã
ã»void setup()
ãIOãã¼ããªã©ã®å²ä»ãåæè¨å®ãè¡ããã¢ã¼ã¿ã¼ãã¸ã·ã§ã³ãEEPROï¼ããèªè¾¼ã
ã»void MotorForward()
ãã¹ãããã³ã°ã¢ã¼ã¿ã¼ã®é æ¹åãã«ã¹ãçºçããããã¸ã·ã§ã³ãæ´æ°ããã
ã»void MotorReverse()
ãã¹ãããã³ã°ã¢ã¼ã¿ã¼ã®éæ¹åãã«ã¹ãçºçããããã¸ã·ã§ã³ãæ´æ°ããã
ã»void MotorON()
ãã¢ã¼ã¿ã¼é»æºãONã«ããã
ã»void SetFocusPosition()
ãã¢ã¼ã¿ã¼ãã¸ã·ã§ã³ãEEPROï¼ã«æ¸ãè¾¼ã¿ãã·ãªã¢ã«ãã¼ãï¼ï¼°ï¼£ï¼ã«åºåããã
ãç¾å¨æå»ï¼ã¢ã¼ã¿ã¼ãæå¾ã«ï¼¯ï¼®ã¨ãªã£ãæå»ã¨ãªãï¼ãèªã¿è¾¼ãã
ã»void loop()
ãã¡ã¤ã³ããã°ã©ã æ¬ä½ã
ãã·ãªã¢ã«ãã¼ããèªãã§ãï¼°ï¼£ããã®ã³ãã³ãã解æãã¦ãã¢ã¼ã¿ã¼ãåããã
ãç¾å¨æå»ãèªãã§ãä¸å®æéï¼ï¼åï¼ä»¥ä¸çµéããããã¢ã¼ã¿ã¼é»æºãOFFã«ããã
ãï½ï½ï½ï½ï½ï½ï¼ï¼ ã¯ãAï½ï½ï½ï½ï½ï½ ãèµ·åãã¦ããã®çµéæéï¼ï½ï½ï½
ï½ï¼ãä¸ããé¢æ°ã§ããã
********************************
// ã¢ã¼ã¿FOCUSER ãã©ã¤ãã¼ã
//ã2015.09.01ãVer.1.0
// For Arduino NANO + PC
#include<EEPROM.h>
// I/Oãã¼ãå®ç¾©
#define LED 13 // D13 åºæ¿ä¸LED
#define SSR 2 // D2 Output Motor Power
#define SLEEP 21 // A7(D21) Output
#define MS1 20 // A6(D20) Output
#define MS2 16 // A2(D16) Output
#define Step 15 // A1(D15) Output
#define Direction 14 // A0(D14) Output
#define Rate 10 // Step Motor Pulse Rate( msec )
//å¤æ°ã®å®ç¾©
byte ReadCMD;
unsigned char FocusPositionH,FocusPositionL;
unsigned int FocusPosition;
long TimeNow,PrevMotorON;
//ãåæè¨å®
void setup()
{ // IO Port Setting
pinMode(LED, OUTPUT);
pinMode(SSR,OUTPUT);
pinMode(SLEEP,OUTPUT);
pinMode(MS1,OUTPUT);
pinMode(MS2,OUTPUT);
pinMode(Step,OUTPUT);
pinMode(Direction,OUTPUT);
// Serial Port Setting
Serial.begin(9600);
// Microstep Driver Setting
digitalWrite(MS1, LOW); // Full Step Mode
digitalWrite(MS2, LOW);
digitalWrite(SLEEP, HIGH); // Sleep OFF
digitalWrite(Step, LOW); // Step OFF
// Set Motor Power OFF
digitalWrite(SSR, HIGH); // Motor Power ON
// Read Focus Position from EEPROM
FocusPosition = EEPROM.read(30);
FocusPositionL = EEPROM.read(31);
FocusPosition = FocusPosition << 8;
FocusPosition = FocusPosition + FocusPositionL;
PrevMotorON = millis(); // Motor Timer Reset
}
void MotorForward()
{ // Rotate Motor 1 Step Forward
digitalWrite(Direction,HIGH);
digitalWrite(Step, HIGH);
delay(Rate);
digitalWrite(Step, LOW);
delay(Rate);
++FocusPosition; // Up Position Counter
}
void MotorReverse()
{ // Rotate Motor 1 Step Reverse
digitalWrite(Direction,LOW);
digitalWrite(Step, HIGH);
delay(Rate);
digitalWrite(Step, LOW);
delay(Rate);
--FocusPosition; // Down Position Counter
}
void MotorON()
{ // Motor Power ON
digitalWrite(SSR, HIGH);
delay(50); // Wait 50msec
}
void SetFocusPosition()
{ // Write Focus Position to EEPROM
FocusPositionH = highByte(FocusPosition);
FocusPositionL = lowByte(FocusPosition);
EEPROM.write(30,FocusPositionH);
EEPROM.write(31,FocusPositionL);
Serial.println( FocusPosition,DEC);
PrevMotorON = millis(); // Read Time
}
void loop()
{
ReadCMD = Serial.read(); // Read Command from PC
// ï¼°ï¼£ããã®ã³ãã³ã解æ
switch ( ReadCMD ){
case 0x31: // "1" Forward One Step
MotorON();
MotorForward();
SetFocusPosition();
break;
case 0x32: // "2" Forward 10 Step
MotorON();
for ( int i=1; i<=10 ;i++ ) MotorForward();
SetFocusPosition();
break;
case 0x33: // "3" Forward 100 Step
MotorON();
for ( int i=1; i<=100 ;i++ ) MotorForward();
SetFocusPosition();
break;
case 0x34: // "4" Reverse One Step
MotorON();
MotorReverse();
SetFocusPosition();
break;
case 0x35: // "5" Reverse 10 Step
MotorON();
for ( int i=1; i<=10 ;i++ ) MotorReverse();
SetFocusPosition();
break;
case 0x36: // "6" Reverse 100 Step
MotorON();
for ( int i=1; i<=100 ;i++ ) MotorReverse();
SetFocusPosition();
break;
case 0x30: // "0" Focus Position Send
Serial.println( FocusPosition,DEC);
break;
case 0x2A: // "*" Focus Position Reset
FocusPosition = 30000;
SetFocusPosition();
break;
default: // No Command Recieved
Serial.flush(); // Flush serial RX Buffer
}
// æå¾ã® Motor ON ããä¸å®æéçµéããã Motor OFF ã«ãã
TimeNow = millis(); // Read Time
if ( ( TimeNow - PrevMotorON ) > 300000 ) digitalWrite(SSR, LOW); // Motor OFF
}