Please explain how to interpret the data in the table?
Please check the Reply #6 for details on how to interpret it.
Ok. So I decided to do a fresh start today.
I took out my motor from the assembly and wanted to check each section to see where a potential issue be coming from. So here is what I did.
I connected the motor to Polulu DRV8825 shield via an Arduino Leonardo at a no load condition(Almost). I connected a coupler to the motor shaft and made sure its very tight to avoid any slippages. I printed out this Circular 360 degree angle picture and made sure the shaft is perfectly aligned to the center of that picture. Then I 3D printed a arrow(Very light) which goes on top of the coupler to show angle of rotation when seen from the top. (Sorry I don't have the picture of the setup with me now, will post it tomorrow). I set the current limit of the driver to 1A.
What I wanted to test was that if there was any missing steps(By measuring the shaft angles) when I change the parameters of the code like delay between each step or when it runs lot of steps or when it is running in different modes.
Following is the code I used for the test. I change the modes and parameters in each test.
// Arduino Digital Pins and Motor Connections
int dPin = 6; // Direction motor || HIGH - Towards the Motor || LOW - Away from the Motor
int sPin = 7; // Step Pin for providing square pulses
int wake = 9; // Sleep Pin || HIGH - Driver Enabled || LOW - Enter Sleep Mode
int M1 = 4; // Mode Pins
int M0 = 5; // Mode Pins
int enb = 8; // Enable Pin for driver || HIGH - Driver Disabled || LOW - Driver Enabled
int rst = 10; // Reset Pin for driver || HIGH - Driver Enabled || LOW - Driver Disabled
int pulsePeriod = 100; // Pulse Period for the Step Waveform
char input;
// Following parameters can be changed in the tests
int delayTime = 30 ; // Delay between Each Step in milliseconds
int nMoveSteps = 1600; // Testing with values 100, 200, 400, 800, 1000
void stepMotor(boolean dir, int nSteps, int dirPin, int stepPin) // Input - Value for Direction Pin, Number of Steps to be moved pins, uC Pins for direction and step
{
digitalWrite(dirPin, dir); // HIGH - Towards the Motor || LOW - Away from the Motor
delayMicroseconds(2);
for (int i = 0; i < nSteps; i++)
{
digitalWrite(stepPin, HIGH);
delayMicroseconds(pulsePeriod);
digitalWrite(stepPin, LOW);
delayMicroseconds(pulsePeriod);
}
}
void setup()
{
Serial.begin(9600);
pinMode(dPin, OUTPUT);
pinMode(sPin, OUTPUT);
pinMode(wake, OUTPUT);
pinMode(enb, OUTPUT);
pinMode(M0, OUTPUT);
pinMode(M1, OUTPUT);
// Full Step Mode
// digitalWrite(M0, LOW);
// digitalWrite(M1, LOW);
// Half Step Mode
// digitalWrite(M0, HIGH);
// digitalWrite(M1, LOW);
// One Fourth Step Mode
// digitalWrite(M0, LOW);
// digitalWrite(M1, HIGH);
// One Eight Mode
digitalWrite(M0, HIGH);
digitalWrite(M1, HIGH);
digitalWrite(enb, HIGH); // Logic HIGH - Driver Disabled
digitalWrite(wake, HIGH); // Logic HIGH - Driver Enabled
digitalWrite(rst, HIGH); // Logic HIGH - Driver Enabled
}
void loop()
{
if (Serial.available() > 0)
{
input = Serial.read();
if (input == 'f' || 'F')
{
for (int i = 0; i < nMoveSteps; i++)
{
digitalWrite(enb, LOW);
delayMicroseconds(2);
stepMotor(HIGH, 1, dPin, sPin);
delay(delayTime); // For Delay between each step // 30ms for Sanyo Pancake motor @10V, 20ms Oriental PKP225D06A @6V, 10ms for SY35ST26 @7.4V
digitalWrite(enb, HIGH);
}
Serial.println("Move Forward");
}
else if (input == 'b' || 'B')
{
for (int i = 0; i < nMoveSteps; i++)
{
digitalWrite(enb, LOW);
delayMicroseconds(2);
stepMotor(LOW, 1, dPin, sPin);
delay(delayTime); // For Delay between each step // 30ms for Sanyo Pancake motor @10V, 20ms Oriental PKP225D06A @6V, 10ms for SY35ST26 @7.4V
digitalWrite(enb, HIGH);
}
Serial.println("Move Backward");
}
else
{
Serial.println("Wrong Input");
}
}
}
I give Serial Input as 'F' which will cause the motor to move nMoveSteps as mentioned in the code.
Test results are as follows for various parameters.




My inference is that there is no missing of steps(except for a couple of times in all of the tests conducted) based on the tests above.
So I am assuming my code and the motor with no load is working precisely. (Any counter suggestions?)
What I am planning to do tomorrow is to connect loads and my mechanical setup to see if that is causing any issue.
Any thoughts on the above?
Also on a side note, lets say if I move the n steps via code and then when motor is stationary, I rotate the shaft slightly with my hand and then move n steps again via code, I see a slight jump in the reverse direction before the motor proceeds to rotate in the proper direction. Is this because of the misalignment between the energised stator and the rotor. (I will probably read up in detail about the sequencing of motors, that will probably answer the above question but just thought of asking).