Line 25... |
Line 25... |
25 |
#define light0 0x44 // A0 = L (I2C light0) |
25 |
#define light0 0x44 // A0 = L (I2C light0) |
26 |
#define light1 0x45 // A0 = H (I2C light1) |
26 |
#define light1 0x45 // A0 = H (I2C light1) |
27 |
|
27 |
|
28 |
int lights[] = {light0, light1}; |
28 |
int lights[] = {light0, light1}; |
29 |
|
29 |
|
30 |
#define LAMP1 13 // Callibration Lamp 1 |
30 |
//#define LAMP1 13 // Callibration Lamp 1 |
31 |
#define LAMP2 6 // Callibration Lamp 2 |
31 |
//#define LAMP2 6 // Callibration Lamp 2 |
32 |
|
32 |
|
33 |
int lamps[] = {LAMP1, LAMP2}; |
- |
|
34 |
|
33 |
|
35 |
#define FW1 7 // [PD7 - red] Slit Wheel 1-st from light |
34 |
#define FW1 7 // [PD7 - red] Slit Wheel 1-st from light |
36 |
#define FW2 8 // [PB0 - yellow] Grism Wheel 2-nd from light |
35 |
#define FW2 8 // [PB0 - yellow] Grism Wheel 2-nd from light |
37 |
#define FW3 3 // [PD3 - blue] Filter Wheel 3-rd from light |
36 |
#define FW3 3 // [PD3 - blue] Filter Wheel 3-rd from light |
38 |
|
37 |
|
39 |
int filters[] = {FW1, FW2, FW3}; |
38 |
int filters[] = {FW1, FW2, FW3}; |
40 |
|
39 |
|
41 |
const int steps = 3500; // change this to fit the number of steps |
40 |
const int STEPS = 3500; // change this to fit the number of steps |
42 |
const int sspeed = 10; // max. 15 // stepper motor speed |
41 |
const int SSPEED = 8000; // max. 15 // stepper motor speed |
43 |
|
42 |
|
44 |
// initialize the stepper library on pins |
43 |
// initialize the stepper library on pins |
45 |
#define M1 9 |
44 |
#define M1 9 |
46 |
#define M2 10 |
45 |
#define M2 10 |
47 |
#define M3 11 |
46 |
#define M3 11 |
48 |
#define M4 12 |
47 |
#define M4 12 |
49 |
Stepper myStepper(steps, M1,M2,M3,M4); |
48 |
Stepper myStepper(200, M1,M2,M3,M4); |
50 |
|
49 |
|
51 |
// DS18S20 Temperature chip |
50 |
// DS18S20 Temperature chip |
52 |
OneWire ds(5); // 1-Wire pin |
51 |
OneWire ds(5); // 1-Wire pin |
53 |
byte addr[2][8]; // 2x 1-Wire Address |
52 |
byte addr[2][8]; // 2x 1-Wire Address |
54 |
|
53 |
|
- |
|
54 |
char deleni16[16]={'0','1','1','2','3','3','4','4','5','6','6','7','7','8','9','9'}; |
- |
|
55 |
|
55 |
char serInString[100]; |
56 |
char serInString[100]; |
56 |
int serInIndx = 0; |
57 |
int serInIndx = 0; |
57 |
int in1, in2; |
58 |
int in1, in2; |
58 |
|
59 |
|
59 |
void motor (int arg) |
60 |
void motor (word arg) |
60 |
{ |
61 |
{ |
- |
|
62 |
word n; |
- |
|
63 |
word s=SSPEED; |
- |
|
64 |
|
- |
|
65 |
/* |
- |
|
66 |
for(n=0;n<2500000/SSPEED;n++) |
- |
|
67 |
{ |
- |
|
68 |
digitalWrite(M1, LOW); |
- |
|
69 |
digitalWrite(M2, HIGH); |
- |
|
70 |
digitalWrite(M1, LOW); |
- |
|
71 |
digitalWrite(M2, HIGH); |
- |
|
72 |
delayMicroseconds(SSPEED); |
- |
|
73 |
digitalWrite(M1, HIGH); |
- |
|
74 |
digitalWrite(M2, LOW); |
- |
|
75 |
digitalWrite(M1, HIGH); |
- |
|
76 |
digitalWrite(M2, LOW); |
- |
|
77 |
delayMicroseconds(SSPEED); |
- |
|
78 |
} |
- |
|
79 |
*/ |
- |
|
80 |
|
- |
|
81 |
if(arg==-1) |
- |
|
82 |
{ |
- |
|
83 |
for(n=0;n<STEPS/4;n++) |
- |
|
84 |
{ |
- |
|
85 |
digitalWrite(M1, LOW); |
- |
|
86 |
digitalWrite(M2, HIGH); |
- |
|
87 |
// digitalWrite(M3, LOW); |
- |
|
88 |
// digitalWrite(M4, HIGH); |
- |
|
89 |
delayMicroseconds(s); |
- |
|
90 |
// digitalWrite(M1, LOW); |
- |
|
91 |
// digitalWrite(M2, HIGH); |
- |
|
92 |
digitalWrite(M3, HIGH); |
- |
|
93 |
digitalWrite(M4, LOW); |
- |
|
94 |
delayMicroseconds(s); |
- |
|
95 |
digitalWrite(M1, HIGH); |
- |
|
96 |
digitalWrite(M2, LOW); |
- |
|
97 |
// digitalWrite(M3, HIGH); |
- |
|
98 |
// digitalWrite(M4, LOW); |
- |
|
99 |
delayMicroseconds(s); |
- |
|
100 |
// digitalWrite(M1, HIGH); |
- |
|
101 |
// digitalWrite(M2, LOW); |
- |
|
102 |
digitalWrite(M3, LOW); |
- |
|
103 |
digitalWrite(M4, HIGH); |
- |
|
104 |
delayMicroseconds(s); |
- |
|
105 |
if(s>1500)s-=16; |
- |
|
106 |
} |
- |
|
107 |
} |
- |
|
108 |
else |
- |
|
109 |
{ |
- |
|
110 |
for(n=0;n<STEPS/4;n++) |
- |
|
111 |
{ |
- |
|
112 |
// digitalWrite(M1, HIGH); |
- |
|
113 |
// digitalWrite(M2, LOW); |
- |
|
114 |
digitalWrite(M3, LOW); |
- |
|
115 |
digitalWrite(M4, HIGH); |
- |
|
116 |
delayMicroseconds(s); |
- |
|
117 |
digitalWrite(M1, HIGH); |
- |
|
118 |
digitalWrite(M2, LOW); |
- |
|
119 |
// digitalWrite(M3, HIGH); |
- |
|
120 |
// digitalWrite(M4, LOW); |
- |
|
121 |
delayMicroseconds(s); |
- |
|
122 |
// digitalWrite(M1, LOW); |
- |
|
123 |
// digitalWrite(M2, HIGH); |
- |
|
124 |
digitalWrite(M3, HIGH); |
- |
|
125 |
digitalWrite(M4, LOW); |
- |
|
126 |
delayMicroseconds(s); |
- |
|
127 |
digitalWrite(M1, LOW); |
- |
|
128 |
digitalWrite(M2, HIGH); |
- |
|
129 |
// digitalWrite(M3, LOW); |
- |
|
130 |
// digitalWrite(M4, HIGH); |
- |
|
131 |
delayMicroseconds(s); |
- |
|
132 |
if(s>1500)s-=16; |
- |
|
133 |
} |
- |
|
134 |
} |
- |
|
135 |
/* |
61 |
myStepper.setSpeed(1); |
136 |
myStepper.setSpeed(1); |
62 |
myStepper.step(arg * 10); |
137 |
myStepper.step(arg * 10); |
63 |
myStepper.setSpeed(sspeed); |
138 |
myStepper.setSpeed(sspeed); |
64 |
myStepper.step(arg * steps); |
139 |
myStepper.step(arg * steps); |
- |
|
140 |
*/ |
65 |
digitalWrite(M1, LOW); |
141 |
digitalWrite(M1, LOW); |
66 |
digitalWrite(M2, LOW); |
142 |
digitalWrite(M2, LOW); |
67 |
digitalWrite(M3, LOW); |
143 |
digitalWrite(M3, LOW); |
68 |
digitalWrite(M4, LOW); |
144 |
digitalWrite(M4, LOW); |
69 |
} |
145 |
} |
Line 155... |
Line 231... |
155 |
pinMode(FW1, OUTPUT); |
231 |
pinMode(FW1, OUTPUT); |
156 |
pinMode(FW2, OUTPUT); |
232 |
pinMode(FW2, OUTPUT); |
157 |
pinMode(FW3, OUTPUT); |
233 |
pinMode(FW3, OUTPUT); |
158 |
|
234 |
|
159 |
pinMode(6, OUTPUT); |
235 |
pinMode(6, OUTPUT); |
160 |
analogWrite(6, 250); |
236 |
//analogWrite(6, 254); |
- |
|
237 |
digitalWrite(6, HIGH); |
161 |
|
238 |
|
162 |
// initialize the serial port: |
239 |
// initialize the serial port: |
163 |
Serial.begin(9600); |
240 |
Serial.begin(9600); |
164 |
|
241 |
|
165 |
Wire.begin(); // join i2c bus |
242 |
Wire.begin(); // join i2c bus |
Line 184... |
Line 261... |
184 |
inicializace (); |
261 |
inicializace (); |
185 |
} |
262 |
} |
186 |
|
263 |
|
187 |
void telemetrie () |
264 |
void telemetrie () |
188 |
{ |
265 |
{ |
- |
|
266 |
int t; |
189 |
Serial.print ("FW1="); |
267 |
Serial.print ("FW1="); |
190 |
Serial.print (digitalRead (filters[0]) ? '1' : '0'); |
268 |
Serial.print (digitalRead (filters[0]) ? '1' : '0'); |
191 |
Serial.print (",FW2="); |
269 |
Serial.print (",FW2="); |
192 |
Serial.print (digitalRead (filters[1]) ? '1' : '0'); |
270 |
Serial.print (digitalRead (filters[1]) ? '1' : '0'); |
193 |
Serial.print (",FW3="); |
271 |
Serial.print (",FW3="); |
194 |
Serial.print (digitalRead (filters[2]) ? '1' : '0'); |
272 |
Serial.print (digitalRead (filters[2]) ? '1' : '0'); |
195 |
Serial.print (",T1="); |
273 |
Serial.print (",T1="); |
- |
|
274 |
t=temperature(0); |
196 |
Serial.print (temperature (0) >> 4); |
275 |
Serial.print (t >> 4); |
197 |
Serial.print ("."); |
276 |
Serial.print ("."); |
198 |
Serial.print (temperature (0) % 16); |
277 |
Serial.print (deleni16[t & 0xf]); |
199 |
Serial.print (",T2="); |
278 |
Serial.print (",T2="); |
- |
|
279 |
t=temperature(1); |
200 |
Serial.print (temperature (1) >> 4); |
280 |
Serial.print (t >> 4); |
201 |
Serial.print ("."); |
281 |
Serial.print ("."); |
202 |
Serial.print (temperature (1) % 16); |
282 |
Serial.print (deleni16[t & 0xf]); |
203 |
Serial.print (",L1="); |
283 |
Serial.print (",L1="); |
204 |
Serial.print (light (0)); |
284 |
Serial.print (light (0)); |
205 |
Serial.print (",L2="); |
285 |
Serial.print (",L2="); |
206 |
Serial.print (light (1)); |
286 |
Serial.print (light (1)); |
207 |
Serial.println (); |
287 |
Serial.println (); |
Line 235... |
Line 315... |
235 |
motor (-1); |
315 |
motor (-1); |
236 |
break; |
316 |
break; |
237 |
case 'M': |
317 |
case 'M': |
238 |
motor (1); // vysunuto |
318 |
motor (1); // vysunuto |
239 |
break; |
319 |
break; |
- |
|
320 |
|
- |
|
321 |
case 'x': |
- |
|
322 |
myStepper.setSpeed(100); |
- |
|
323 |
myStepper.step(3000); |
- |
|
324 |
break; |
- |
|
325 |
case 'y': |
- |
|
326 |
myStepper.setSpeed(10.0); |
- |
|
327 |
myStepper.step(-3000); |
- |
|
328 |
break; |
- |
|
329 |
|
240 |
case 'A': |
330 |
case 'A': |
241 |
digitalWrite(FW1, HIGH); |
331 |
digitalWrite(FW1, HIGH); |
242 |
break; |
332 |
break; |
243 |
case 'a': |
333 |
case 'a': |
244 |
digitalWrite(FW1, LOW); |
334 |
digitalWrite(FW1, LOW); |