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
c5e40cb3
Commit
c5e40cb3
authored
Jul 15, 2019
by
markus
Browse files
Support stop and brake
parent
650c8164
Changes
6
Hide whitespace changes
Inline
Side-by-side
shackremote_arduino/brake.cpp
View file @
c5e40cb3
#include "brake.h"
Brake
::
Brake
(
int
brake_pin
,
int
release_
cache
_in_ms
)
Brake
::
Brake
(
int
brake_pin
,
int
release_
delay
_in_ms
)
{
last_release_
=
0
;
brake_counter_
=
0
;
brake_tightened_
=
true
;
brake_pin_
=
brake_pin
;
release_cache_in_ms_
=
release_cache_in_ms
;
brake_tightened_
=
true
;
release_delay_in_ms_
=
release_delay_in_ms
;
//Pin Settings
pinMode
(
brake_pin_
,
OUTPUT
);
...
...
@@ -22,7 +22,7 @@ void Brake::doBreak()
if
(
brake_tightened_
==
false
)
{
int
diff
=
millis
()
-
last_release_
;
if
((
diff
>
release_
cache
_in_ms_
)
||
(
diff
<
0
))
if
((
diff
>
release_
delay
_in_ms_
)
||
(
diff
<
0
))
{
digitalWrite
(
brake_pin_
,
HIGH
);
brake_tightened_
=
true
;
...
...
@@ -37,6 +37,11 @@ void Brake::doBreak()
}
}
void
Brake
::
skipDelay
()
{
last_release_
=
millis
()
-
release_delay_in_ms_
-
1
;
}
void
Brake
::
release
()
{
last_release_
=
millis
();
...
...
shackremote_arduino/brake.h
View file @
c5e40cb3
...
...
@@ -7,16 +7,17 @@
class
Brake
{
public:
Brake
(
int
brake_pin
,
int
release_
cache
_in_ms
);
Brake
(
int
brake_pin
,
int
release_
delay
_in_ms
);
void
doBreak
();
void
tighten
();
void
release
();
void
skipDelay
();
private:
int
last_release_
;
int
brake_counter_
;
int
brake_pin_
;
int
release_
cache
_in_ms_
;
int
release_
delay
_in_ms_
;
byte
brake_tightened_
;
};
...
...
shackremote_arduino/control.cpp
View file @
c5e40cb3
...
...
@@ -99,5 +99,15 @@ Control::hamlibError Control::executeActiveCommandSubstring(String substring)
if
(
err
==
Motor
::
ROT_VAL_OUT_OF_RANGE
)
return
HAMLIB_NOK
;
}
else
if
(
substring
==
"stop"
)
{
rotor_
->
stopAzimuth
();
rotor_
->
stopElevation
();
}
else
if
(
substring
==
"brake"
)
{
rotor_
->
stopAndBreakAzimuth
();
rotor_
->
stopAndBreakElevation
();
}
else
return
HAMLIB_NOK
;
return
HAMLIB_OK
;
}
shackremote_arduino/motor.h
View file @
c5e40cb3
...
...
@@ -14,17 +14,15 @@ public:
ROT_ALREADY_IN_SPAN
};
Motor
(
double
max
,
double
min
,
int
down_pin
,
int
up_pin
,
Brake
*
brake
,
int
sensor_pin
,
double
degree
,
double
resolution
,
double
span
);
void
doMotor
();
void
stop
();
double
getPosition
()
const
;
motorError
setPosition
(
double
);
private:
void
releaseBrake
();
void
tightenBrake
();
void
stop
();
motorError
setPosition
(
double
);
motorError
rotateUp
();
motorError
rotateDown
();
private:
motorError
readMotSensor
();
double
readADC
(
int
);
...
...
shackremote_arduino/rotor.cpp
View file @
c5e40cb3
...
...
@@ -14,26 +14,6 @@ void Rotor::doRotor()
brake_
->
doBreak
();
}
void
Rotor
::
releaseBrakeAzimuth
()
{
azimuth_
->
releaseBrake
();
}
void
Rotor
::
releaseBrakeElevation
()
{
elevation_
->
releaseBrake
();
}
void
Rotor
::
tightenBrakeAzimuth
()
{
azimuth_
->
tightenBrake
();
}
void
Rotor
::
tightenBrakeElevation
()
{
elevation_
->
tightenBrake
();
}
void
Rotor
::
stopAzimuth
()
{
azimuth_
->
stop
();
...
...
@@ -44,24 +24,16 @@ void Rotor::stopElevation()
elevation_
->
stop
();
}
Motor
::
motorError
Rotor
::
rotateCW
()
{
return
azimuth_
->
rotateDown
();
}
Motor
::
motorError
Rotor
::
rotateCCW
()
{
return
azimuth_
->
rotateUp
();
}
Motor
::
motorError
Rotor
::
rotateUp
()
void
Rotor
::
stopAndBreakAzimuth
()
{
return
elevation_
->
rotateUp
();
stopAzimuth
();
brake_
->
skipDelay
();
}
Motor
::
motorError
Rotor
::
rotateDow
n
()
void
Rotor
::
stopAndBreakElevatio
n
()
{
return
elevation_
->
rotateDown
();
stopElevation
();
brake_
->
skipDelay
();
}
double
Rotor
::
getAzimuth
()
const
...
...
shackremote_arduino/rotor.h
View file @
c5e40cb3
...
...
@@ -21,20 +21,13 @@ public:
double
getAzimuth
()
const
;
double
getElevation
()
const
;
void
releaseBrakeAzimuth
();
void
releaseBrakeElevation
();
void
tightenBrakeAzimuth
();
void
tightenBrakeElevation
();
void
stopAzimuth
();
void
stopElevation
();
void
stopAndBreakAzimuth
();
void
stopAndBreakElevation
();
Motor
::
motorError
setAzimuth
(
double
);
Motor
::
motorError
setElevation
(
double
);
Motor
::
motorError
rotateCW
();
Motor
::
motorError
rotateCCW
();
Motor
::
motorError
rotateUp
();
Motor
::
motorError
rotateDown
();
private:
Motor
*
azimuth_
;
Motor
*
elevation_
;
...
...
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