Reading stepper motor rpm

Hello,

I need a way to tell the rpm of my stepper motor for a school project.
We have to make a windmill and the stepper is used as a generator.
We need a way to brake the turbine if its going to fast so we need to read the rpm's.

Is there a way to tell how fast the shaft is spinning with the help of the four leads that come out of the stepper motor?

some sort of code that reads the output of the 4 leads and tells the speed(RPM).

I use a nema17 Stepper motor.

Thanks in advance

You may be able to read the frequency across one pair of wire (take great care you do not exceed 5v or go negative on the input to the Arduino.) the frequency is dependent on the number of poles and the speed of rotation.

As you turn the motor, a voltage will be generated across the winding. This is what you would be using to take the power from your generator. It will be AC and can be fed into a diode bridge to make it DC. (It will be pulses until you put it into a battery or filter capacitor.)

Weedpharma

It is very simple (and cheap) to make tachometer with a slotted-optical-switch and something attached to the motor (a card or plastic disk with a piece missing) that breaks the beam (or allows the beam through) once per revolution. You can use a simple Interrupt Service Routine (ISR) to calculate the millisecs or micrsosecs between interruptions of the beam.

...R

Though a hybrid stepper makes a fairly decent tachometer all by itself - treat as a 100 pole
tachometer by using just 2 wires from one winding.

Interfacing an AC tachometer isn't that simple however, you have to either read rms voltage,
peak-to-peak voltage, or frequency. The output voltage may be quite high so you have to
protect against it.

Perhaps the simplest frequency measurement is to route the winding via a resistor to two back-to-back
diodes to limit the voltage to a roughly 0.7V amplitude square wave. Don't neglect the resistor or
you'll likely burn out the diodes. Something like 5 or 10k ought to work for this. A comparator
can then generate a clean logic signal from this.

Given you are generating at the same time, perhaps use an opto-isolator though - again
one winding via resistor to the opto input, then you'll get 50 pulses on the output per
revolution. It won't work so well at lower speeds as an opto-isolator needs about 1.4V to
work compared to 0.6V for a silicon diode, but you don't have to worry about DC offsets due
to the generating circuit if you are isolated.

How do you plan to slow down the motor if it is too fast? Dynamic braking would be one way. Use PWM to dump excess power to a dummy load.

Weedpharma