×

INDI Library v2.0.7 is Released (01 Apr 2024)

Bi-monthly release with minor bug fixes and improvements

Can someone help me understand elative and absolute focuser position?

  • Posts: 16
  • Thank you received: 0
I'm a college student working on client development using PyIndi-Client for a research project with a professor. There are standard properties for focusers called REL_FOCUS_POSITION and ABS_FOCUS_POSITION for which I'm trying to write functions to change their values. Or, rather, I would like to be able to do that, but I don't understand what they are or what the difference between them is. I do know that you can use getNumber("REL_FOCUS_POSITION") to access the list of members, change the value and send it back to the indiclient, but I don't know what the numbers mean. Here's what some of my code looks like right now:

@app.route('/focuser/abs_focus=<int:steps>')
def set_focus_abspos(steps):
    abs_focus_pos=device_focuser.getNumber("ABS_FOCUS_POSITION")
    abs_focus_pos[0].value=steps
    indiclient.sendNewNumber(abs_focus_pos)
    return make_response(jsonify('Absolute focus position set to: ' +
                                 str(abs_focus_pos[0].value)),200)

The app.route stuff is from a package called Flask, for anyone who might not recognize that. So you see that a number of steps is passed into the function, but what does that number actually represent?

I'm still pretty novice when it comes to this stuff, so I'm trying to build a deeper understanding. When I googled this question, I didn't see any real explanations, so I would appreciate any clarification someone could give me.
Last edit: 3 years 11 months ago by Stephen Berg. Reason: Fixed code
3 years 11 months ago #53577

Please Log in or Create an account to join the conversation.

  • Posts: 421
  • Thank you received: 102
Most (but not all) focusers use a stepper motor. Stepper motors have a definite number of steps per revolution of the motor (usually 200, sometimes 400). So the steps parameter maps directly to a number of steps on the stepper motor.

Setting the absolute position will move the stepper to the new position specified. If it thinks the current position is 5000, and you tell it to move to 4000, then it will move inward by 1000 steps.

Now, if you know you want to move inward by, say, 100 steps, you could get the current absolute position, subtract 100, then tell the focuser to move to that new absolute position. Or you could just tell it to move inward by 100 steps by passing -100 to the relative position property. Or +100 to move outward. So the relative properties are just a shortcut to move in or out a set distance. Otherwise you'd have to read the absolute position, do some math (not complicated), then send back the new position.

Hope this helps!
The following user(s) said Thank You: Jasem Mutlaq, Stephen Berg
3 years 11 months ago #53589

Please Log in or Create an account to join the conversation.

  • Posts: 16
  • Thank you received: 0
Thanks for the speedy reply. I understand how the relative and absolute positions work now, but this has brought up another question. There is another standard property for focusers called FOCUS_MOTION which is a switch that can be defined as focusing in or focusing out. I'm testing my functions with an indiserver running indi_simulator_focus, and being able to pass in absolute position values to the simulator to change the absolute position to be higher or lower than the previous value seems to invalidate the need for the FOCUS_MOTION property. Am I understanding this correctly? What's the point of the FOCUS_MOTION switch if the absolute focuser position can be changed in either direction at will?
3 years 11 months ago #53597

Please Log in or Create an account to join the conversation.

  • Posts: 421
  • Thank you received: 102
Sorry, I was going from memory. I poked through the code, and yes, the relative motion is slightly more complicated than I first described it. Doing a relative move is a two-step process. Set the direction via the FOCUS_MOTION property. Then set the amount you want to move via REL_FOCUS_POSITION (always a positive number, so my comment above about -100 is wrong). When you do that, the focuser will move the specified direction for the specified distance. And yes, you could achieve this with the ABS_FOCUS_POSITION setting as well.

The main reason (I believe) for the relative movement properties is for DC focus motors, not stepper motors. DC motors don't have steps. You turn voltage on, they run until you turn the voltage off. In this case, the amount to move isn't steps, but milliseconds. And for those types of focusers, the absolute position settings won't be available. I think that's how it works. I'm not sure, I only work with stepper motors.
The following user(s) said Thank You: Stephen Berg
3 years 11 months ago #53600

Please Log in or Create an account to join the conversation.

Time to create page: 0.183 seconds