Replies: 1 comment
-
Correct, if sets to 0, nothing happen, see the code here: https://github.com/nanoframework/nanoFramework.IoT.Device/blob/3d260069b12bd33224b02d1ff5d0aec818a36eb8/devices/A4988/A4988%20.cs#L57 And from the rest of the code, I don't really see anything to optimize much: https://github.com/nanoframework/nanoFramework.IoT.Device/blob/3d260069b12bd33224b02d1ff5d0aec818a36eb8/devices/A4988/A4988%20.cs#L69 If you want something much faster, then if you're using an ESP32, I recommend you to use RMT. Just create the wave length you need and output it, you'll be able to control precisely exactly what you need. See for example this sample: https://github.com/nanoframework/Samples/blob/main/samples/Hardware.Esp32.Rmt/NeoPixelStrip/NeoPixel/NeopixelChain.cs. In your case, it will be the same for high and low, with the number of steps you need. |
Beta Was this translation helpful? Give feedback.
-
I use the example code to drive my stepper motor ( driver chip: A4988)
When changing the micro-steps to Microsteps.SisteenthStep, the motor makes one revolution in 6s, it's too slow.
If the micro-steps is FullStep, it will be faster; but it's still slow for me.
I think the parameter 'sleepTime' is used to control the rotation speed, but it has been zero.
using Iot.Device.A4988;
using System;
// Pinout for MCU please adapt depending on your MCU
// Any regular GPIO will work
const byte stepPin = 10;
const byte dirPin = 11;
const Microsteps microsteps = Microsteps.FullStep;
const ushort fullStepsPerRotation = 200;
TimeSpan sleepTime = TimeSpan.Zero;
using (var motor = new A4988(stepPin, dirPin, microsteps, fullStepsPerRotation, sleepTime))
{
var direction = true;
while (true)
{
var rotationDegree = (direction ? 1 : -1) * 360;
motor.Rotate(UnitsNet.Angle.FromDegrees(rotationDegree));
direction = !direction;
System.Threading.Thread.Sleep(1000);
}
}
Beta Was this translation helpful? Give feedback.
All reactions