hello everyone,
I would like to know how to initialize a stepper motor, like to make it stop and get 0 as its position once a magnet meet a magnetic sensor. I got the magnetic sensor but i am not able to make the motor stop and get initialized. I didn't use any library for my arduino code.
Thank you. ![]()
You need to move the motor towards the sensor one step at a time and check the sensor between steps.
...R
Stepper Motor Basics
Hi,
Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html
Tom..... ![]()
Thank you Robin, i am going to give it a try now.
TomGeorge, i didn't understand your second sentence. Should i make a copy past or do i have to attach it?
do you count steps now ?
if you just run with a pulse and no count, you need to count steps, or microsteps.
to set 'home'
run at your normal speed, past the sensor
then back up slowly
then very slowly run to the sensor
when the sensor changes state, display step count. it should be 0 if you count up when moving away and cound down when moving towards the sensor.
note the postion.
move away 10 steps
move back slowly and see if the sensor changes state at 0
set your count to 0
if the count is off by some amount you pick, then you can have an alarm of some kind.
by the way a sensor should never be a physical block. it should never be installed so that if the motor runs freely, it will crash into the sensor. it should be designed so that it trips the sensor as is passes.
Hi,
Read and goto the link for the thrid line, it will show you how to post your sketch.
http://forum.arduino.cc/index.php/topic,148850.0.html
See section 7
Tom.... ![]()