Notifications
Clear all

Stepper Motor with Hall Effect Limit Tutorial

3 Posts
2 Users
0 Likes
1,040 Views
(@everythingiscopy)
Member
Joined: 4 years ago
Posts: 2
Topic starter  

Howdy gang -

I recently built and tried Bill's Stepper Motor with Hall Effect Limit tutorial. I used the same code and components outlined in the class. I'm trying to get a better understanding of working with limits and steppers to use in a current project but I'm still trying to grasp much of the theory and practical.

Questions - 

1 - While hall effect sensors (A) and (B) changed direction of the motor as intended, I noticed that passing a magnet over one hall effect sensor has the same effect as the magnet passing two sensors. It doesn't seem to matter which sensor triggers and the motor will change direction. Shouldn't the motor run past, say for example, limit (A) until it gets back to limit (B) before changing direction?

2 - Can mechanical limit switches be used in place of the magnetic limits, and if so, how would I code for that based from this tutorial?

3 -  In my project, I want the stepper to turn CW 180 degrees from a homed position, make contact with the limit and stop until a momentary button is pressed. Then it will turn CCW 180 degrees, hit the second limit and stop, ending the program at that point until reset.  

Thanks for the help.

Cheers -

Christopher

 

This topic was modified 3 years ago by everythingiscopy

   
Quote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@everythingiscopy

Posted by: @everythingiscopy

Questions - 

1 - While hall effect sensors (A) and (B) changed direction of the motor as intended, I noticed that passing a magnet over one hall effect sensor has the same effect as the magnet passing two sensors. It doesn't seem to matter which sensor triggers and the motor will change direction. Shouldn't the motor run past, say for example, limit (A) until it gets back to limit (B) before changing direction?

No, because both A and B generate individual interrupts.  As soon as any one of those interrupts occur, the direction variable is immediately switched in direction, and execution resumes back in the main loop of the program with the new direction.

Posted by: @everythingiscopy

2 - Can mechanical limit switches be used in place of the magnetic limits, and if so, how would I code for that based from this tutorial?

Yes, and they would be coded in exactly the same way.  Having said that however, mechanical switches are subject to bouncing issues, and will most likely require some additional denouncing code, at least for any serious program.  For this reason alone, I probably wouldn't code in limit switches using interrupts at all, but it's OK for learning and experimenting.

Posted by: @everythingiscopy

3 -  In my project, I want the stepper to turn CW 180 degrees from a homed position, make contact with the limit and stop until a momentary button is pressed. Then it will turn CCW 180 degrees, hit the second limit and stop, ending the program at that point until reset.  

In reality, you don't need any limit switches to initiate the turning of a stepper motor with the push of a button, but that doesn't sound like something too difficult to achieve for experimentation purposes anyway.  It's basically the same program code, except for replacing the switches and adding a button.  Simply assign the button to a pin, and add some code to read it's state and then toggle its state... the amount of steps to turn would occur within each toggle state condition to move it 180 degrees, or until it hits a limit switch.

Also note, that buttons usually do make use of interrupts and some denouncing code, especially where there is a need to "interrupt" a very busy operation.

Have a go at it, and someone here will be able to help I'm sure.

Cheers.


   
ReplyQuote
(@everythingiscopy)
Member
Joined: 4 years ago
Posts: 2
Topic starter  

@frogandtoad Thanks for your insight. Cheers!


   
ReplyQuote