×

INDI Library v2.0.6 is Released (02 Feb 2024)

Bi-monthly release with minor bug fixes and improvements

Stepper focusser directly from Raspberry

  • Posts: 8
  • Thank you received: 0
@Kaczorek
Thanks to your source I have managed to adapt the rpi_focuser source so that it will drive the BYJ28 motor + driver. Great stuff! See attached file.

However I'm wondering what the 'speed' and 'timer' values do. They are presented in the UI, but from the source I don't really see what their practical purpose is.
Also, how do you establish Absolute position? Is it merely because at some point you have moved the focuser to minimum and have bee very careful to always move it back to that before switching off?

I'm considering adding a 'steps/mm' parameter so that focus positions and ranges can be in distance instead of steps. In my case there is a mm scale on the focuser, so another thing that might be handy is to have a 'set absolute' button where one can set the position to the actual position of the focuser.
8 years 7 months ago #4681
Attachments:

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

  • Posts: 983
  • Thank you received: 375
@mrpraline, Astroberry Focuser actually works this way.
1. The starting position is 0, which is the most counter clockwise position. Just turn your focuser knob maximum to the left before mounting your focuser on.
2. Focusing outward increases absolute position value and focusing inward increases absolute position value.
3. On the Options tab you can find Parking Mode - while it's ON by clicking Save options button you can save actual position of your focuser. With Parking Mode ON when disconnecting the focuser it will return to 0 position first. After you reconnect it will return to saved position. Switching Parking Mode OFF will disable this feature and the focuser will not remember the position between the sessions. I always keep it ON so absolute position number is correct.
4. Anytime absolute position is out of sync with actual physical position of the focuser you can reset absolute position number by going to 0 and clicking Reset button on Options tab. This will perform short counter clockwise move to reach physical zero position (see p. 1 above). As soon as you focuser knob stops turning left you are sure that it is at 0 and physical focuser position and absolute position value are in sync.
5. You can use presets to define and save predefined focuser positions. Remember to save the options after setting the preset values. This will ensure that values are persistent between sessions.
6. Timer value is time in milliseconds you want the focuser to move (In or Out). It just calculates number of steps per time value and performs them. Set the value to e.g. 1000 ms, choose direction e.g. Inward and you will see that the focuser moves for 1 second to a specified direction. It's relative position feature. I don't use it personally but I know that some people do so I included it in the code.
7. Speed value is ignored and not used anyhow. It is a default feature of INDI focuser coming from the framework. At it's current version Astroberry Focuser works in a single speed mode. You can change default speed in the code. After many tests I don't think dual speed is required at all. The precision you will get with your setup (923 steps per revolution) should be more than enough. If it is not, just change default speed in the code to 1/nth of the full step. I will consider introducing fast and fine buttons for user level speed/precision control in future versions.

So in summary - use Parking Mode, Save options at you favorite position and you will have your focuser ready at the favorite position just after connection. Set your Presets and you can quickly change your focus after adding a barlow lens or a focal reducer.

I hope it explains a lot :)
8 years 7 months ago #4682

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

  • Posts: 8
  • Thank you received: 0
Thanks that answers a lot for me. I'm starting to get to grips with the software now.
So essentially Parking mode is used as a helper to stop the focuser in a well known position and this is how you maintain absolute position.

I have started to modify the code further so that setting and reporting the focus position will be in mm. I think this is easier to use and also allows a uniform mode of operation between different physical configurations of stepper motor, reduction and focuser.
If I get really ambitious I will change the code so one can configure different stepper interfaces at user defined hardware pins. That would allow the driver to be used in a generic way without having to compile from source.

BTW: My BYJ28 motor has has 4096 steps/turn and my focuser has a 1:10 reduction so I had to increase MAX-STEP to 140000.
8 years 7 months ago #4683

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

  • Posts: 314
  • Thank you received: 34
@Kaczorek
In your motor.sh script there is this sleep value of 0.000005. Does this mean 5 microseconds for each step on/off and one complete step is 10 microseconds?
I just now found the value for my stepper that has to be at least 1.9µs for each high/low. So I could set sleep in my case to at least 0.000002?

Meanwhile I think I successfully managed to set the current limit to 0.67A on the driver DRV8834 by:
  • set M0,M1 to 0 (for full step mode)
  • set SLEEP to 1 (for powering the motor without step)
  • measuring the current of one coil (which is 70% of the desired current limit of one coil,)
in my case it would be I=(0.67A/2)*0.7=0,2345A/coil, then I used the potentiometer to set it.
I have to verify that again!

Parts are now complete except some screws, holes are drilled (thanx for the elongated holes tip).
I still fear the angle wont be stiff enough and teeth may skip while rotating. I will maybe cut an 2nd angle an
screw them together.

--= human, without Windows™ =--
pls excuse my bad english! :)
Last edit: 7 years 4 months ago by pauledd.
8 years 7 months ago #4706

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

  • Posts: 983
  • Thank you received: 375
I'm very glad that you got it working!
Sleep value is exactly what you think :) You can safely set 0.000002 in the script. As the result locical 1 will be set for 2µs and locical 0 for another 2µs. The full step cycle will take 2x2µs = 4µs. This values are specific for your stepper motor. As stated before you can check the model values in your motor datasheet. It is also safe to experiment with the value, providing you don't leave the motor running with wrong values for long time since it gets warm and in worse case scenario does not move a step.
In my project I'm using secong angle sliding on the base plate. This way I can precisely tune distances and keep the construction very solid.

