Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Software Defined Radio
r0tor
Commits
028e5d26
Commit
028e5d26
authored
Mar 03, 2019
by
Markus Mueller
Browse files
Add rotating functionality
parent
e603b37f
Changes
4
Hide whitespace changes
Inline
Side-by-side
shackremote_arduino/rotor.cpp
View file @
028e5d26
...
...
@@ -34,6 +34,7 @@ void CRotor::initRotor()
digitalWrite
(
AZIM_RE_BREAK
,
HIGH
);
//Initial Values
m_bAzimuthBreakReleased
=
0
;
m_bAzimuthCurrentlyRotating
=
0
;
}
if
(
ELEV
)
{
...
...
@@ -47,6 +48,7 @@ void CRotor::initRotor()
digitalWrite
(
ELEV_RE_BREAK
,
HIGH
);
//Initial Values
m_bElevationBreakReleased
=
0
;
m_bElevationCurrentlyRotating
=
0
;
}
}
...
...
@@ -56,19 +58,140 @@ void CRotor::initRotor()
void
CRotor
::
doRotor
()
{
//Do all the Rotor Stuff here
readRotSensors
();
if
(
AZIM
)
if
(
AZIM
&&
false
)
{
//Do all the Azimuth Stuff here
if
(
m_bAzimuthCurrentlyRotating
)
{
if
(
abs
(
m_uActualAzimuth
-
m_uSetAzimuth
)
<
AZIM_RES
)
stopAzimuth
();
else
{
if
(
m_uActualAzimuth
-
m_uSetAzimuth
>
0
)
rotateCW
();
else
rotateCCW
();
}
}
else
{
if
(
abs
(
m_uActualAzimuth
-
m_uSetAzimuth
)
>
AZIM_SPAN
)
{
releaseBreakAzimuth
();
if
(
m_uActualAzimuth
-
m_uSetAzimuth
>
0
)
rotateCW
();
else
rotateCCW
();
}
}
}
if
(
ELEV
)
{
//Do all the Elevation Stuff here
int
diff
=
m_uActualElevation
-
m_uSetElevation
;
if
(
m_bElevationCurrentlyRotating
)
{
if
(
abs
(
diff
)
<
ELEV_RES
)
{
stopElevation
();
if
(
m_uSetElevation
>=
90
)
{
setElevation
(
20
);}
else
{
setElevation
(
130
);}
}
else
{
if
(
diff
>
0
)
rotateUp
();
else
rotateDown
();
}
}
else
{
if
(
abs
(
diff
)
>
ELEV_SPAN
)
{
releaseBreakElevation
();
if
(
diff
>
0
)
rotateUp
();
else
rotateDown
();
}
}
}
}
void
CRotor
::
releaseBreakAzimuth
()
{
m_bAzimuthBreakReleased
=
1
;
digitalWrite
(
AZIM_RE_BREAK
,
LOW
);
}
void
CRotor
::
releaseBreakElevation
()
{
m_bElevationBreakReleased
=
1
;
digitalWrite
(
ELEV_RE_BREAK
,
LOW
);
}
void
CRotor
::
tightenBreakAzimuth
()
{
m_bAzimuthBreakReleased
=
0
;
digitalWrite
(
AZIM_RE_BREAK
,
HIGH
);
}
void
CRotor
::
tightenBreakElevation
()
{
m_bElevationBreakReleased
=
0
;
digitalWrite
(
ELEV_RE_BREAK
,
HIGH
);
}
void
CRotor
::
stopAzimuth
()
{
digitalWrite
(
AZIM_RE_CW
,
HIGH
);
digitalWrite
(
AZIM_RE_CCW
,
HIGH
);
m_bAzimuthCurrentlyRotating
=
0
;
setAzimuth
(
m_uActualAzimuth
);
}
void
CRotor
::
stopElevation
()
{
digitalWrite
(
ELEV_RE_UP
,
HIGH
);
digitalWrite
(
ELEV_RE_DWN
,
HIGH
);
m_bElevationCurrentlyRotating
=
0
;
setElevation
(
m_uActualElevation
);
}
CRotor
::
rotorError
CRotor
::
rotateCW
()
{
if
(
m_bAzimuthBreakReleased
==
0
)
return
CRotor
::
ROT_BREAK_NOT_RELEASED
;
digitalWrite
(
AZIM_RE_CW
,
LOW
);
digitalWrite
(
AZIM_RE_CCW
,
HIGH
);
m_bAzimuthCurrentlyRotating
=
1
;
return
CRotor
::
ROT_OK
;
}
CRotor
::
rotorError
CRotor
::
rotateCCW
()
{
if
(
m_bAzimuthBreakReleased
==
0
)
return
CRotor
::
ROT_BREAK_NOT_RELEASED
;
digitalWrite
(
AZIM_RE_CW
,
HIGH
);
digitalWrite
(
AZIM_RE_CCW
,
LOW
);
m_bAzimuthCurrentlyRotating
=
1
;
return
CRotor
::
ROT_OK
;
}
CRotor
::
rotorError
CRotor
::
rotateUp
()
{
if
(
m_bElevationBreakReleased
==
0
)
return
CRotor
::
ROT_BREAK_NOT_RELEASED
;
digitalWrite
(
ELEV_RE_UP
,
LOW
);
digitalWrite
(
ELEV_RE_DWN
,
HIGH
);
m_bElevationCurrentlyRotating
=
1
;
return
CRotor
::
ROT_OK
;
}
CRotor
::
rotorError
CRotor
::
rotateDown
()
{
if
(
m_bElevationBreakReleased
==
0
)
return
CRotor
::
ROT_BREAK_NOT_RELEASED
;
digitalWrite
(
ELEV_RE_UP
,
HIGH
);
digitalWrite
(
ELEV_RE_DWN
,
LOW
);
m_bElevationCurrentlyRotating
=
1
;
return
CRotor
::
ROT_OK
;
}
///
/// @brief Serial Debug output Function
///
...
...
@@ -78,12 +201,10 @@ void CRotor::debugOut()
//debug Out
readRotSensors
();
Serial
.
println
(
"-----------------"
);
Serial
.
write
(
"Azim Value: "
);
Serial
.
write
(
m_uActualAzimuth
);
Serial
.
println
(
""
);
Serial
.
write
(
"Elev Value: "
);
Serial
.
write
(
m_uActualElevation
);
Serial
.
println
(
""
);
Serial
.
print
(
"Azim Value: "
);
Serial
.
println
(
m_uActualAzimuth
);
Serial
.
print
(
"Elev Value: "
);
Serial
.
println
(
m_uActualElevation
);
}
///
...
...
@@ -158,8 +279,10 @@ CRotor::rotorError CRotor::setElevation(uint16 pElevation)
CRotor
::
rotorError
CRotor
::
readRotSensors
()
{
m_uActualAzimuth
=
(
uint16
)(
readADC
(
AZIM_POT
)
/
AZIM_DEG
);
m_uActualElevation
=
(
uint16
)(
readADC
(
ELEV_POT
)
/
ELEV_DEG
);
if
(
AZIM
)
m_uActualAzimuth
=
(
uint16
)(
readADC
(
AZIM_POT
)
/
AZIM_DEG
);
if
(
ELEV
)
m_uActualElevation
=
(
uint16
)(
readADC
(
ELEV_POT
)
/
ELEV_DEG
);
return
CRotor
::
ROT_OK
;
}
...
...
@@ -175,8 +298,10 @@ CRotor::rotorError CRotor::readRotSensors()
uint16
CRotor
::
readADC
(
int
AdcPin
)
{
//Read ADC 4 times and calculate average
uint
16
adcValue
=
0
;
for
(
int
i
=
0
;
i
<
4
;
i
++
)
uint
32_t
adcValue
=
0
;
for
(
int
i
=
0
;
i
<
128
;
i
++
)
adcValue
+=
analogRead
(
AdcPin
);
adcValue
=
adcValue
/
4
;
}
\ No newline at end of file
delay
(
1
);
adcValue
=
adcValue
/
128
;
return
(
uint16
)
adcValue
;
}
shackremote_arduino/rotor.h
View file @
028e5d26
...
...
@@ -16,7 +16,8 @@ class CRotor
public:
enum
rotorError
{
ROT_OK
,
ROT_NOK
,
ROT_VAL_OUT_OF_RANGE
};
ROT_VAL_OUT_OF_RANGE
,
ROT_BREAK_NOT_RELEASED
};
CRotor
();
void
initRotor
();
void
doRotor
();
...
...
@@ -24,9 +25,20 @@ public:
uint16
getActualAzimuth
()
const
;
uint16
getActualElevation
()
const
;
void
releaseBreakAzimuth
();
void
releaseBreakElevation
();
void
tightenBreakAzimuth
();
void
tightenBreakElevation
();
void
stopAzimuth
();
void
stopElevation
();
rotorError
setAzimuth
(
uint16
);
rotorError
setElevation
(
uint16
);
rotorError
rotateCW
();
rotorError
rotateCCW
();
rotorError
rotateUp
();
rotorError
rotateDown
();
private:
rotorError
readRotSensors
();
uint16
readADC
(
int
);
...
...
@@ -37,6 +49,8 @@ private:
uint16
m_uSetElevation
;
byte
m_bAzimuthBreakReleased
;
byte
m_bElevationBreakReleased
;
byte
m_bAzimuthCurrentlyRotating
;
byte
m_bElevationCurrentlyRotating
;
};
#endif //ROTOR_H
\ No newline at end of file
#endif //ROTOR_H
shackremote_arduino/settings.h
View file @
028e5d26
...
...
@@ -21,12 +21,15 @@
// Allowed span in degree
#define AZIM_SPAN 5
#define ELEV_SPAN 3
#define ELEV_SPAN 3
0
// Max Values
#define AZIM_MIN 0
#define AZIM_MAX 360
#define ELEV_MIN 0
#define ELEV_MAX 180
#define AZIM_MIN 0.0
#define AZIM_MAX 360.0
#define ELEV_MIN 0.0
#define ELEV_MAX 180.0
// Resolution values in degree
#define AZIM_RES 1
#define ELEV_RES 15
// ADC Values
#define AZIM_ADC_MIN 0
#define AZIM_ADC_MAX 1024
...
...
@@ -37,18 +40,18 @@
// Pin Settings
// Rotor Sensor Pins
#define AZIM_POT A
8
#define ELEV_POT A
9
#define AZIM_POT A
1
#define ELEV_POT A
0
// Rotor Relais
// Aximut
#define AZIM_RE_CW
0
#define AZIM_RE_CCW
0
#define AZIM_RE_BREAK
0
#define AZIM_RE_CW
53
#define AZIM_RE_CCW
51
#define AZIM_RE_BREAK
45
// Elevation
#define ELEV_RE_UP
0
#define ELEV_RE_DWN
0
#define ELEV_RE_BREAK
0
#define ELEV_RE_UP
47
#define ELEV_RE_DWN
49
#define ELEV_RE_BREAK
45
...
...
@@ -61,4 +64,4 @@
// Typedefs
typedef
unsigned
int
uint16
;
#endif //SETTINGS_H
\ No newline at end of file
#endif //SETTINGS_H
shackremote_arduino/shackremote_arduino.ino
View file @
028e5d26
...
...
@@ -45,13 +45,14 @@ void setup()
//Debug
debugTime
=
0
;
rotor
.
setElevation
(
70
);
}
void
loop
()
{
hamlib
.
receiveHamlibPacket
();
//
hamlib.receiveHamlibPacket();
rotor
.
doRotor
();
hamlib
.
sendHamlibPacket
();
//
hamlib.sendHamlibPacket();
if
(
debugTime
>
100
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment