Skip to content

Commit

Permalink
Merge pull request #23 from nexdome/release/3.2.0
Browse files Browse the repository at this point in the history
Release 3.2.0
  • Loading branch information
NameOfTheDragon authored Dec 2, 2019
2 parents 61eb44e + 0015284 commit 8951009
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 30 deletions.
6 changes: 2 additions & 4 deletions Deploy-Firmware.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ else {
Remove-Item "$DeployDirectory\ReadMe.pdf" -ErrorAction Ignore
}

Copy-Item ".\TA.NexDome.Rotator\Release\TA.NexDome.Rotator.hex" -Destination "$DeployDirectory\" -Force
Copy-Item ".\TA.NexDome.Shutter\Release\TA.NexDome.Shutter.hex" -Destination "$DeployDirectory\" -Force
Copy-Item ".\XBeeFactoryReset\Release\XBeeFactoryReset.hex" -Destination "$DeployDirectory\" -Force
Copy-Item ".\ReadMe.pdf" -Destination "$DeployDirectory\" -Force
Copy-Item ".\TA.NexDome.Rotator\Release\TA.NexDome.Rotator.hex" -Destination "$DeployDirectory\Rotator-$semver.hex" -Force
Copy-Item ".\TA.NexDome.Shutter\Release\TA.NexDome.Shutter.hex" -Destination "$DeployDirectory\Shutter-$semver.hex" -Force

Write-Host "Deploy complete. Now build the ASCOM driver solution."

Expand Down
1 change: 1 addition & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ DW | R | ddddd | :DWR# | @DWR,300 | Write Dead-zone in steps [
FR | RS | none | :FRstring# | @FRR | Reads the semantic version (SemVer) string of the firmware.
GA | R | ddd | :GAR# | @GAR,180 | Goto Azimuth (param: integer degrees)
GH | R | none | :GHR# | @GHR | Rotates clockwise until the home sensor is detected and synchronizes the azimuth to the home position.
GS | R | ddddd | :GSR# | @GSR,1000 | Goto whole step position (0 <=param <= @RRR)
HR | R | none | :HRRddddd# | @HRR | Home position Read (steps clockwise from true north)
HW | R | ddddd | :HWR# | @HWR,1000 | Home position Write (seps clockwise from true north)
PR | RS | none | :PRt-dddd# | @PRR | Position Read - get current step position in whole steps (signed integer)
Expand Down
30 changes: 21 additions & 9 deletions TA.NexDome.Rotator/CommandProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ Response CommandProcessor::HandleCommand(Command& command) const
if (command.Verb == "FR") return HandleFR(command); // Read firmware version
if (command.Verb == "GA") return HandleGA(command); // Goto Azimuth (rotator only)
if (command.Verb == "GH") return HandleGH(command); // Goto Home Sensor (rotator only)
if (command.Verb == "GS") return HandleGS(command); // Goto step position (rotator only)
if (command.Verb == "HR") return HandleHR(command); // Home position Read (rotator only)
if (command.Verb == "HW") return HandleHW(command); // Home position Write (rotator only)
if (command.Verb == "SW") return HandleSW(command); // Stop motor (emergency stop)
Expand Down Expand Up @@ -134,19 +135,30 @@ Response CommandProcessor::HandleAR(Command& command) const
}


void CommandProcessor::rotateToMicrostepPosition(const int32_t target) const {
const auto currentPosition = rotator.getCurrentPosition();
const auto delta = target - currentPosition;
const auto direction = sgn(delta);
if (abs(delta) >= settings.deadZone)
{
HomeSensor::cancelHoming();
sendDirection(direction);
rotator.moveToPosition(target);
}
}

Response CommandProcessor::HandleGA(Command& command) const
{
const auto microstepsPerDegree = settings.home.microstepsPerRotation / 360.0;
const auto target = targetStepPosition(command.StepPosition * microstepsPerDegree);
const auto currentPosition = rotator.getCurrentPosition();
const auto delta = target - currentPosition;
const auto direction = sgn(delta);
if (abs(delta) >= settings.deadZone)
{
HomeSensor::cancelHoming();
sendDirection(direction);
rotator.moveToPosition(target);
}
rotateToMicrostepPosition(target);
return Response::FromSuccessfulCommand(command);
}

