Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Satnogs Arduino
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Android-smartphones
interesting_things
bkerler
Satnogs Arduino
Commits
773b19ee
Commit
773b19ee
authored
Apr 18, 2014
by
Agis Zisimatos
Browse files
Options
Downloads
Patches
Plain Diff
arduino code
parent
36b55a20
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
arduino/SatNOGS.ino
+60
-0
60 additions, 0 deletions
arduino/SatNOGS.ino
arduino/Serial.ino
+50
-0
50 additions, 0 deletions
arduino/Serial.ino
arduino/Stepper.ino
+68
-0
68 additions, 0 deletions
arduino/Stepper.ino
with
178 additions
and
0 deletions
arduino/SatNOGS.ino
0 → 100644
+
60
−
0
View file @
773b19ee
#include
<string.h>
#include
<stdlib.h>
#include
<math.h>
#define DIR_AZ 8
#define STEP_AZ 9
#define EN_AZ 7
#define DIR_EL 10
#define STEP_EL 11
#define EN_EL 12
#define SPD 200 //step per degree
#define T_DEALY 10000
#define T_STEPPER 1
int
stepPosAz
=
0
;
int
stepAz
=
0
;
int
stepPosEl
=
0
;
int
stepEl
=
0
;
long
t1
=
0
;
void
setup
()
{
pinMode
(
DIR_AZ
,
OUTPUT
);
pinMode
(
STEP_AZ
,
OUTPUT
);
pinMode
(
EN_AZ
,
OUTPUT
);
digitalWrite
(
EN_AZ
,
LOW
);
digitalWrite
(
DIR_AZ
,
LOW
);
pinMode
(
DIR_EL
,
OUTPUT
);
pinMode
(
STEP_EL
,
OUTPUT
);
pinMode
(
EN_EL
,
OUTPUT
);
digitalWrite
(
EN_EL
,
LOW
);
digitalWrite
(
DIR_EL
,
LOW
);
Serial
.
begin
(
19200
);
}
void
loop
()
{
/*Time Check*/
if
(
t1
==
0
)
t1
=
millis
();
if
(
stepAz
==
0
&&
stepEl
==
0
&&
millis
()
-
t1
>
T_DEALY
)
{
digitalWrite
(
EN_AZ
,
HIGH
);
digitalWrite
(
EN_EL
,
HIGH
);
}
else
{
digitalWrite
(
EN_AZ
,
LOW
);
digitalWrite
(
EN_EL
,
LOW
);
}
cmd_proc
();
stepper_move
();
}
This diff is collapsed.
Click to expand it.
arduino/Serial.ino
0 → 100644
+
50
−
0
View file @
773b19ee
void
cmd_proc
()
{
/*Serial*/
static
char
buffer
[
256
];
char
incomingByte
;
static
int
counter
=
0
;
char
data
[
100
];
/*Read from serial*/
while
(
Serial
.
available
()
>
0
)
{
incomingByte
=
Serial
.
read
();
/*new data*/
if
(
incomingByte
==
'\n'
||
incomingByte
==
' '
||
incomingByte
==
'\r'
)
{
buffer
[
counter
]
=
0
;
if
(
buffer
[
0
]
==
'A'
&&
buffer
[
1
]
==
'Z'
)
{
strncpy
(
data
,
buffer
+
2
,
100
);
double
cmdAz
=
atof
(
data
);
stepAz
=
path
(
cmdAz
);
}
else
if
(
buffer
[
0
]
==
'E'
&&
buffer
[
1
]
==
'L'
)
{
strncpy
(
data
,
buffer
+
2
,
10
);
double
cmdEl
=
atof
(
data
);
stepEl
=
deg2step
(
cmdEl
)
-
stepPosEl
;
}
else
if
(
buffer
[
0
]
==
'S'
&&
buffer
[
1
]
==
'A'
)
{
stepAz
=
0
;
}
else
if
(
buffer
[
0
]
==
'S'
&&
buffer
[
1
]
==
'E'
)
{
stepEl
=
0
;
}
counter
=
0
;
//Reset time
t1
=
0
;
}
/*Fill the buffer with incoming data*/
else
{
buffer
[
counter
]
=
incomingByte
;
counter
++
;
}
}
}
This diff is collapsed.
Click to expand it.
arduino/Stepper.ino
0 → 100644
+
68
−
0
View file @
773b19ee
void
stepper_move
()
{
if
(
stepAz
>
0
)
{
digitalWrite
(
DIR_AZ
,
HIGH
);
digitalWrite
(
STEP_AZ
,
HIGH
);
stepPosAz
++
;
stepAz
--
;
}
else
if
(
stepAz
<
0
)
{
digitalWrite
(
DIR_AZ
,
LOW
);
digitalWrite
(
STEP_AZ
,
HIGH
);
stepPosAz
--
;
stepAz
++
;
}
if
(
stepEl
>
0
)
{
digitalWrite
(
DIR_EL
,
LOW
);
digitalWrite
(
STEP_EL
,
HIGH
);
stepPosEl
++
;
stepEl
--
;
}
else
if
(
stepEl
<
0
)
{
digitalWrite
(
DIR_EL
,
HIGH
);
digitalWrite
(
STEP_EL
,
HIGH
);
stepPosEl
--
;
stepEl
++
;
}
delay
(
T_STEPPER
);
digitalWrite
(
STEP_AZ
,
LOW
);
digitalWrite
(
STEP_EL
,
LOW
);
delay
(
T_STEPPER
);
}
int
path
(
double
cmdAz
)
{
int
sign
=
0
,
stepTemp
;
double
PosAz
=
cmdAz
-
step2deg
(
stepPosAz
);
double
distAz
=
abs
(
PosAz
);
if
(
distAz
<
180
)
stepAz
=
deg2step
(
PosAz
);
else
{
if
(
PosAz
>
0
)
sign
=
-
1
;
else
sign
=
1
;
stepTemp
=
deg2step
((
360
-
PosAz
)
*
sign
);
}
return
stepTemp
;
}
int
deg2step
(
double
deg
)
{
return
(
60
*
SPD
*
deg
/
360
);
}
float
step2deg
(
int
Step
)
{
return
(
360
*
Step
/
(
SPD
*
60
));
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment