stepper motor with hall sensor ,control the number of revolutions

hi dears

i am actually having a problem with arduino code

my problem is that i want to control the rotation of the stepper motor based on the claculated value of RPM which comes from the hall sensor for example if (rpm>40) "this is the value that will frequently be calculated and read by the hall sensor , the question is that i want the motor to rotate once and stop based on the given steps if the rpm is less than 40 i need the motor to rotate once and stop ,else should be no rotation

your help is really appreciated

What is the sensor sensing? How many times in 1 motor revolution is the sensor activated? You realize it may take several pulses from the sensor to calculate a stable RPM reading?

if (rpm>40) "this is the value that will frequently be calculated and read by the hall sensor , the question is that i want the motor to rotate once and stop based on the given steps, if the rpm is less than 40 i need the motor to rotate once and stop ,else should be no rotation

More than 40 and less than 40... what is "else" :)

if the rpm is less than 40 i need the motor to rotate once and stop ,else should be no rotation

Each time the Arduino computes the RPM, the stepper should step the required number of times if the RPM value is less than 40?

We can't actually help you without CLEAR requirements and without seeing your code.

Personally, I think you're looking at this in completely the wrong way. Put an actual encoder on the motor, and use a PID, so you can monitor and control both speed and position. You can buy a decent 800PPR optical quadrature encoder on EBay for as little as $10.

Regards, Ray L.

hazemarjoub: my problem is that i want to control the rotation of the stepper motor based on the claculated value of RPM which comes from the hall sensor

What motor is the hall sensor connected to? It would be a complete waste of time connecting it to the stepper motor because you already know exactly how fast the stepper motor moves.

Assuming the hall sensor is connected to another motor then how many pulses per second does the sensor produce, and how many pulses per revolution of the shaft the sensor is detecting.

...R