Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leadscrew speed warnings, hook up power button #54

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 25 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
# Clough42 Lathe Electronic Leadscrew Controller
# Fork of Cloug42 Lathe Electronic Leadscrew Controller

This is the firmware for an experimental lathe electronic leadscrew controller. The goal is to replace the change
gears or gearbox on a metalworking lathe with a stepper motor controlled electronically based on an encoder on the
lathe spindle. The electronic controller allows setting different virtual gear ratios for feeds and threading.

## Fork Status

This is a fork of the original project. The display has been replaced with a Nextion color LCD + touch screen to
allow for a better UI. Most of the hardware interface code on the microcontroller has also been re-written to use
Ti's latest libraries and recommendations (and it makes for easier to read and modify code).

This is an early drop and has bugs, but I've been using it for months on my own system.

Future plans:
* Read DRO input over serial to provide virtual compound angle feature. This is helpful on lathes where the
compound has been removed and replaced by a stouter toolpost mount.
* Threading mode
* Turning mode with a fixed stop point

The documentation below is only lightly edited from Clough42's version.

## Project Status
Design and prototyping.

Expand All @@ -17,54 +33,27 @@ For documentation, please [**visit the project wiki**](https://github.com/clough
## Current Concept
The project is still in the early stages of development. The current hardware looks like this:
* Use a TI F280049C Piccolo microcontroller on a LaunchXL prototyping board
* Use an inexpensive SPI "LED&Key" import display and keypad for the user interface
* Read the spindle position using a rotary encoder with a 3D-printed gear
* Read the spindle position using a rotary encoder
* Use a standard stepper motor and driver on the lathe leadscrew
* Use a simple control interface
* Make as few modifications to the lathe as possible:
* Use the original leadscrew and halfnuts without machining
* Drive the leadscrew through the factory input shaft
* Drive the encoder from the factory spindle gear train
* Make it easy to restore the lathe to the original change gear configuration

The current plan is to support the following operations:
* Multiple feeds in thousandths of an inch per revolution
* Multiple feeds in hundredths of a millimeter per revolution
* Multiple imperial thread pitches (in threads-per-inch)
* Multiple metric thread pitches (in millimeters)

## Future Goals
While this project is starting out as a simple gearbox replacement, some features seem attractive, even for
that simple case:
* Threading/feeding up to a hard shoulder with automatic stop
* Automatic recall and resync with hybrid threads (e.g. metric threads on an imperial leadscrew)

## Non-Goals
This is not a CNC project. The goal is not to control the lathe automatically, but rather to transparently
replace the lathe change gears or quick-change gearbox with an electronic virtual gearbox that can be quickly
set to almost any ratio. The lathe will continue to operate normally, with the operator closing and opening
the half-nuts to control feeding and threading.

## Hardware Configuration
If you want to get this running on your own LaunchXL-F280049C board, here are the settings you will need:

### Physical Switches
The LaunchXL-F280049C has a number of switches on the board to configure the GPIO and peripheral signal routing.
This provides lots of flexibility for different uses of the board, but it means that you will have to change
some of the switches from their defaults in order to use the GPIO pins and eQEP periperals.

These are the required switch settings
* `S3.1 = 0` Connects eQEP1 to J12
* `S3.2 = 0` Connects eQEP2 to J13
* `S4 = 1` Connects eQEP1 to J12
* `S9 = 1` (default) -- Connects GPIO32/33 to BoosterPack site 2 pins

S6 and S8 can be in any position. 0 is the default.

### External Connections
The firmware assumes the following pins are connected externally.

> NOTE: the silkscreen on the LaunchXL-F280049C board has the labels for J6 and J8
> swapped. J6 is the header closest to the edge of the board.
#### Serial Port to Nextion Display
The serial is mapped to the microcontrollers Serial Port B
* GPIO40 is pin 3 and SCIBRX
* GPIO13 is pin 4 and SCIBTX

#### Encoder
A quadrature encoder for the spindle is connected to the eQEP connector, J12.
Expand All @@ -76,17 +65,5 @@ A Step-direction stepper motor driver should be connected to the following GPIO
* `GPIO6` (J8 pin 78) - Enable
* `GPIO7` (J8 pin 77) - Alarm input

#### Control Panel
The LED&KEY control panel board **must be connected through a bidirectional level converter**, since
it is a 5V device, and the TI microcontroller is a 3.3V device. A standard BSS138-based converter works
well.
* `GPIO24` (J6 pin 55) - DIO
* `GPIO32` (J8 pin 71) - CLK
* `GPIO33` (J6 pin 53) - STB (chip select)

#### Debugging Outputs
In addition to the control wires for the hardware, the firmware also outputs signals on two additional
GPIO pins to allow timing of the interrupt and loop routines. An oscilloscope or logic analyzer may be
connected to these pins to debug and time the ISR routines:
* `GPIO2` (J8 pin 76) - Main state machine ISR
* `GPIO3` (J8 pin 75) - Secondary control panel loop
#### SCI Bus
SCI Bus is no longer used (that went to the control panel on Clough42's version)
8 changes: 4 additions & 4 deletions els-f280049c/.cproject
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
<option id="com.ti.ccstudio.buildDefinitions.C2000_18.12.compilerID.DISPLAY_ERROR_NUMBER.318753746" name="Emit diagnostic identifier numbers (--display_error_number, -pden)" superClass="com.ti.ccstudio.buildDefinitions.C2000_18.12.compilerID.DISPLAY_ERROR_NUMBER" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_18.12.compilerID.DIAG_WRAP.650025148" name="Wrap diagnostic messages (--diag_wrap)" superClass="com.ti.ccstudio.buildDefinitions.C2000_18.12.compilerID.DIAG_WRAP" useByScannerDiscovery="false" value="com.ti.ccstudio.buildDefinitions.C2000_18.12.compilerID.DIAG_WRAP.off" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.C2000_18.12.compilerID.INCLUDE_PATH.1797448346" name="Add dir to #include search path (--include_path, -I)" superClass="com.ti.ccstudio.buildDefinitions.C2000_18.12.compilerID.INCLUDE_PATH" valueType="includePath">
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/device}"/>
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/device/driverlib}"/>
<listOptionValue builtIn="false" value="${PROJECT_ROOT}"/>
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/device_support_f28004x/common/include}"/>
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/device_support_f28004x/headers/include}"/>
<listOptionValue builtIn="false" value="${CG_TOOL_ROOT}/include"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.C2000_18.12.compilerID.ABI.953458610" name="Application binary interface [See 'General' page to edit] (--abi)" superClass="com.ti.ccstudio.buildDefinitions.C2000_18.12.compilerID.ABI" useByScannerDiscovery="false" value="com.ti.ccstudio.buildDefinitions.C2000_18.12.compilerID.ABI.coffabi" valueType="enumerated"/>
Expand Down Expand Up @@ -126,9 +126,9 @@
<option id="com.ti.ccstudio.buildDefinitions.C2000_18.12.compilerID.DISPLAY_ERROR_NUMBER.1844332943" name="Emit diagnostic identifier numbers (--display_error_number, -pden)" superClass="com.ti.ccstudio.buildDefinitions.C2000_18.12.compilerID.DISPLAY_ERROR_NUMBER" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_18.12.compilerID.DIAG_WRAP.436543125" name="Wrap diagnostic messages (--diag_wrap)" superClass="com.ti.ccstudio.buildDefinitions.C2000_18.12.compilerID.DIAG_WRAP" useByScannerDiscovery="false" value="com.ti.ccstudio.buildDefinitions.C2000_18.12.compilerID.DIAG_WRAP.off" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.C2000_18.12.compilerID.INCLUDE_PATH.1711216731" name="Add dir to #include search path (--include_path, -I)" superClass="com.ti.ccstudio.buildDefinitions.C2000_18.12.compilerID.INCLUDE_PATH" valueType="includePath">
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/device}"/>
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/device/driverlib}"/>
<listOptionValue builtIn="false" value="${PROJECT_ROOT}"/>
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/device_support_f28004x/common/include}"/>
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/device_support_f28004x/headers/include}"/>
<listOptionValue builtIn="false" value="${CG_TOOL_ROOT}/include"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.C2000_18.12.compilerID.ABI.1932552368" name="Application binary interface [See 'General' page to edit] (--abi)" superClass="com.ti.ccstudio.buildDefinitions.C2000_18.12.compilerID.ABI" useByScannerDiscovery="false" value="com.ti.ccstudio.buildDefinitions.C2000_18.12.compilerID.ABI.coffabi" valueType="enumerated"/>
Expand Down
8 changes: 8 additions & 0 deletions els-f280049c/.settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
eclipse.preferences.version=1
encoding//Debug/device/driverlib/subdir_rules.mk=UTF-8
encoding//Debug/device/driverlib/subdir_vars.mk=UTF-8
encoding//Debug/device/subdir_rules.mk=UTF-8
encoding//Debug/device/subdir_vars.mk=UTF-8
encoding//Debug/device_support_f28004x/common/source/subdir_rules.mk=UTF-8
encoding//Debug/device_support_f28004x/common/source/subdir_vars.mk=UTF-8
encoding//Debug/device_support_f28004x/headers/cmd/subdir_rules.mk=UTF-8
Expand All @@ -10,6 +14,10 @@ encoding//Debug/objects.mk=UTF-8
encoding//Debug/sources.mk=UTF-8
encoding//Debug/subdir_rules.mk=UTF-8
encoding//Debug/subdir_vars.mk=UTF-8
encoding//Release/device/driverlib/subdir_rules.mk=UTF-8
encoding//Release/device/driverlib/subdir_vars.mk=UTF-8
encoding//Release/device/subdir_rules.mk=UTF-8
encoding//Release/device/subdir_vars.mk=UTF-8
encoding//Release/device_support_f28004x/common/source/subdir_rules.mk=UTF-8
encoding//Release/device_support_f28004x/common/source/subdir_vars.mk=UTF-8
encoding//Release/device_support_f28004x/headers/cmd/subdir_rules.mk=UTF-8
Expand Down
18 changes: 14 additions & 4 deletions els-f280049c/Configuration.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Electronic Leadscrew
// https://github.com/alexphredorg/electronic-leadscrew
//
// Copyright (c) 2020 Alex Wetmore
//
// Derived from:
// Clough42 Electronic Leadscrew
// https://github.com/clough42/electronic-leadscrew
//
Expand Down Expand Up @@ -27,6 +33,7 @@
#ifndef __CONFIGURATION_H
#define __CONFIGURATION_H

