GithubHelp home page GithubHelp logo

Comments (16)

NameOfTheDragon avatar NameOfTheDragon commented on September 3, 2024

I can't initially reproduce this. Is there something special about the numbers or does this happen from any starting position?

from firmware.

rpineau avatar rpineau commented on September 3, 2024

from firmware.

NameOfTheDragon avatar NameOfTheDragon commented on September 3, 2024

OK thanks.

So looking at the code, it is difficult to see how the homing operation can fail to start.

void HomeSensor::findHome(int direction)
	{
	if (phase == Idle || phase == AtHome)
		{
		const auto distance = 2 * homeSettings->microstepsPerRotation;	// Allow 2 full rotations only
		setPhase(Detecting);
		motor->moveToPosition(distance);
		}
	}

The only possibility I can really see there is that the phase state variable must be in the correct state or homing will not start. Perhaps the state is getting left in a corrupt state from a previous operation. This will need further investigation.

Home detection is via an edge triggered interrupt from the home sensor. Even if this were happening immediately after starting the home operation before the motor has taken even a single step, then that could possibly look like nothing has happened. This seems unlikely though, with a nearly 20 degree movement away from home.

from firmware.

NameOfTheDragon avatar NameOfTheDragon commented on September 3, 2024

Nope, I can't make it happen. Is there any possibility of getting the customer to reproduce it in PuTTY or a dumb terminal emulator, so we can see the raw output from the rotator?

from firmware.

rpineau avatar rpineau commented on September 3, 2024

from firmware.

NameOfTheDragon avatar NameOfTheDragon commented on September 3, 2024

I believe it will be set to Idle the next time there is an onMotorStopped event...

/*
 * Handles the onMotorStopped event. Action depends on the homing phase.
 */
void HomeSensor::onMotorStopped() const
	{
	std::cout << "Hstop " << phase << std::endl;
	switch (phase)
		{
		case Reversing:
			setPhase(AtHome);
			break;
		case Stopping:
			setPhase(Reversing);
			const auto target = commandProcessor.targetStepPosition(homeSettings->position);
			motor->moveToPosition(target);
			break;
		default:
			setPhase(Idle);
			return;
		}
	}

Even if that were not the case, it is explicitly allowed to start another homing operation while already at home, so that would still work.

from firmware.

rpineau avatar rpineau commented on September 3, 2024

from firmware.

NameOfTheDragon avatar NameOfTheDragon commented on September 3, 2024

Ah yes. Thanks for doing that @rpineau , that's really helpful. I will have another go at reproducing it here.

from firmware.

NameOfTheDragon avatar NameOfTheDragon commented on September 3, 2024

OK, yes I can reproduce it now. It's pretty odd because the output doesn't seem to match what the code says should happen.

P47885
P47686
P47565
STOP
Hstop 4
:SER,47522,1,55080,0,50#
XB->Online

With this output, we can see STOP (motor stopped event) and then HStop 4. This is produced in the home sensor onMotorStopped event handler. The 4 is "phase 4" which is AtHome (this is expected at thsi point). However, a few lines later the switch statement should set the phase to Idle (since it is known to be AtHome and not Reversing or Stopping but it looks like that's not happening:

/*
 * Handles the onMotorStopped event. Action depends on the homing phase.
 */
void HomeSensor::onMotorStopped() const
	{
	std::cout << "Hstop " << phase << std::endl;
	switch (phase)
		{
		case Reversing:
			setPhase(AtHome);
			break;
		case Stopping:
			setPhase(Reversing);
			const auto target = commandProcessor.targetStepPosition(homeSettings->position);
			motor->moveToPosition(target);
			break;
		default:
			setPhase(Idle);
			return;
		}

Is there some subtlety of C++ that I'm missing that could cause that default case not to execute?

from firmware.

rpineau avatar rpineau commented on September 3, 2024

from firmware.

NameOfTheDragon avatar NameOfTheDragon commented on September 3, 2024

If this is based on the homing phase (Action depends on the homing phase. in your comment), then what happen if we're not homing.

By design, the state should be AtHome at the end of a FindHome operation and Idle when no homing operation is in progress (it is actually cleared to Idle each time the motor stops, except if the previous state was Reversing). Therefore, it follows that (by design) AtHome will be true at the end of a successful homing operation and false at all other times.

However it looks like there may be a compiler bug that's causing it to generate incorrect code for switch statements. I had something similar elsewhere in the code and I had to re-order my case statements to get it to work. I've re-written it using if statements and its working now. I'll send you a hotfix to test shortly.

Aside: I wouldn't recommend relying on the AtHome flag for anything other than display purposes, because Find Home is an operation, not a position. The AtHome flag has no meaning outside of a Find Home operation and it should never be true except at the end of a successful Find Home operation. There is also no defined "home position" (from the firmware's point of view), there is only the azimuth of the home sensor, which is not quite the same thing, conceptually. The definition is in the FAQ under https://github.com/nexdome/ASCOM/wiki/Home,-Park-and-Home-Sensor-Magnet-Positioning#home-sensor-azimuth.

from firmware.

NameOfTheDragon avatar NameOfTheDragon commented on September 3, 2024

@rpineau could you give this a go please?
Rotator-3.2.1-Beta.1.zip

from firmware.

rpineau avatar rpineau commented on September 3, 2024

from firmware.

NameOfTheDragon avatar NameOfTheDragon commented on September 3, 2024

from firmware.

rpineau avatar rpineau commented on September 3, 2024

from firmware.

NameOfTheDragon avatar NameOfTheDragon commented on September 3, 2024

Fixed for firmware release 3.3.0, later today.

from firmware.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.