Nextion Touchscreen for Clough42 Electronic Leadscrew

Nextion Touchscreen for Clough42 Electronic Leadscrew

Summary

A Clough42 electronic leadscrew is enhanced with a Nextion touchscreen and a carriage mounted feed-stop switch. The original functionality is maintained including the seven-segment display. The improvements are demoed, the Clough42 ELS hardware is reviewed, and the software changes are summarized. The Nextion changes are available on GitHub and will become a pull request for consideration to the main repository.

Available as a GitHub fork, feature-nextion branch.

Introduction

The leadscrew of a lathe synchronizes feed to the spindle and is necessary for consistent turning and threading. Most lathes use a mechanical method for synchronization with limited thread pitch options or be inconvenient to change, like on my SouthBend lathe that requires exchanging gears. An electronic leadscrew solves these problems by driving the leadscrew with a motor at a speed controlled by software that is simultaneously monitoring the spindle speed. With software in control, any gear ratio is immediately possible.

My friend, James Weber, for his lathe, purchased a Clough42, but James wanted a touchscreen interface and a carriage mounted limit switch to stop feed. Luckily, the Clough42 ELS has open source software and that started this project began.

Review of Clough32 ELS hardware

The Clough32 ELS is an assembly of a TI LaunchPad evaluation board, seven-segment display, and a custom board for convenient wiring, power regulation, level conversion, and an EEPROM for saving settings.

The custom board is sold for $20 plus shipping and thru hole assembly required. That seems reasonable. Connectors can especially add to the total cost. My hunch is a that a much more of the development time went into the software.

The standard ELS uses a seven-segment display with the push buttons. The display is inexpensive, but much of the ELS code is for supporting the display, but maybe that could be simplified. An additional $25 is charged for the display plus cover. There might be other related parts sold on eBay.

Suggestions for hardware improvements

  • The ELS board could extend a little further to connect to the LaunchPad’s encoder pins and provide screw terminal headers for the encoder wires.
  • To add support for the touch screen and limit switch, I’ll need a UART and one GPIO. The ELS board covers headers with access to a UART and GPIO and could provide headers to both and optoisolation to the sensor.
  • Use optocouplers instead of FETs to add some protection and to support 24v limit limit switches.
  • Settings could be stored in LaunchPad’s nonvolatile memory, eliminating the need for the EEPROM on the ELS. As of today, eBay shows at least 850 have been sold, so saving twenty to thirty cents from the BOM adds up.

Adding a Nextion touchscreen

Verifying electrical compatibility

Nextion requires 5v power and uses 3.3v TTL serial (which is 5v tolerant).

The TI LaunchPad has two serial UARTS. GPIO 28 and 29 (J5) are covered by but not used by the ELS. The existing display uses the SPI interface, pins 72-75 (J6). An updated ELS board could add headers to simplify connecting a Nextion display. Possibly jumpers to switch between the SPI and SCI interfaces and reuse the same level converting FETs (is that what’s being used) and headers.

Ideas for improvements

  • Add state information to the nextion_read(…) function allowing it to read from the Nextion, tokenizing until a valid packet is received, and then parse the packet. Now, each pass through nextion_loop is assumed to be able to read a complete packet, if one is available, and this generally works. The LaunchPad’s 16-byte deep send and receive FIFOs might be helping to make this more likely to work, but allowing the receipt of a packet to span multiple calls to nextion_loop(…) would more robust.
  • Use interrupts to improve performance of receiving of the messages from the Nextion.
  • Update the Nextion display to use nicer looking screens. Two static graphics could be used as screens: one where the buttons are not pressed and another with the buttons pressed. The Nextion UI elements would still be used, but made transparent so that the graphics are shown instead of the current solid elements.
  • Eliminate the seven-segment display and SPI support code and commit to the Nextion display. This would greatly simplify the code and create space to implement nice features including typing in a desired pitch or choosing from from a material or thread aware list. Currently, only a few feeds and pitches are available and hardcoded into a lookup table. These could be easily calculated.
  • Use the Control Law Accelerator (CLA), the co-processor of the main processor, to generate step pulses. Currently step generation is done in an interrupt service routine with bit banging, and ignores the need for motors to accelerate. During testing, fast direction changes and starts caused a closed-loop stepper motor to frequently fault. With open-loop stepper motors, one would have no idea that many pulses from the ELS where lost. Different ways to fix this, but a good start would be to improve the step generator to have a physics aware profile or control loop.

Video chapters

A video was made summarizing and demoing the project. Below are the chapters of the vide.

  • 00:00 – Introduction
  • 01:12 – Making an electronic leadscrew
  • 02:30 – Clough42 ELS hardware review
  • 03:06 – Demonstration of changes
  • 04:48– Disaster
  • 05:57 – Potential improvements
  • 07:45 – Summary of software changes
  • 12:44 – Closing

References

Full notes for this project are available on Notion.

Parts that I used (Amazon Affiliate links) Nextion NX8048K050 touchscreen:

Clough42’s first video from his ELS series.

TI LaunchPad LAUNCHXL-F280049C

Purchase product

TMS320F28004x Microcontroller

Datasheet

Technical reference manual

TI C2000 Forum

https://e2e.ti.com/support/microcontrollers/c2000/f/171

Clough42 Electronic Leadscrew Interface PC Board

https://github.com/clough42/electronic-leadscrew

https://github.com/clough42/electronic-leadscrew/wiki

Inspirational commercial unit

http://www.babinmachine.com/index.php?HLVELECLEAD

HSS86 stepper motor driver

https://www.jmc-motor.com/file/1806081666.pdf

http://cncdrive.com/datasheets/2HSS86H.pdf

Seven-segment display

Uses a TM1638 interface chip and costs ~$10

https://cdn.shopify.com/s/files/1/2386/9605/files/tm1638.pdf?8132892906594134473

https://pmdway.com/products/tm1638-numeric-display-led-input-board

From https://medium.com/@circuit4us/write-spin-code-for-tm1637-and-tm1638-part-i-f5568d2fe05b:

But TM1638 adopts a SPI-like signal interface. Again it’s SPI-like, because the standard SPI MISO and MOSI lines are combined into one bi-directional DIO line. Since there is no START, END signaling, the digital signals become a lot simpler.

This Post Has One Comment

Comments are closed.