How do you initialize the stepper motor?

#3 · closed · 4 comments

View on GitHub ↗

TheSiebi

I really like your project, but I couldn't find out how you initialize the stepper motor. Do you just point it north before starting the program?

Comments

LordBrain

The stepper motor is controlled via the arduino. https://github.com/blee1170/SpacePointer/blob/master/Ardiuno/Space_Pointer.ino#L19 is where it starts. I have a compass hooked up as well. So when it powers on, it will find north with that. Then start tracking the ISS. The Raspberry Pi handles that.

TheSiebi

I don't understand how the stepper finds north with the compass hookup. Let's say the stepper is pointing south before powering up. Now after you power everything on it should make the stepper move 180 degrees so it points north. How can it calculate the 180 degrees? The only way it would make sense for me is if the compass was attached to the stepper, but otherwise I don't get how you know what the stepper's initial direction is. Thanks for the quick response btw!

LordBrain

This function gets the current direction its facing: https://github.com/blee1170/SpacePointer/blob/master/Ardiuno/Space_Pointer.ino#L117 Then when the stepper motor is asked to move it will check the current direction, then based on what the Pi has told it to face it will move: https://github.com/blee1170/SpacePointer/blob/master/Ardiuno/Space_Pointer.ino#L211 Then it will keep looping until it is within 2º of what it should be. It reads the compass all the time.

TheSiebi

Thank you very much!