forked from PongSatParts/PongSat-Codes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeathStar.spin
102 lines (77 loc) · 9.32 KB
/
DeathStar.spin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
{{
''***********************************************************************************
''* Title: *
''* DeathStar.spin *
''* A fun control Object for 12mA & 1.5mW OPV300 laser diodes *
''* Author: Blaze Sanders *
''* Copyright (c) 2011 Solar System Express (Sol-X) LLC *
''* See end of file for terms of use. *
''***********************************************************************************
''* Brief Description: *
''* Number of cogs/CPU's used: 1 out of 8 *
''* *
''* This code controls OPV300 laser diodes, by controlling the amount of current *
''* sourced to the laser diodes; from a varying number on 40 mA I/O pins with *
''* current limiting resistors, for a set duration of time. *
''***********************************************************************************
''* Circuit Diagram can be found at solarsystemexpress.com/death-star-in-leo.html * *
''***********************************************************************************
''* Detailed Description: *
''* Software IDE's, datasheets, getting start guides and demo code can be found at *
''* www.solarsystemexpress.com/software.html *
''***********************************************************************************
''* Theory of Operation: *
''* See YourProject.spin and GDB Hello World.spin for demos using the Pong Sat API *
''***********************************************************************************
Suggested Circuit (Sol-X)
┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬ (anade) LASER DIODE (cathode) ─┬
│ │ │ │ │ │ │ │ │ │ │ │ │
(Twelve 1300 Ohm resistors) │
│ │ │ │ │ │ │ │ │ │ │ │ │
┻ ┻ ┻ ┻ ┻ ┻ ┻ ┻ ┻ ┻ ┻ ┻
P0 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 0v
}}
CON 'Global Constants
'---Useful constants---
HIGH = 1
LOW = 0
OUTPUT = 1
INPUT = 0
VAR
'Boolean variable holding the state of the self destruct button
byte SELF_DESTRUCT
'Boolean variable monitoring the location of Luke SkyWalker
byte LUKE_SKYWALKER
OBJ
'Used to control CPU clock timing functions
'Source URL - http://obex.parallax.com/object/173
TIMING : "Clock"
PUB Initialize | OK 'Initializes all the laser diodes
SELF_DESTRUCT := false
LUKE_SKYWALKER := false
PUB Fire(PercentPower, Duration, NumberOfPins) : MoonDestoryed | NumOfPowerLevels, i 'Turns on a 1.5 mW OPV300 laser diode
'' Action: Turns on a 1.5 mW OPV300 laser diode
'' Parameters: PercentPower - Percent of 12 mA current input into laser
'' Duration - Time is seconds the laser should stay on
'' NumberOfPins - Number of (12 / NumberOfPins) mA I/O pins connected to laser diode (1 to 12)
'' Results: Moons get destoryed
''+Reads/Uses: None
'' +Writes: None
'' Local Vars: None
'' Calls: None
'' URL: http://www.solarsystemexpress.com/death-star-in-leo.html
NumOfPowerLevels := (PercentPower * NumberOfPins) / 100
If (SELF_DESTRUCT == true OR LUKE_SKYWALKER == true )
MoonDestoryed := false
Else
MoonDestoryed := true
'Power UP
Repeat i from 1 to NumOfPowerLevels
DIRA[i] := OUTPUT
OUTA[i] := HIGH
TIMING.PauseSec(Duration)
'Power DOWN
Repeat i from 1 to NumOfPowerLevels
DIRA[i] := OUTPUT
OUTA[i] := LOW
return MoonDestoryed