Stepper motors are ideal for 3D printers, robots, mills and lathes; you can program them to rotate by very precise amounts. Push the right signal (âI will have 36 degrees pleaseâ) into the motor driver and it will spin or âstepâ by the nominated amount.
This is a companion discussion topic for the original entry at http://reprage.com/post/non-blocking-control-of-stepper-motors-on-arduino
That’s a pretty creative solution. Have you had a chance to look at using the AVR Timer2 or other in-built timer interrupt services? They offer asynchronous processing, over using millisecond delays to achieve a similar result https://makezine.com/2012/01/25/how-to-arduino-interrupts/
Woah, that is awesome. Have only ever used hardware interrupts, never timer based. Will definitely give them a bit of a tinker. Thanks for the tip.
Be interested to see what/if any blocking occurs when passing data to and from the interrupt. I.e. the stuff that happens between a cli and sei call – https://github.com/cfreeman/fishparty_dispenser/blob/master/fishparty_dispenser.ino#L107-L113
That’s an interesting program. What about using a digital oscillator at a specified frequency to control it the same way as the Arduino output? That was you can send a command and leave it running while Arduino is going something else. Also, do you know if your solution would work for this motor: 28BYJ-48 STEPPER MOTOR?
looking at writing my own firmware for a 3d printer on an Arduino Due type setup but I wanted to be able to develop it on Windows first and simply emulate everything. Using interrupts to control the steppers made this near impossible so was looking at doing something similar to what you have done.
Under Windows… basically I would cut the delays out as the simulation would have steppers that need no fancy timing or make noise. The simulation would allow me to accurately plot and view exactly where the print heads think they have travelled and how much plastic is extruded.
In the simulation things like heat beds and end stops would also be simulated.
From what I can tell… the main tricky bit is moving the nozzle from x1,y1 to x2,y2 in a smooth manner while possibly extruding.
I did some similar coding that output to a MCP4921 DAC via SPI inside an interrupt and at first had small __asm delays after toggling the SCK signal. I hated having delays in the code especially inside the interrupt… so after looking at the way the entire loop worked interleaved some code after each SCK toggle that was enough to not need the delays.
Did you try the approach with that stepper motor? It ‘should’ work?