Hi, i want to calculate the rpm of my stepper motor as a beginner. delay in microseconds is 3500. using nema 23 stepper motor with 200 steps per revolution (1.8 degree). plz guide me & suggest me the formula to calculate the exact rpm. more how to calculate pulse rate or peulse frequency
thanks in advance
void Nema(void *pvParameters){
//Nema pins
pinMode (pulPin, OUTPUT); // set Pin9 as PUL
pinMode (dirPin, OUTPUT); // set Pin8 as DIR
digitalWrite (dirPin, LOW); // set high level direction
while(1){
//nema speed control
int delayValue = 3500; // in microseconds
digitalWrite (pulPin, HIGH);
delayMicroseconds (delayValue);
digitalWrite (pulPin, LOW);
delayMicroseconds (delayValue);
}
I would imagine youre microstepping at 1/8th steps. If youre seeing that difference between expected and actual RPM values... Can you elaborate more on your code and circuit/driver setup?
Have you confirmed the current has been regulated appropriately for your motor/system?
Your step period is 7000 micros (3500 HIGH + 3500 LOW), a minute is 60 million micros, 60000000 / 7000 = 8571.42857143 steps per minute, / 200 steps per revolution = 42.8571428571 revolutions per minute (RPM). It's just elementary school arithmetic.
// Vacuum Motor
#define RPWM 5
#define LPWM 6
int Vacuumspeed = 150;
// Nema 23
#define pulPin 9
#define dirPin 8
//int delayValue = 3500; // in microseconds
unsigned long previous_NemaTime = 0;
long NemaDelay = 5; // in milliseconds
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
// Vacuum
pinMode(RPWM, OUTPUT);
pinMode(LPWM, OUTPUT);
analogWrite(LPWM, 0);
//Nema
pinMode (pulPin, OUTPUT); // set Pin9 as PUL
pinMode (dirPin, OUTPUT); // set Pin8 as DIR
digitalWrite (dirPin, LOW); // set high level direction
}
void loop() {
// put your main code here, to run repeatedly:
//vacuum speed
analogWrite(RPWM, Vacuumspeed);
//nema speed
digitalWrite (pulPin, LOW);
unsigned long current_NemaTime = millis();
if(current_NemaTime - previous_NemaTime >= NemaDelay) {
digitalWrite (pulPin, HIGH);
previous_NemaTime = current_NemaTime;
}
//delay(500);
}
I have analyzed the pulse signal (pin no 9 of Arduino Uno) in a proteus which showed the time period is 5ms. but the motor is not rotating with 60 RPM as calculated theoretically. There is also negligible load on Nema 23. I have also tested the motor providing 4.5A max current but still the same problem. Motor moves at about 8 RPM calculated manually.
A couple of points. First, the DM542 has opto isolated inputs which is good but I can't recall what the drive current is (i.e. what the series resistor to the LED is) - hopefully the Arduino digital outputs will have enough grunt. I don't think you said what Arduino you are using - it does have 5v logic levels I suppose?
Second, in your loop() you write a high after 5ms to pulPin but then it almost immediately gets set low next time round the loop - the resulting pulse length may be too short to reliably trigger the driver. You want something like 2.5ms high then 2.5ms low so pulses repeat at 500Hz.
Can i ask you to try a different approach on the motor logic, and let me know the results?
digitalWrite(pulpin, HIGH);
delaymicros(20); // this is the step pulse, the value 20 worked well for my needs
digitalWrite(pulpin, LOW);
delaymicros(500); // change this value only for RPM adjustment