Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!
I'm currently trying to build a 3d scanner with a garmin v3, sparkfun motors, a4988, and an Arduino Uno. However, currently, my sparkfun stepper motors, which are driven by A4988, switch directions every step. I'm not sure why this issue occurs, and sometimes the stepper motors steps properly, but 95% of the time, the stepper switches direction every step. I'm currently micro stepping by 1/16, but when the oscillation occurs, it appears to be taken over 1 step every oscillation cycle. Here is a link to a video of this issue:
LIDARLite myLidarLite; const int dirPinV = 2;Â // Direction const int stepPinV = 3; // Step const int dirPinH = 4;Â // Direction const int stepPinH = 5; // Step
// Motor steps per rotation
void setup() {  Serial.begin(115200);  myLidarLite.begin(0, true); // Set configuration to default and I2C to 400 kHz  myLidarLite.configure(0); // Change this number to try out alternate configurations
 // Setup the pins as Outputs  pinMode(stepPinV,OUTPUT);  pinMode(dirPinV,OUTPUT);  pinMode(stepPinH,OUTPUT);  pinMode(dirPinH,OUTPUT);
 pinMode(8,OUTPUT);  pinMode(9,OUTPUT);  pinMode(10,OUTPUT);
 pinMode(11,OUTPUT);  pinMode(12,OUTPUT);  pinMode(13,OUTPUT);
 digitalWrite(8,HIGH);  digitalWrite(9,HIGH);  digitalWrite(10,HIGH);
 digitalWrite(11,HIGH);  digitalWrite(12,HIGH);  digitalWrite(13,HIGH);
} void loop() { Â int maxStepV = 45*16; Â int stepV = 1;
 int maxStepH = 60*16;  int stepH = 1;  for (int x = 0; x < maxStepH; x = x + stepH*2)  {   // Set motor direction clockwise   digitalWrite(dirPinV,HIGH);   // Spin vertical   for(int v = 0; v <= maxStepV; v= v + stepV) {    digitalWrite(stepPinV,HIGH);    delayMicroseconds(500);    digitalWrite(stepPinV,LOW);    delayMicroseconds(500);    Serial.println(myLidarLite.distance(false));   }   // Pause for one second   delay(1000);
  // Spin horizontal   digitalWrite(dirPinH,HIGH);   for(int hstep = 0; hstep <= stepH; hstep= hstep + stepH) {    digitalWrite(stepPinH,HIGH);    delayMicroseconds(10000);    digitalWrite(stepPinH,LOW);    delayMicroseconds(10000);   }   myLidarLite.distance(true);
  // Pause for one second   delay(1000);
  // spin vertical   digitalWrite(dirPinV,LOW);   // Spin motor two rotations quickly   for(int v = 0; v <= maxStepV; v= v + stepV) {    digitalWrite(stepPinV,HIGH);    delayMicroseconds(500);    digitalWrite(stepPinV,LOW);    delayMicroseconds(500);    Serial.println(myLidarLite.distance(false));   }   // Pause for one second   delay(1000);
  // Spin horizontal   digitalWrite(dirPinH,HIGH);   for(int hstep = 0; hstep <= stepH; hstep= hstep + stepH) {    digitalWrite(stepPinH,HIGH);    delayMicroseconds(10000);    digitalWrite(stepPinH,LOW);    delayMicroseconds(10000);   }   myLidarLite.distance(true);   // Pause for one second   delay(1000);  } }
This looks like a very cool project (I hope you don't mind I embedded your video)!
Unfortunately my experiences with stepper motors is pretty much zero - I know how they work, just never got around playing with them. Since this is a little over my head, I'd recommend (which you probably already did) reading this section Arduino Stepper Library on the Arduino website and start with some barebones experiments. I'd also start dumping the variables like stepH and such to the serial monitor to see if there is a mistake in the logic (happens to me at times as well haha).
Like I said: I'm pretty sure you've already done all that. But unfortunately, I do not know enough about stepper motors and such to be of any useful help 😞 .
Maybe one of the other users here can chime in ...
I don't have any experience with stepper motors but I am wondering if the issue is related to the pins you are using. Great idea to include a video.Â
You are using pins 11, 12 and 13. On the Arduino Uno these are for SPI commucation. Pin 11 is MOSI, 12 is MISO and 13 is SCK. I don't think you can override this function.
Animizer Animizer.net provides complete online toolbox for animations (GIF and APNG) - Edit, Assemble, Split or Convert, it's all there.
PreLoaders Handy little online tool to generate preload images (spinners).
AlternativeTo Great resource when you're looking for alternatives for an application that you'd like to use, but might not be available on your platform or the application you have is just not doing it right.
NCH Software - WavePad Awesome Audio editor (from audio and even video files!), free for home use, available for Windows, MacOS X, iOS and Android.
Microsoft PowerToys for Windows 10 Back in the day (Windows 98/XP era) we had PowerToys - Microsoft released them again for Windows 10 (free)
Links Page These and more of our favorite links can be found on the Links Page.
New Downloads
ConnectMeNow4-v4.0.18-macOS-x86-64.dmgDate: 2024-04-24 - Size: 3.5 MBVersion 4 of ConnectMeNow - A tool for more convenient mounting of network shares under macOS. This is the Intel version which works on Intel and Apple Silicon Macs.
ConnectMeNow4-v4.0.18-macOS-arm64.dmgDate: 2024-04-24 - Size: 3 MBVersion 4 of ConnectMeNow - A tool for more convenient mounting of network shares under macOS. This is the Apple Silicon version (not suitable for Intel).
MiniWOL2 MacOS (64 bits Apple Silicon)Date: 2023-08-01 - Size: 1.2 MBminiWol is a simple, but effective application to send Wake On LAN to network devices. This is the signed 64 bit MacOS ARM (Apple Silicon) version.
MovieScanner2-2.2.3-Windows-32bit-setup.exeDate: 2023-04-12 - Size: 18.6 MBA small application that uses FFProbe to scan your video files and logs these details in a small database. This is the 32 bit Windows version.
MovieScanner2-2.2.2-Linux-GTK-64bits.tar.gzDate: 2023-04-11 - Size: 29.2 MBA small application that uses FFProbe to scan your video files and logs these details in a small database. This is the 64 bit Linux version for GTK.
MovieScanner2-2.2.2-Linux-QT5-64bits.tar.gzDate: 2023-04-11 - Size: 29.1 MBA small application that uses FFProbe to scan your video files and logs these details in a small database. This is the 64 bit Linux version for QT5.
Downloads Page Find these and more Downloads on the Downloads Page, where you will also find articles references, operating system requirements and categories.
Amazon Ads
Support us by doing your shopping at Amazon.com, either click the link, or click one of the links below …
You can also sponsor us through these Amazon offerings:
Please consider disabling your ad blocker for our website.We rely on these ads to be able to run our website.You can of course support us in other ways (see Support Us on the left).