An Electronic Lead Screw controller using a Teensy 4.1

WobblyHand

H-M Supporter - Diamond Member
H-M Lifetime Diamond Member
Joined
Dec 18, 2019
Messages
6,426
Been reading about an ELS quite a bit. It seems the TI controller board is out of stock, and has been for at least six months. The Teensy 4.1 processor seems to have the guts and software support to be able to pull this off. So this is a thread where I start looking at this. Think I will look at Clough42's implementation and adopt some of it into my version of an ELS.

Towards that end, I have purchased a Teensy 4.1 and a little adapter board with screw terminals. In the beginning I expect to flounder about learning the platform, but that's kind of how it is starting on a new device. Think I will integrate a small 3 inch touch display to control this, rather than the traditional LED and push button board. I have used an ILI9341 before, so I will try it for the display. Making the display look ok is kind of a task in of itself, but it is doable. If someone knows of a repo where someone has done a Teensy ELS, with a display, let me know. No point of re-inventing the wheel. Haven't started the repo search in earnest, but a preliminary look doesn't show anything obvious.

How easy this will be without ICE (in circuit emulation) is an open question. But, hey, I'm a glutton for punishment. This is obviously not going to be a quick project, as I will have to do a lot of learning along the way. Based on a complex arduino project (a doppler radar chronometer) I finished a couple of years ago, I expect something working in maybe 3-4 months, but not really working well until maybe 6-8 months. At least this time I will be able to reuse some of my display code. Maybe I will get it working by the time the TI boards are available again - or not. Won't know until I try.
 
I can say I started it. Hah, one thing out of the 1500+ things to do. Soldered together the screw terminal board for the Teensy 4.1.
PXL_20220501_210948118.jpg
Those are tiny screwheads! My 2 mm wide screwdriver blade is a little too big. I used 2 mm standoffs at the four corners. The 2mm screws barely made it through the holes. Quite a contrast between this little board, and the stepper motors and pulleys.
 
Have you looked at @greenail's ELS version? He took a different approach which provides more versatility. The thread is a long one but I believe his real work starts around page 47. https://www.hobby-machinist.com/threads/electronic-lead-screw.76101/page-47
I did see this. Believe he is using an ESP32 and a bluetooth? connection to a phone. Looked into that a while back (phone app) and found it a bit over my head - or more accurately, it seemed like a very steep barrier of entry. A simple display is good enough for me. I'm looking to make a utilitarian appliance - one that just works. If I get a new phone, I don't want to learn how to get the display app to work again to use my lathe - that is just too geeky for me.

My doppler chronometer rendered radar information on an ILI9341 touch display. The "live" FFT data from the radar as well as detected targets was displayed. (Detected airgun pellets being fired using an X-band door opener radar and a custom analog front end I designed.) The display running over SPI is too slow to update in real time, (50 Hz) but the background target detection (radar processing) runs in real time continuously, so no firing is ever missed. When there is a detection, the display updates with the FFT display (in dBs) and the target speed is displayed in either meters per second or feet per second. 1K complex floating point FFTs running continuously at a 50Hz rate, and target detection using an Arm M4 arduino chip. ADC was serviced by DMA and never stopped. The Teensy 4.1 has an Arm M7 which is a lot more capable than the M4 so I don't think I will run out of compute power.

I'll take a look at greenail's repo and see what is there. Could be very instructive, so it is well worth a look. Since I've ordered a pair of Teensy's I will use one for something. If I have to add bluetooth or wifi, there are many options available.
 
I think your Teensy4.1 will be totally up to the task. You can do a lot with a 600MHz RISC chip, especially when it has a built-in FPU and DSP hardware. Not sure if it will work for your application, but the chip has a FlexIO I/O block that can be configured for specialized (and high speed) tasks that might load down the main processor if implemented in S/W.

A lot of folks on the PJRC forum are pretty knowledgable, good to know if you run into problems on your project.
 
I think your Teensy4.1 will be totally up to the task. You can do a lot with a 600MHz RISC chip, especially when it has a built-in FPU and DSP hardware. Not sure if it will work for your application, but the chip has a FlexIO I/O block that can be configured for specialized (and high speed) tasks that might load down the main processor if implemented in S/W.

A lot of folks on the PJRC forum are pretty knowledgable, good to know if you run into problems on your project.
Have spent some time on PJRC recently. Having never used the Teensy expect there will be a learning curve. First order of business is to find a copy of the processor docs. I think there's a quadrature sensor decoder in hardware, which should help.

I cloned the Clough42, and greenail repos and also the Teensy Stepper driver. Been poking through some of the code.

Next is to install the latest Arduino, guess it is at 1.8.19 now. I have been using 1.8.13. Have already downloaded Teensyduino. Hope the updates won't bust my old code. I'd hate to debug my radar code again.
 
The Teensy is an excellent choice for an ELS. I'm leaning toward a Pi Pico, using one core for the realtime and one for the user interface. But the Teensy can easily handle this. I also prefer a graphical display for flexibility rather than the $2 LED/Button boards that many are using, but I'm leaning toward non-touch and using a rotary encoder and a couple of switches for the interface. Variations on the theme. Will be interested in your progress. I've collected encoder and have a motor but have not done much more than basic planning. I do have a solid algorithm for rotary encoders that I have used in the past (in fact with Teensy 2). This is not a high speed encoder application so many things can work, the quadrature hardware can be used but is not needed.
 
PJRC has a link to the processor datasheet near the bottom of their (long) web page for the T4.1.

The schematic, also on the same page, is useful because it shows the relationship between the processor's I/O groups and the T4.1 pinouts. Some of the I/O functions are, naturally, dedicated to things like the USB and Ethernet interfaces, along with flash memory and so on -- so some of the I/O groups aren't going to be fully available. And some just aren't wired up, period. I found this when looking at using the FlexIO stuff for driving a linear CCD (part of a long back-burnered spectrometer project).
 
Bought an encoder, basically the one Clough42 used. Also bought a small inexpensive stepper motor and driver for playing with and getting a feeling for the control aspects without using beefy hardware. Not sure exactly what size stepper to get yet for my G0752Z/G0602, but leaning towards a 577 oz-in NEMA24 unit. This is a little bigger than the recommended one, but most of the comments I have read indicate that some of the builders who used the smaller NEMA23 stepper desired a little more margin. The NEMA34 steppers are quite big, so would like to avoid them, since it would be hard to mount them to the lathe and not be in the way.

I found a NEMA24 kit at steppers online that seems like it would work, but I would rather investigate all the options before buying. Rather buy the motor and driver just once as they seem to be the expensive bits of the system.
 
Haven't read through the thread the whole way, but wanted to chime in that I'm actively using the Teensy 4.1 for projects and happy to help if I can.

The Teensy 4.1 is wicked fast, although it is limited to 3.3V. Level shifters are a great solution, but consider a Teensy 3.2 which is 5V tolerant if you don't need 60MHz.

The PJRC forum for the teensy is invaluable for deep technical discussions. I highly recommend getting involved there.

Since you're working with encoders, be aware that the Teensy (specifically the 4.x but likely all of them) have hardware quadrature counters. This is great for keeping up with an encoder without devoting the processor time to sample each edge transition.
 
Back
Top