stepper motor tach code

Does any one have or can steer me in the right direction. looking for a working tachometer code.
using a switec x25/27 stepper motor. digital 5v in and run the stepper directly from the aurdino

Dougsauto

Hi,
Welcome to the forum.

I think you will find the forum members prefer not to write custom code.
We can help you develop your code.

What is your electronics, programming, arduino, hardware experience?
If all you need is code written for you, then there is a Gig and Collaboration section of the forum that you can use.

Thanks.. Tom... :slight_smile:

If you know the interval between the steps that you send to the stepper motor can't you calculate the RPM?

Post links to the datasheet for the stepper motor and tell us what stepper motor driver you are using. Also, give details of the motor power supply (volts and amps).

...R
Stepper Motor Basics
Simple Stepper Code

Hi,
The switec x25/27 stepper motor is a car dashboard meter.

There are plenty of articles about using it as tacho.

Tom.... :slight_smile:

Thanks for the clarification Tom.

I thought the OP wanted to measure RPM.

...R

Hi,
Yes he does want to measure engine RPM I gather and use the stepper as the tacho.
But we are not here to write ALL the code.

Tom... :slight_smile:

Hi All

I can build just about anything I want electronic. but when it comes to writing code pretty much lost. all my electronic experience started before there were microprocessors.I usually can modify and existing code to suit my needs. I need 2 instruments one tach and one speedometer both inputs are hall effect sensors 5 v square wave.
tach frequency from 0 to 165 HZ speedo is 0 to 2050 HZ

switec motor specs are.

•Axial Force Maximum: 150N
•Axial Pull Force Maximum: 100N
•Radial Force Maximum: 12N
•Rotation Angle Maximum: 315°
•Coil Resistance: 260 ohm
•General Tolerance: ± 0.1 / ± 5°
•Rotation Angle Maximum: ~315°
•600 steps per 'rotation' (315 degree rotation)

I know that the group does not like to write the codes for someone that's why I was wondering if there may be a previous post that may have some info.

Thank you Dougsauto

For the stepper motor to move the needle to (say) the 3000 rpm position you will have to tell it to move a certain number of steps from the ZERO position. You will probably need to do some experiments to figure out how many steps match the diagram on your display.

If you are detecting pulses (say one pulse per revolution) then you need to measure the interval between pulses and map that to the appropriate number of steps corresponding to that engine speed.

You can set up an Interrupt Service Routine (ISR) that is triggered by each pulse and records the value of micros(). When the next pulse triggers the ISR you can subtract the previously saved value of micros() from the latest value to get the interval between the pulses.

The code in the ISR could be as simple as

void savePulseMicros() {
   pulseMicros = micros();
   newPulse = true;
}

The purpose of newPulse = true; is to let the other part of your code know that a new pulse has been detected so that it knows to work out the interval.

...R

Try this.