10 years, 9 months ago.

interrupt question!! i need to control step motor

i'm using 2 head files it's "sMotor.h" and "mbed-rtos.h"

here's the situation

a step motor is rotating in front of me then i got analogin signal from 4 led sensors i need to control the step motor's rpm i want to use interruptin function but it's too hard to use.

is there any good function to control step motor?

1 Answer

10 years, 9 months ago.

InterruptIn is more intended for digital signals, so triggering an interrupt when a certain pin transitions from high to low or vice-versa, so it isn't so useful for adjusting the position based on analog signals. If you are interested in controlling a stepper motor, there are a few options. If you want to be able to use microstepping to get particularly fine control of your stepper motor, you'll probably want to use a dedicated stepper motor driver IC, which you can get on breakout boards from pololu or sparkfun, though it can be done using a simple motor driver such as an L293D. If you don't need such fine control, then you could use the boards I mentioned, or you could alternatively just use a simpler driver such as the L293D and control the sequence of the coils of the stepper motor in order to turn it in a certain direction. Which kind of light sensor are you using to detect the light, because depending on what you're aiming to do, and how you're intending to do you may be able to do it better than constantly looping through and checking to see if the analog value of the sensors has changed. Theoretically you could set up a Ticker, or a timer to check the analog value every so often without having to build it into your while(1) loop. In case it's relevant, what are you using RTOS for in the project?

Accepted Answer