Hi Paul and the rest of the internets
I've been trying to figure out a problem with my stepper count being ~4x higher than expected while running on a Teensy 3.0.
I have a 200 step/rev NEMA23 bipolar stepper motor connected to a G203V Gecko driver with 10x microstepping. Thus, the stepper motor is capable of 2000 steps or positions per revolution. I have a high resolution (20000 steps/rev) quadrature encoder mounted on the same shaft as the stepper motor. The Geckodriver is supplied with 30VDC and is current limited to 2A. I am trying to get the stepper motor to rotate at 1.5RPM.
I am using Teensyduino 1.16 and Arduino 1.0.5.
Using the included code below, I would expect that after one revolution, the step count would be 2000 and the encoder count would be 20000. However, in testing, the step count is 7926 and the encoder count is 20008. I timed a single revolution at roughly 2min38s. The timing of 20000microseconds (sincePrint) should give rise to 50pps (1.5RPM). I've also tried it at a higher speed (2000microseconds/15RPM) which yielded similar results. I realise there are easier ways to do what I'm trying to do, but those methods gave similar results. :/ The code I've included is just a sanity check...
I'm unsure if this is an implementation problem or if I've run into a bug? Any suggestions would be much appreciated!
Here is the last bit of output from serial:
7912 19973
7913 19973
7914 19981
7915 19981
7916 19981
7917 19981
7918 19989
7919 19989
7920 19989
7921 19990
7922 19999
7923 19999
7924 19999
7925 19999
7926 20008
7927 20008
7928 20008
7929 20008
The output seems to suggest that the stepper motor only takes a physical microstep every 4th command.
Here is the code:
I tried to do something similar with the Accelstepper library and ended up with values of 1999 and 20150. Close, but not perfect. Not sure if this is relevant?
I've been trying to figure out a problem with my stepper count being ~4x higher than expected while running on a Teensy 3.0.
I have a 200 step/rev NEMA23 bipolar stepper motor connected to a G203V Gecko driver with 10x microstepping. Thus, the stepper motor is capable of 2000 steps or positions per revolution. I have a high resolution (20000 steps/rev) quadrature encoder mounted on the same shaft as the stepper motor. The Geckodriver is supplied with 30VDC and is current limited to 2A. I am trying to get the stepper motor to rotate at 1.5RPM.
I am using Teensyduino 1.16 and Arduino 1.0.5.
Using the included code below, I would expect that after one revolution, the step count would be 2000 and the encoder count would be 20000. However, in testing, the step count is 7926 and the encoder count is 20008. I timed a single revolution at roughly 2min38s. The timing of 20000microseconds (sincePrint) should give rise to 50pps (1.5RPM). I've also tried it at a higher speed (2000microseconds/15RPM) which yielded similar results. I realise there are easier ways to do what I'm trying to do, but those methods gave similar results. :/ The code I've included is just a sanity check...
I'm unsure if this is an implementation problem or if I've run into a bug? Any suggestions would be much appreciated!
Here is the last bit of output from serial:
7912 19973
7913 19973
7914 19981
7915 19981
7916 19981
7917 19981
7918 19989
7919 19989
7920 19989
7921 19990
7922 19999
7923 19999
7924 19999
7925 19999
7926 20008
7927 20008
7928 20008
7929 20008
The output seems to suggest that the stepper motor only takes a physical microstep every 4th command.
Here is the code:
Code:
#include <Stepper.h>
#include <Encoder.h>
Stepper disk1_stepper(2000, 7, 8); // 2000 = number of microsteps per revolution
// pin 7 = step
// pin 8 = direction
Encoder disk1_encoder(11, 12);
elapsedMicros sincePrint;
char command = '0';
String tab = String("\t");
long disk1_stepper_count = 0;
long disk1_encoder_count = 0;
void setup() // run once, when the sketch starts
{
Serial.begin(115200); // set up serial library at 115200 bps
delay(15000);
Serial.println("Please enter 1 to continue: ");
while (command != '1') {
if (Serial.available()) {
command = Serial.read();
}
}
disk1_encoder.write(0);
}
void loop() // run over and over again
{
if (sincePrint > 20000)
{
sincePrint = 0;
disk1_stepper.step(1);
disk1_stepper_count++;
disk1_encoder_count = disk1_encoder.read();
String output = disk1_stepper_count + tab + disk1_encoder_count;
Serial.println(output);
}
}
I tried to do something similar with the Accelstepper library and ended up with values of 1999 and 20150. Close, but not perfect. Not sure if this is relevant?