No public repo yet. I have a private one online. I wanted to make sure it actually worked, before it was made public for several reasons. A brave soul stepped up to the plate and I granted him access. His ELS, based on my hardware (custom PCB and enclosure) and software, is up and running. We both learned a bit along the way, and as a result the code is a bit more mature and generalized. There's nothing like having someone else debug your code to find bugs. They find the bugs that you were blind to. I started my ELS May of last year. Things were running well by September, which was pretty good considering it was written from scratch, and I took advantage of existing Teensy libraries. I need to scrub my repo a bit, before making it public.I looked around for the Teensy thread about an ELS, but it's a bit hard to search for the bare bones implementation from the long forum thread -- maybe I missed a repo.
I'm still going to try playing around with the pico a bit, unless I can find a slimmed down teensy or nano example that isn't a full package, but rather just encoder + motor as a platform / playground to start.
I found a PIO implementation of 4 synchronized stepper motor controls with the pico:
GitHub - Vendelator/RP2040_PIO_Steppermotors: Synchronized PIO Programs for stepper motors. 4 Motors possible.
Synchronized PIO Programs for stepper motors. 4 Motors possible. - Vendelator/RP2040_PIO_Steppermotorsgithub.com
and I found a good video about interrupts and interfacing with quadrature motor encoders:
I'll try playing around with my absolute inexperience and the encoder example first, moving to attempting threading and communciation via global variables or something similar. Not sure if it's the wrong tree to bark up, but right now I just want spindle/encoder rpm readout and hopefully some testing of stepper control based on this reading next.
Thanks again for the encoder links.Ideally the Encoder, Bresenham and Stepper Motor pulse outputs would be handled by a couple of the Pico's built in PIO processors, leaving only the user interface to the microcontroller.
aha, thanks! I mostly write bugs, not code, so I'm sure the experience would be humblingNo public repo yet. I have a private one online. I wanted to make sure it actually worked, before it was made public for several reasons. A brave soul stepped up to the plate and I granted him access. His ELS, based on my hardware (custom PCB and enclosure) and software, is up and running. We both learned a bit along the way, and as a result the code is a bit more mature and generalized. There's nothing like having someone else debug your code to find bugs. They find the bugs that you were blind to. I started my ELS May of last year. Things were running well by September, which was pretty good considering it was written from scratch, and I took advantage of existing Teensy libraries. I need to scrub my repo a bit, before making it public.
That aside, it's a good idea to play around with writing your own code and try to interface with hardware, even if they are "toy" motors and encoders. Experience is the best teacher. You don't get good at something without practice...
That's how everyone starts out. I developed the code using the same encoder and used a small stepper motor to get familiar with things. With little motors, not much can go wrong!aha, thanks! I mostly write bugs, not code, so I'm sure the experience would be humbling
Cool, thanks for the clarification about the repo.
That makes sense, I think. I was thinking that if it's polling the position incredibly fast anyhow, that I could calculate the decimal fraction for each time slice of encoder displacement, get a whole number steps to send for this poll to the motor, keep the decimal remainder in an added error tracker, then send the remainder of unsent steps in the next poll if the decimal portion of unsent steps adds up to a whole microstep threshold to add on to the next cycle of steps to send.That's how everyone starts out. I developed the code using the same encoder and used a small stepper motor to get familiar with things. With little motors, not much can go wrong!
I didn't bother interpolating Bresenham. Most of the time the numerator and denominator are relatively small if you reduce the fractions. I used all integer math for that. Haven't experienced a single thread that I've cut have any issues in practice or fit. My advice is to get all the basics working, then augment things to your liking. It's motivating to have parts working - it makes one want to continue to do more. You learn a lot with the incremental approach, the steps are a lot less daunting and it's often easier to implement. Good way to do it when you are starting out.
The way I figure it is, to try something simple to see if it's good enough. If it is then you are done. Quite often we fall into the trap of making things perfect, when 99.998% of the time it's not required. Do you look at your lathe work at 1000x? I don't. I have looked at my threads at 10x and they seem ok. Don't make the problem anymore complex than it needs to be, unless required. JMHO.That makes sense, I think. I was thinking that if it's polling the position incredibly fast anyhow, that I could calculate the decimal fraction for each time slice of encoder displacement, get a whole number steps to send for this poll to the motor, keep the decimal remainder in an added error tracker, then send the remainder of unsent steps in the next poll if the decimal portion of unsent steps adds up to a whole microstep threshold to add on to the next cycle of steps to send.
It seems like this could approximate more or less dividing the motion steps out equally, while the rate would vary in each poll of the encoder position. It doesn't seem perfect, but also it seems potentially that the main core could do the math fast enough to feed new step values to the PIO controlled motor to approximate matching the encoder rate at a given fraction. I'm sure it might be easier to dissuade myself from the efficacy after trying some experimenting out
For sure, for clarification the above last comment is my pretty naive, simple solution. The control seems pretty easy, so I'll try and see if it works.The way I figure it is, to try something simple to see if it's good enough. If it is then you are done. Quite often we fall into the trap of making things perfect, when 99.998% of the time it's not required. Do you look at your lathe work at 1000x? I don't. I have looked at my threads at 10x and they seem ok. Don't make the problem anymore complex than it needs to be, unless required. JMHO.