An Electronic Lead Screw controller using a Teensy 4.1

Plotting the discretized position vs the analog, one can see the staircase. For the highest TPI's, the staircase lags the analog curve. If one wanted to, one could individually adjust the offset of the staircase by preloading the accumulator for every thread pitch selected. This would reduce the phase lag of the thread, and the peak phase error by centering the quantization error around zero. It only seems worthwhile for the smallest pitches. The staircase error really is incredibly small for most threads. For now, I will leave things the way they are, and only adjust them if they prove to be troublesome in reality. No point of fixing something, if it isn't known to be broken! The errors are small, but unique to each pitch.

This morning worked on the menuing a bit more. Put on my noise cancelling headphones and went to work. I find the graphical display more difficult than implementing the carriage position control. Now have two menus to choose from when in threading mode. Touching the Imp/Metric button toggles between Imperial and Metric states, and the corresponding allowable threads are displayed. Next step will be to implement touch sense for this menu, allowing me to touch the thread text and the corresponding parameters will be displayed in the small area at the bottom left. If the save button is touched, the values will be loaded, and the state of the machine will be advanced to "initialized". Then the menu will go back to the main page, with the thread pitch or TPI updated. "Start" will then enable threading. Once enabled, the stepper will advance (or recede), when the spindle moves, to achieve the selected thread.
PXL_20220523_153407208.jpgPXL_20220523_153422794.jpg
The individual pitches (or TPI's) are far enough apart so one can select them with one's finger tip without too much trouble. A stylus works as well. This puts all the info at your fingertips without having to scroll through stuff.

Slowly getting a little more done on this project. Getting to the point of looking at stepper motors again. A NEMA-24 4Nm motor seems to be about the right size and capability. Will have to seriously look at how the heck to integrate this into my system, ie. pulleys, ratios and installation related things. Getting a bit more exciting now.
 
Rightly or wrongly, I pulled the trigger on a stepperonline kit with a 4Nm closed loop stepper, controller and power supply. If it's insufficient, maybe I can use it for some other task.

I was talking about it with my wife and she said, would you like it for your birthday present? Not being a dope, I said yes. Maybe I should have held out for more, but having approval for playing in the shop is good. It's not like the kit was big money. Frees up some mad money for other stuff. :grin:
 
Hmm, after putting in my garden and getting too much sun, thought I'd take a look at things again.

Unfortunately, I seemed to have gotten a computer update that has delayed my plans. As is usual with graphics related stuff, it is a bear to figure out. Has something to do with updating to Wayland, maybe, or more likely, the interaction between Wayland and Nvidia drivers. All I know is , first it seemed like the computer was operating at 1/10 Baud. You know, terribly slow update. 10 seconds for a keystroke to show up. Computer was sluggish.

Thought I fixed it with updating the video driver. But that has had some unfortunate side effects. Like having my computer turn off, after flashing the Teensy. After the flash, the computer freezes for 3-5 seconds, meaning the mouse doesn't move. Then the computer just plain turns off. Doesn't go to sleep, it just turns off. Like someone pulled the plug. Have to say, this is a major inconvenience! I'm kind of irritated at a minor update doing this sort of thing. More infuriating is I cannot seem to backdate the driver, nor even use the open source Nouveau driver, the OS complains of missing dependencies, which it should have installed. May have to transfer my Arduino files to my RPI4, just so I can keep going at this. Pretty much a pain in the neck...
 
My main computer still is dying from some sort of video problem. So I moved my Arduino development temporarily to a 4GB RPI4. I have removed the SD card and directly boot and run from a SSD, and while it isn't a speed demon, at least it is tolerable. I also boosted the clock a little. I can get by for a while.

Got some additional UI work done today. Now can select either imperial or metric threads, and select a pitch. The pitch value is saved and the ustep, Numerator and Denominator are determined. Working through the issues of modifying existing code to allow me to pass in these new selected values. As they say, too bad I didn't think of that when I wrote that routine in the beginning. Oh, well, eventually it will be muddled through. Now when I select the pitch, an auxilliary display is populated with the ustep, N & D values. If I touch save, these values are loaded into variables called newpitch, newustep, etc. I will handle the transfer of these new values in the main state machine. If quit is touched, then these values are zeroed. Eventually, I may add some non-volatile storage to make this less tedious, but so far the selection menu process doesn't take too much time. Think I may highlight the touched button, for better feedback, but the bottom row is what will get loaded into the machine (if saved).
PXL_20220530_182859290a.jpg
 
Hopefully the fix for my laptop computer continues to work. Had to purge my video drivers and reinstall them. Don't know why they were messed up, but hopefully this fixes my nightmare shutdowns.

Seems like I can do the stuff that I was doing before, like compiling and flashing the Teensy. So I had to move all the stuff from my makeshift RPI-4 setup (in the dining room!) and bring all the hardware back to my desk. Yes, this makes my wife happy again. Copied over the Arduino files, and I am calling it good. Along the way, I got sidetracked by making some kitchen cabinet shelf brackets, but I hope to finish them up within a day or two.
 
Driver issues can be so annoying. I feel like your approach has worked for me in the past. I’ll be happy to see your progress with the ELS.
 
The reinstalling of the video drivers didn't quite do the trick. Had another shutdown, while posting to HM. How annoying! And discouraging.

This was after moving all the gear away from the RPI4 setup, back to my normal desk. What a pain in the neck.

Today my stepper kit should arrive. Would be nice to get it all going, but this laptop issue will take precedence. The laptop is my main computer, so having it dying with little notice needs to be addressed. So far have not been able to find any breadcrumbs in the journal file. Or at least I'm not recognizing what I see there.
 
The stepper kit arrived. Nothing remarkable about the kit, save for the fact that there's no instructions to hook it up, nor is a color code provided for the cable ends. Why do they do that? Gives them flexibility with wire color? It's not terribly difficult to ring out the wires, but jeepers, why make every one of your customers do this? Guess I will see if there is any information online.

What is interesting, is the size contrast between the NEMA-24 and the NEMA-11. Yes, that NEMA-24 is a lot bigger! I suspect I will have to restrain it for testing or it will vibrate itself right off my desk.
PXL_20220601_222231569.jpg
 
At least for my kit, the info was online.

Code:
Stepper Motor Connections

Pin   1   2   3   4
Motor A+  A-  B+  B-
Ext   BLK GRN RED BLU


Encoder Extension Cable

Pin   2   3     1   13  11  12
Enc   Vcc EGND  EA+ EA- EB+ EB-
Color RED WHT   BLK BLU YEL GRN
 
Got it wired up. Download the Teensy and off my laptop goes. Literally turned off. What a pain in the posterior. Once I back the system up, I am going to say goodbye to this distribution. What a lot of grief. Especially since it wasn't my fault. If I would have caused it, well I'd take my lumps, but this was the result of a standard update.

Well, let's see what happens anyways. Connected the Encoder rather than the simulator, and turned it. Nothing. Hmm, did I change the voltage switch on the power supply? Shut it down and set the switch to 115V. Powered up and hey the motor turns in response to the Encoder! Of course it is backwards, but that's fixable! The motor is louder than I expected. Much louder than the little NEMA-11. And a heck of a lot stronger. If I attempt to spin the Encoder, the motor starts torque walking across the desk. Despite the laptop issues, was an exciting day.
 
Back
Top