Response CommandProcessor::HandleGS(Command& command) const
{
const auto target = targetStepPosition(stepsToMicrosteps(command.StepPosition));
rotateToMicrostepPosition(target);
return Response::FromSuccessfulCommand(command);
}

Expand Down
2 changes: 2 additions & 0 deletions TA.NexDome.Rotator/CommandProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class CommandProcessor
Response HandleAW(Command& command) const; // AW - Acceleration ramp time write
Response HandleFR(Command& command) const; // Firmware version read
Response HandleGA(Command& command) const; // GA - GoTo Azimuth (in degrees).
void rotateToMicrostepPosition(int32_t target) const;
Response HandleGS(Command& command) const; // GS - GoTo Step Position
Response HandleGH(Command& command) const; // Go to home sensor
Response HandleHR(Command& command) const; // Read Home position (steps clockwise from true north)
Response HandleHW(Command& command) const; // Write home position (steps clockwise from true north)
Expand Down
18 changes: 14 additions & 4 deletions TA.NexDome.Shutter/LimitSwitch.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
//
//
//
//
//
//

#include <ArduinoSTL.h>
#include "LimitSwitch.h"
#include "NexDome.h"


MicrosteppingMotor* LimitSwitch::motor;
volatile bool LimitSwitch::closeTriggered; // static and volatile because accessed in ISR

LimitSwitch::LimitSwitch(MicrosteppingMotor* stepper, uint8_t openLimit, uint8_t closeLimit)
: openLimitPin(openLimit), closedLimitPin(closeLimit)
Expand All @@ -27,8 +28,11 @@ bool LimitSwitch::isClosed() const

void LimitSwitch::onCloseLimitReached()
{
if (closeTriggered)
return;
if (motor->getCurrentVelocity() < 0)
{
closeTriggered = true;
motor->SetCurrentPosition(SHUTTER_LIMIT_STOPPING_DISTANCE);
motor->moveToPosition(0);
}
Expand All @@ -45,10 +49,16 @@ void LimitSwitch::onOpenLimitReached()
}
}

void LimitSwitch::init()
void LimitSwitch::onMotorStopped()
{
closeTriggered = false;
}

void LimitSwitch::init() const
{
pinMode(openLimitPin, INPUT_PULLUP);
pinMode(closedLimitPin, INPUT_PULLUP);
closeTriggered = false;
attachInterrupt(digitalPinToInterrupt(openLimitPin), onOpenLimitReached, FALLING);
attachInterrupt(digitalPinToInterrupt(closedLimitPin), onCloseLimitReached, FALLING);
}
29 changes: 16 additions & 13 deletions TA.NexDome.Shutter/LimitSwitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,22 @@
#include <AdvancedStepper.h>

class LimitSwitch
{
public:
LimitSwitch(MicrosteppingMotor* stepper, uint8_t openLimit, uint8_t closeLimit);
bool isOpen() const;
bool isClosed() const;
void init();
private:
uint8_t openLimitPin;
uint8_t closedLimitPin;
static MicrosteppingMotor * motor;
static void onOpenLimitReached();
static void onCloseLimitReached();
};
{
public:
LimitSwitch(MicrosteppingMotor* stepper, uint8_t openLimit, uint8_t closeLimit);
bool isOpen() const;
bool isClosed() const;
void init() const;
void onMotorStopped();

private:
uint8_t openLimitPin;
uint8_t closedLimitPin;
static volatile bool closeTriggered;
static MicrosteppingMotor* motor;
static void onOpenLimitReached();
static void onCloseLimitReached();
};

#endif

1 change: 1 addition & 0 deletions TA.NexDome.Shutter/TA.NexDome.Shutter.ino
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,6 @@ void loop()
// Handle the motor stop event from the stepper driver.
void onMotorStopped()
{
limitSwitches.onMotorStopped();
commandProcessor.sendStatus();
}

0 comments on commit 8951009

Please sign in to comment.