An Electronic Lead Screw controller using a Teensy 4.1

Two nights ago had a chance to work on the feed menu. It's not pretty, but both metric and imperial feeds are done, button select-able. Need to light up the selections, for better human interaction, but the values of N & D change based on which button is pressed. Pressing start will enable that feed.
PXL_20220703_224211603.jpgPXL_20220703_224237849.jpg
Imperial feed on left, (0.0025"), metric feed on right, (0.25mm). Might put a grid around the individual "buttons".
Of course, the calculations for N & D will change once I settle on the correct pulleys for the system. There is no difference between threading and feeding for the stepper algorithm, just different values of N and D.

At least something got done on this...
 
Inadvertently merged two screens processing together. This resulted in confusion which state the machine was in, feeding or threading. Will take a bit to unravel. When feeding is saved, I am not passing back "feeding" and the pitch to the main screen, and it should. Want the main screen to readout feeding or threading. If feeding the effective pitch is displayed with units, whereas if threading, and metric the pitch is shown, or TPI if imperial.

So I need to disentangle the two screens (menus). Up around 900 LOC for this display processing, it's getting a bit confusing, primarily due to it's length. Lots of scrolling to find the stuff I need!

In a bit of odd news, after emailing me that the TI board was going to be delayed for another month, Digikey, on the same day ships me a board! I was going to cancel the board, but they shipped it within 10 minutes of telling me it would be delayed a month! Didn't get a chance to cancel it. I have so much effort into my Teensy setup, I will try to return the TI board. If I can't return, I will sell it. At this point, can't see a reason to go with the Clough42 setup. It is nice and all, and more polished than mine, but honestly, I have engineered from scratch all the hard electronic parts.
 
Might want to hang onto that board awhile. Clough42 had a lot of experience with other hobby processors and specifically chose the TI board for processing power. I know I like my setup on PM-1340GT. It's never missed a beat. I've cut a lot of threads and made some heavy cuts but I have a higher powered servo than what he used.
 
Might want to hang onto that board awhile. Clough42 had a lot of experience with other hobby processors and specifically chose the TI board for processing power. I know I like my setup on PM-1340GT. It's never missed a beat. I've cut a lot of threads and made some heavy cuts but I have a higher powered servo than what he used.
Probably won't be keeping the TI dev board. It is large, and somewhat fragile to user abuse. At least that is what I seemed to read. People seemed to fry the boards, a lot more often than I'd expect.

I'm using a 600MHz Arm M7 processor with double precision floating point. It can be overclocked to 1GHz. At 600MHz, it handles 400,000 encoder interrupts per second, because I tested it that fast. It also has HW quadrature encoders. It is also small, 3 square inches, and $25 or so. Also has built in ethernet. The TI board is 90MHz. Not saying the TI board is bad, but there are now more powerful choices out there than when Clough42 was doing this. Not knocking him at all, he did a bang up job and has been a very good explainer. His videos on the subject have been quite informative. I didn't like the buttons and displays he used, which is partially why I rolled my own. Not being able to buy the TI board for 9 months, didn't help either!

I have a 4Nm closed loop stepper motor and controller, which I think is more torque than what James used. Should be sufficient. After I clear up these menus, it's back to designing brackets and pulleys and the fun puzzle of putting it all together. I'm sure there will be coding changes required to get it all to work, it's part of the process. My approach has not been plug and play, but it has been a fun thing to do.

Had everything been available to me at the time I was serious about an ELS, I probably would have gone with Clough42. But it wasn't. So this is what I have done instead. Knock on wood, it should work out fine.
 
Inadvertently merged two screens processing together. This resulted in confusion which state the machine was in, feeding or threading. Will take a bit to unravel. When feeding is saved, I am not passing back "feeding" and the pitch to the main screen, and it should. Want the main screen to readout feeding or threading. If feeding the effective pitch is displayed with units, whereas if threading, and metric the pitch is shown, or TPI if imperial.

So I need to disentangle the two screens (menus). Up around 900 LOC for this display processing, it's getting a bit confusing, primarily due to it's length. Lots of scrolling to find the stuff I need!

In a bit of odd news, after emailing me that the TI board was going to be delayed for another month, Digikey, on the same day ships me a board! I was going to cancel the board, but they shipped it within 10 minutes of telling me it would be delayed a month! Didn't get a chance to cancel it. I have so much effort into my Teensy setup, I will try to return the TI board. If I can't return, I will sell it. At this point, can't see a reason to go with the Clough42 setup. It is nice and all, and more polished than mine, but honestly, I have engineered from scratch all the hard electronic parts.
websockets + webpage... no flashing... easy to change... multiple views... event driven...
 
Frankly this might have happened using webpages. I'm also a lousy C programmer, although that's not the issue here.

If one doesn't think the pages and transitions through in advance, this is what happens. Won't be that hard to unravel once I diagram it all out. Simply hadn't thought through the feeding issues before I started plugging away. Was trying to sneak in some work on this while away from home.

This code needs some serious refactoring, as it's a bit messy. And I stink at programming. Nonetheless, will put some effort into that, as it will make the existing stuff simpler to follow.
 
Been on a short vacation. Back to this. My 1x4 and 2x2 weather pack connectors and seals came in, along with some AWG20 wire for the lathe DRO tee connnectors. I managed to get similar colors as in the harness. Also got some self fusing rubber tape. That should help me get the harness going. The next few days I will try to straighten out the menu problem. Since I am back home, I can use two monitors to do the coding, which helps a lot! The UI code is 1K LOC now, so it is tough to scroll about and find what I need in other sections. Two monitors makes that a lot easier.
 
Been trying to get back to this. I have found some inconsistencies in transition from state to state. Need to change that. Drew up some cartoons for myself to try to understand this better. Was flip flopping about with the number of states. Need to handle the states similarly, so there is some consistency in coding. This will help for later on, when I inevitably decide to add stuff in, like DRO handling. I have settled on 5 states. Initialization plus 4 menus.

There is an initialization state. After Initialization completes it transitions to the main menu. The only way to initialization is via power up, or perhaps some error checking.

Main menu: Has the current threading or feeding parameters, the RPM display, and optionally the DRO display. There are 3 buttons. Start enables the stepper, stop disables the stepper. Setup causes the transition to the Feed and Thread selection menu.

Feed or Thread Selection menu: The stepper is disabled. Touching Feed or Thread transitions to the appropriate menu. Quit transitions to Main menu. Save is disabled and grey.

Threading menu: The stepper is disabled. Touching Imperial or Metric populates the appropriate table on the display. If a thread is touched, the thread parameters are shown on the lower part of display. The selected thread (button) should be highlighted. The selection of a thread enables the Save button. Prior to selection, the Save button is greyed. If Save is touched, the values for tpi/pitch, ustep, N & D are updated. Then state transitions to the Main menu. Quit causes a transition to the Feed or Thread selection menu.

Feeding menu: The stepper is disabled. Touching Imperial or Metric populates the appropriate table on the display. If a feed is touched, the feed parameters are shown on the lower part of display. The selected feed (button) should be highlighted. The selection of a thread enables the Save button. Prior to selection, the Save button is greyed. If Save is touched, the values for tpi/pitch, ustep, N & D are updated. I need to handle the tpi/pitch differently than in the feed case. Feed is like a pitch. At the completion of the Save the state transitions to the Main menu. Quit causes a transition to the Feed or Thread selection menu.

File lengths got a bit out of control, so I cut and pasted sections of the long file into some additional files to reduce the size of the big file. It makes it easy to code and debug if each file is smaller. Figure it will take a week to sort this out and clean it up.
 
As I'm sure you know, getting those details cleaned up is the difference between a proof-of-concept and a usable system. Just takes a lot of time.
 
As I'm sure you know, getting those details cleaned up is the difference between a proof-of-concept and a usable system. Just takes a lot of time.
Yes, indeed. The devil is in those very details.

Had a working system for a while, then mucked it up. Why? Because I was ad hoc adding stuff, rather than having it thought out in the beginning. Before you know it, you box yourself in! So it was time to step back and think through the executive level stuff more fully. I have to pry some parts out and rearrange things, but it will get there...
 
Back
Top