BTW. in your previous post you suggested to use mm scale in the focuser. I will leave it to your customization since using it in the astroberry focuser code will make it very motor/gears/focuser specific. I'm afraid it might loose precision when recalculating absolute position to mm values. If you come across a good solution we can work it out togeter to include it in astroberry code in future versions.
8 years 7 months ago #4707

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

  • Posts: 314
  • Thank you received: 34
I guess the "mm"-thing post you are refering to was from mrpraline: indilib.org/forum/general/766-stepper-fo...y.html?start=24#4681
--= human, without Windows™ =--
pls excuse my bad english! :)
8 years 7 months ago #4708

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

  • Posts: 314
  • Thank you received: 34

In your svn-code rpi_focus.cpp there is:
#define STEP_DELAY 4 // [b]mili[/b]seconds
could it be that you mean microseconds?

// Stepper motor takes 4 miliseconds to move one step = 250 steps per second (real rate = 240,905660377)
// 1) focusing from min to max takes 7 evolutions
// 2) PG2528-0502U step motor makes 7 * (360deg/15degperstep)*72:1 = 1728 steps per evolution
// 3) MAX_STEPS for 7 evolutions should be 12096

This is all meant in full step mode?

I am just trying to calculate MAX_STEPS.
Lets say my focuser needs 3 evolutions for min/max and has 60 teeth. My motor gear has 13 teeth.
(60/13)*3=13.846 evolutions for min/max at the motor. 13.846 evolutions multiplied by 200 steps per evolution gives 2769.23 steps for MAX_STEPS.

Status Report: ;)
  • The motor is mounted, wiring is done,RaspberryPi has been completely "gentoo-fied" (took me 3 days).
  • Now there is a lot of fine adjustment. Those elongated holes are fine but I am unable to tighten screws on the motor because there is no place. So I have to dismount the hole thing again and again for just adjusting the motor spacing.


  • In full step mode the motor and the whole tube somehow gets in resonance and makes incredible noise
    This can be corrected a little bit by optimizing the gears spacing but its still LOUD. In 1/2 step mode its bearable, at 1/8 it would be my desired loudness.
    @Kaczorek, what step mode does the rpi_focuser use and can this be changed somehow?
--= human, without Windows™ =--
pls excuse my bad english! :)
Last edit: 8 years 7 months ago by pauledd.
8 years 7 months ago #4732

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

  • Posts: 8
  • Thank you received: 0
Good to hear your progress!
The bcm2835_delay() function is specified in milliseconds.
The relevant code starts on line 525 of rpi_focus.cpp:
 // step on
        bcm2835_gpio_write(STEP, HIGH);
        // wait
        bcm2835_delay(STEP_DELAY/2);
        // step off
        bcm2835_gpio_write(STEP, LOW);
        // wait 
        bcm2835_delay(STEP_DELAY/2);
If you need better resolution you could change those to bcm2835_delayMicroseconds(STEP_DELAY/2) and specify STEP_DELAY in microseconds instead of milliseconds.

I found in rpi_focusser.cpp only full step mode. However there is a function FocusRpi::SetSpeed() that allows programming to different microstep values.

So you could change line 481 in FocusRpi::MoveAbsFocuser from SetSpeed(1) to SetSpeed(4) for 1/8 microstepping. But then you will also need to adjust the total amount of steps and delay also. So for 1/8 microstepping you use 1/8 of the delay value and multiply the total number of steps by 8.
Last edit: 8 years 7 months ago by Gerrit Jan Baarda.
8 years 7 months ago #4733

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

  • Posts: 314
  • Thank you received: 34
ok thank you, I will go into that after fine tuning mechanics :)
--= human, without Windows™ =--
pls excuse my bad english! :)
8 years 7 months ago #4734

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

  • Posts: 314
  • Thank you received: 34
Ok I somewhat managed the noise problem.
I run into another problem (I guess skywatcher only). After mounting my Canon700D/Flattener to the focuser the focuser shaft seems to have not enought pressure against the focuser tube so I did the optimization recommended in this video . The problem was when the full weight is straight down the focuser doesn't move if the motor moves. I admit this is a rare situation that I work with the DSLR on the top. After the optimization it work better but not perfect. The problem is when I start the focuser from total inward and set it to do 1000 steps outward and when done I set it back to 0 it moves inward until it reaches the zero point but its moving on. So it moves faster inward than outward.

If I cant fix this will this be an problem while doing ekos auto-focusing? Or does it try to focus until it reaches focus no matter how much steps it skipped. I will try to add some more pressure to the focuser axis to add more friction but I guess this will stress the motor more and more.
If that doesnt work I can still set to manual focus.

Everything else is set up, waiting for clear sky to test :silly:
--= human, without Windows™ =--
pls excuse my bad english! :)
8 years 7 months ago #4739

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

  • Posts: 314
  • Thank you received: 34
Situation update: Yesterday I was able to test focuser and I have to say everything works to my full satisfaction including auto-focus. It was able to focus in less than a minute without stepper-noise-terror to the neighbourhood.
Thank you all for your inspirations an especially Kaczorek for your driver! B)
--= human, without Windows™ =--
pls excuse my bad english! :)
8 years 6 months ago #4915

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


A video demo will be great!!
8 years 6 months ago #4916

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

Time to create page: 0.873 seconds