Controlling Stepper Motors with uLisp


#1

Hi everyone,

I’ve recently started experimenting with uLisp on an Arduino-compatible board, and I’m trying to control a small stepper motor as part of a robotics project. My goal is to write a simple Lisp function to move the motor a certain number of steps in each direction.

So far, I’ve managed to toggle GPIO pins from uLisp, but I’m running into a couple of challenges:

Timing – I’m not sure what’s the most efficient way to generate the correct step pulses in uLisp.

Smooth motion – the motor seems to stutter at higher speeds, probably because my stepping sequence isn’t timed evenly.

Hardware – I’m using a basic ULN2003 driver board with a 28BYJ-48 stepper motor.

Has anyone here successfully driven a stepper motor directly from uLisp?

Do you recommend writing a small C function and calling it from uLisp for more precise timing?

Or is it possible to handle the stepping loop entirely within uLisp without noticeable jitter?

I’d love to see sample code or hear about your approach. My next step will be trying microstepping with a driver like the A4988, but I’d like to get the basics working first.

Thanks in advance for any tips!


#2

Garbage collection is probably your biggest source of jitter, since it runs at unpredictable times, unless you call it yourself. If you call (gc) between every step, it should be more even.

If all else fails you could write a uLisp extension to embed some existing Arduino stepper control library like the AccelStepper library.