#include "els.h"



Expand Down Expand Up @@ -64,12 +71,12 @@
//================================================================================

// Steps and microsteps
#define STEPPER_MICROSTEPS 8
#define STEPPER_RESOLUTION 200
#define STEPPER_MICROSTEPS 4 // 4:1 belt drive ratio
#define STEPPER_RESOLUTION 1600 // default resolution on our system

// Step, direction and enable pins are normally active-high
// #define INVERT_STEP_PIN true
// #define INVERT_DIRECTION_PIN true
#define INVERT_DIRECTION_PIN true
#define INVERT_ENABLE_PIN true
#define INVERT_ALARM_PIN true

Expand All @@ -91,7 +98,7 @@
//================================================================================

// Encoder resolution (counts per revolution)
#define ENCODER_RESOLUTION 4096
#define ENCODER_RESOLUTION 1440 // 360 p/r

// Which encoder input to use
#define ENCODER_USE_EQEP1
Expand Down Expand Up @@ -147,5 +154,8 @@
#define CPU_CLOCK_MHZ 100
#define CPU_CLOCK_HZ (CPU_CLOCK_MHZ * 1000000)

// Warning and shutoff levels for stepper speeds
#define STEPPER_WARNING_RPM 300
#define STEPPER_SHUTOFF_RPM 500

#endif // __CONFIGURATION_H
Loading