Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added $MS for motor status. Fixed bug in MachineConfig for user outputs. #93

Open
wants to merge 2 commits into
base: Devt
Choose a base branch
from

Conversation

atlaste
Copy link
Collaborator

@atlaste atlaste commented Nov 3, 2021

As the title describes. Seems to be more bugs tho...

@MitchBradley MitchBradley deleted the branch bdring:Devt November 16, 2021 21:09
@MitchBradley MitchBradley reopened this Nov 16, 2021
Copy link
Collaborator

@MitchBradley MitchBradley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the comments are addressed, I don't have any further issues with this, but overall, it has the feel of a debugging tool that was intended for a special purpose use. Do we want to keep it around?

@@ -79,6 +79,7 @@ namespace Machine {

if (_userOutputs == nullptr) {
_userOutputs = new UserOutputs();
_userOutputs->init();
Copy link
Collaborator

@MitchBradley MitchBradley Nov 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is unnecessary since I moved the array population to the UserOutputs constructor.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

namespace MotorDrivers {
class Nullmotor : public MotorDriver {
int32_t direction = 0;
int32_t steps = 0;
int state = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is state actually used anywhere? It gets set and unset but other than that I don't see anywhere that the information goes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a left-over. I have to check. Let's first decide what to do with the PR.

public:
Nullmotor() = default;

bool set_homing_mode(bool isHoming) { return false; }

bool isReal() override { return false; }

void step() override {
Assert(!disabled, "Cannot step motor while disabled.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is unwise to Assert in something that is usually called from an ISR

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, I agree that asserts are "unwise" in an ISR. However, the rationale here was that it should "crash early" if things go wrong. After all, if the ena/dir is incorrect, it will just crash - but then again, if it's wrong and a machine moves there are bigger issues... It was a bit of a trade-off here.

}

void set_direction(bool dir) override {
Assert(!disabled, "Cannot set direction while disabled.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, Assert from ISR

@atlaste
Copy link
Collaborator Author

atlaste commented Nov 30, 2021

I only see your comments now, I really have to fix my github preferences... not sure why I didn't get a proper notification. Anyways,

If the comments are addressed, I don't have any further issues with this, but overall, it has the feel of a debugging tool that was intended for a special purpose use. Do we want to keep it around?

I have to clarify I think. This is indeed intended to be a debugging tool, specifically to test the behavior of the stepper engine with motor movements. I considered adding a 'debug_motor', but since I noticed that I'm usually developing on null_motor, it made more sense to just add it here. It does 2 things:

  1. Count the number of steps from the origin.
  2. Test if enable behavior is correct.

Since these are quite basic functionalities of the stepper engine, I made this PR. A better place would be to make a proper unit test from this... but due to all the dependencies to other components I don't see that happening anytime soon.

FTR: I'm perfectly fine with closing the PR if it's not relevant enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants