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

Length, back and foward #222

Open
wants to merge 50 commits into
base: topics/clough42/multiConfigBuild
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
51786b1
Create experimental encoder simulator.
Sep 8, 2019
5515bd4
Drive encoder simulator from a table lookup.
Sep 8, 2019
2d4261c
Documentation images
Nov 6, 2019
2d311dd
Add image
Nov 7, 2019
7901b55
Update README.md
clough42 Nov 7, 2019
4cd08e5
Update README.md
clough42 Nov 7, 2019
114df49
Update README.md
clough42 Nov 7, 2019
0fafb14
More images
Nov 7, 2019
3629d1d
Merge branch 'master' of https://github.com/clough42/electronic-leads…
Nov 7, 2019
869d8b0
Rotate image
Nov 7, 2019
540bce6
Add support for ELS Boost V2 (#19)
clough42 Nov 30, 2019
425a6df
Incorporate #29 from carneeki: added two BSP threads, made 11.5 actua…
clough42 Nov 30, 2019
56efba7
Add additional comments to Configuration.h
clough42 Dec 1, 2019
adf633e
Update version number.
clough42 Dec 1, 2019
0837df2
Add configuration to use second encoder (EQEP2) (#46)
clough42 Jan 13, 2020
ecb358e
Update version number to 1.2.00.
clough42 Oct 5, 2020
3cbb415
Fix overflow caused by large metric threads. Suggested by hugosman65
clough42 Oct 5, 2020
5e3fac0
Slow down SPI bus (from 250Kbps to 98Kbps) to make it more noise-immune.
clough42 Oct 5, 2020
61619c8
Increase SPI timing delays slightly to make communication more robust.
clough42 Oct 6, 2020
9debd0b
Aggressively filter bad key input: require multiple consecutive read…
clough42 Oct 6, 2020
94ebec9
Do not allow changes to feed/thread, metric/imperial, forward/reverse…
clough42 Oct 6, 2020
1f81220
Add configuration option to ignore all keypresses (including up/down)…
clough42 Oct 6, 2020
9c6b3d0
Update README.md
clough42 Oct 7, 2020
e472a9c
Add images of the control panel kit
Oct 7, 2020
87e92a2
Update README.md
clough42 Oct 7, 2020
0d67cc3
Merge branch 'dev'
clough42 Oct 10, 2020
7711032
Make power button disable stepper drive and turn off control panel.
clough42 Oct 10, 2020
c956b26
Make power button disable stepper drive and turn off control panel. (…
clough42 Oct 10, 2020
f27ba92
Revert "Make power button disable stepper drive and turn off control …
clough42 Oct 10, 2020
72c75c6
Roll version to 1.3.00
clough42 Oct 10, 2020
a4cfe97
Manual merge of travistabbal's different stepper rates for feed and t…
clough42 Oct 10, 2020
050860d
Fix startup initialization so the stepper/servo will actually run.
clough42 Oct 10, 2020
1dc8510
Update version to 1.3.01.
clough42 Oct 11, 2020
0a10330
Change tachometer update to twice per second to reduce jitter. (#96)
clough42 Oct 11, 2020
a100633
Add continuity troubleshooting images.
clough42 Oct 11, 2020
f8f5a9c
Merge branch 'dev'
clough42 Oct 11, 2020
7031142
Merge branch 'master' of https://github.com/clough42/electronic-leads…
clough42 Oct 11, 2020
16c39ab
Update README.md
clough42 Oct 11, 2020
37415a0
Rename images
clough42 Oct 11, 2020
7a5f6fb
Merge branch 'master' of https://github.com/clough42/electronic-leads…
clough42 Oct 11, 2020
25d08d6
Panic stop with error message if stepper output backlog exceeds a con…
clough42 Feb 25, 2021
eef2418
Allow econst to span ram banks in debug mode.
clough42 Feb 25, 2021
84ab988
Roll version number to 1.4.00
clough42 Feb 25, 2021
adbd47f
Merge branch 'dev'
clough42 Feb 26, 2021
aaadffd
Update README.md
clough42 Feb 27, 2021
e4e413a
Add integrated servo wiring diagram
clough42 Oct 27, 2022
708cdb1
Switch to graphic of easy servo
clough42 Nov 29, 2022
4e2a791
Add Easy Servo Motor image
clough42 Nov 29, 2022
509486b
Add 200 icon for Easy Servo Motor
clough42 Nov 29, 2022
7f993ea
Create LaunchPad DIN Rail Mount.stl
clough42 Aug 1, 2024
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
Binary file added 3D Models/LaunchPad DIN Rail Mount.stl
Binary file not shown.
1 change: 1 addition & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pipeline {
stage('Import Projects') {
steps {
sh 'ccstudio -noSplash -data . -application com.ti.ccstudio.apps.projectImport -ccs.location els-f280049c || true'
sh 'ccstudio -noSplash -data . -application com.ti.ccstudio.apps.projectImport -ccs.location testfixture-f280049c || true'
}
}

Expand Down
72 changes: 56 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,74 @@
# Clough42 Lathe Electronic Leadscrew Controller

This is the firmware for an experimental lathe electronic leadscrew controller. The goal is to replace the change
This is the firmware for a 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.

![Silkscreened Control Panel](https://raw.githubusercontent.com/clough42/electronic-leadscrew/master/docs/images/CPKit.jpg)

## License and Disclaimer

This software is distributed under the terms of the MIT license. Read the entire
license statement [here](https://github.com/clough42/electronic-leadscrew/blob/master/LICENSE).

**Machine tools can be dangerous.** This is especially true of machine tools that can move by themselves
under the control of electronics and software. You are responsible for your own safety. Always assume
that something could fail and cause the machine to move unexpectedly. Keep clear of pinch points and
be ready to kill the power in an emergency.

## Latest Version

Version 1.4.00 adds the following features and fixes:
* Automatically detect if the ELS hits its max 100KHz step rate and fail safe
* Change the memory map to allow more thread and feed definitions

Version 1.3.01 added the following features and fixes:
* Fix phantom control panel button presses
* Add power button support
* Fix integer overflow for large metric threads
* Prevent mode and direction changes while running
* Smooth tachometer display
* Add support for lathes with separate feed and thread gearing

[DOWNLOAD HERE](https://github.com/clough42/electronic-leadscrew/releases)

## Project Status
Design and prototyping.
Beta.

**NOTE: This is still a work in progress and is subject to change. Many people have expressed interest in buying parts
and following along with the build. That's great! Just be aware that this hasn't been tested and refined end-to-end yet, so
things like stepper motors, servos, drivers, display boards are likely to change as the project progresses.**
**NOTE: This is still a work in progress and is subject to change. Hundreds of people all over the world have purchased parts
and built their own. That's great! I have had great success with mine, as have others. Building an ELS
for your lathe does require require basic electronics and troubleshooting skills, so keep that in mind if you decide to build one
yourself.**

## Current Concept
The project is still in the early stages of development. The current hardware looks like this:
## Documentation
For documentation, please [**VISIT THE PROJECT WIKI**](https://github.com/clough42/electronic-leadscrew/wiki).

## Concept
The project is still in active 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
* Use a standard stepper motor and driver on the lathe leadscrew
* Read the spindle position using a rotary encoder with a 3D-printed gear or belt drive
* Use a standard stepper motor (or servo) and driver on the lathe leadscrew
* 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)
The ELS firmware currently supports the following:
* Feeds in thousandths of an inch per revolution
* Feeds in hundredths of a millimeter per revolution
* Imperial thread pitches (in threads-per-inch)
* Metric thread pitches (in millimeters)
* Imperial and Metric lead screws
* Support for powering down the leadscrew while leaving the tachometer active
* Tachometer averaging (stabilization)

Items on the short list for future development:
* Support for dual-shaft lathes that have different drive ratios for feeding and threading
* Leadscrew speed limit warnings

## Future Goals
## Possible 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
Expand All @@ -42,7 +81,8 @@ set to almost any ratio. The lathe will continue to operate normally, with the
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:
If you want to get this running on your own LaunchXL-F280049C board, here are the settings you will need.
See the documentation at the link above for more details.

### Physical Switches
The LaunchXL-F280049C has a number of switches on the board to configure the GPIO and peripheral signal routing.
Expand Down
Binary file added docs/images/CPKit.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Continuity/LEDandKEY-Continuity.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Driver.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/ELSBoost.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/EasyServoMotor.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Encoder.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Icons200/CPKit.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Icons200/Driver.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Icons200/ELSBoost.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Icons200/EasyServoMotor.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Icons200/Encoder.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Icons200/LEDandKEY.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Icons200/LaunchPad.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Icons200/PowerSupply.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Icons200/ServoMotor.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Icons200/WallWart.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/IntegratedServoWiringDiagram.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/JumpersAndSwitches.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/LEDandKEY.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/LaunchPad.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/PowerSupply.jpg
Binary file added docs/images/ServoMotor.jpg
Binary file added docs/images/WallWart.jpg
Binary file added docs/images/WiringDiagram.JPG
6 changes: 3 additions & 3 deletions els-f280049c/28004x_generic_ram_lnk.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ SECTIONS
.reset : > RESET, PAGE = 0, TYPE = DSECT /* not used, */

.stack : > RAMM1, PAGE = 1
.ebss : > RAMLS5, PAGE = 1
.econst : > RAMLS5, PAGE = 1
.esysmem : > RAMLS5, PAGE = 1
.ebss : > RAMLS5|RAMLS6, PAGE = 1
.econst : >> RAMLS5|RAMLS6, PAGE = 1
.esysmem : > RAMLS5|RAMLS6, PAGE = 1

ramgs0 : > RAMGS0, PAGE = 1
ramgs1 : > RAMGS1, PAGE = 1
Expand Down
66 changes: 63 additions & 3 deletions els-f280049c/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,23 @@
// Define the number of steps and microsteps for your stepper motor, the pin
// polarity of the driver, and whether to use additional features, like servo
// alarm feedback.
//
// NOTE: If you are using a servo drive with something other than a 1:1 drive
// ratio, you can use the STEPPER_MICROSTEPS to compensate. For example, if you
// have a servo configured for 1000 steps/revolution and it drives the leadscrew
// through a 3:1 reduction, you can set STEPPER_RESOLUTION to 1000 and
// STEPPER_MICROSTEPS to 3.
//================================================================================

// Steps and microsteps
#define STEPPER_MICROSTEPS 8
#define STEPPER_RESOLUTION 200

// Separate step and microstep settings for feed rates. Redefine these if your
// lathe has a separate feed drive train with a different ratio.
#define STEPPER_MICROSTEPS_FEED STEPPER_MICROSTEPS
#define STEPPER_RESOLUTION_FEED STEPPER_RESOLUTION

// Step, direction and enable pins are normally active-high
// #define INVERT_STEP_PIN true
// #define INVERT_DIRECTION_PIN true
Expand All @@ -78,9 +89,19 @@
//
// Define the type of encoder you are using on the spindle. The firmware assumes
// the encoder is turning at a 1:1 ratio with the spindle.
//
// NOTE: the firmware is concerned with the quadrature edge count, which is
// four times the number of pulses. For example, if you have a 1024 P/R
// encoder, you need to enter 4096 here.
//================================================================================

// Encoder resolution (counts per revolution)
#define ENCODER_RESOLUTION 4096

// Which encoder input to use
#define ENCODER_USE_EQEP1
//#define ENCODER_USE_EQEP2




Expand All @@ -97,6 +118,47 @@



//================================================================================
// HARDWARE
//
// Define which hardware you're using:
//
// 1 - LaunchXL F280049C with ELS BoostXL v1
// 2 - LaunchXL F280049C with ELS BoostXL v2
//================================================================================

// See hardware version table above
#define HARDWARE_VERSION 2




//================================================================================
// FEATURES
//
// Additional features that can be enabled for your configuration.
//================================================================================

// Ignore all key presses when the machine is running. Normally, only the mode
// and direction keys are ignored.
//#define IGNORE_ALL_KEYS_WHEN_RUNNING




//================================================================================
// VALIDATION/TRIP
//
// Validation thresholds and automatic trip behavior.
//================================================================================

// Maximum number of buffered steps
// The ELS can only output steps at approximately 100KHz. If you ask the ELS to
// output steps faster than this, it will get behind and will stop automatically
// when the buffered step count exceeds this value.
#define MAX_BUFFERED_STEPS 100


//================================================================================
// CPU / TIMING
//
Expand All @@ -112,13 +174,11 @@
#define UI_REFRESH_RATE_HZ 100

// RPM recalculation rate, in Hz
#define RPM_CALC_RATE_HZ 10
#define RPM_CALC_RATE_HZ 2

// Microprocessor system clock
#define CPU_CLOCK_MHZ 100
#define CPU_CLOCK_HZ (CPU_CLOCK_MHZ * 1000000)




#endif // __CONFIGURATION_H
53 changes: 49 additions & 4 deletions els-f280049c/ControlPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@
#include "ControlPanel.h"

// Time delay to allow CS (STB) line to reach high state and be registered
#define CS_RISE_TIME_US 5
#define CS_RISE_TIME_US 10

// Time delay after sending read command, before clocking in data
#define DELAY_BEFORE_READING_US 1
#define DELAY_BEFORE_READING_US 3

// Number of times a key state must be read consecutively to be considered stable
#define MIN_CONSECUTIVE_READS 3


// Lower the TM1638 CS (STB) line
Expand All @@ -47,6 +50,8 @@ ControlPanel :: ControlPanel(SPIBus *spiBus)
this->value = NULL;
this->leds.all = 0;
this->keys.all = 0;
this->stableKeys.all = 0;
this->stableCount = 0;
this->message = NULL;
this->brightness = 3;
}
Expand Down Expand Up @@ -236,13 +241,53 @@ KEY_REG ControlPanel :: getKeys()
configureSpiBus();

newKeys = readKeys();
if( newKeys.all != this->keys.all ) {
if( isValidKeyState(newKeys) && isStable(newKeys) && newKeys.all != this->keys.all ) {
KEY_REG previousKeys = this->keys; // remember the previous stable value
this->keys = newKeys;
return newKeys;

if( previousKeys.all == 0 ) { // only act if the previous stable value was no keys pressed
return newKeys;
}
}
return noKeys;
}

bool ControlPanel :: isValidKeyState(KEY_REG testKeys) {
// filter out any states with multiple keys pressed (bad communication filter)
switch(testKeys.all) {
case 0:
case 1 << 0:
case 1 << 2:
case 1 << 3:
case 1 << 4:
case 1 << 5:
case 1 << 6:
case 1 << 7:
return true;
}

return false;
}


bool ControlPanel :: isStable(KEY_REG testKeys) {
// don't trust any read key state until we've seen it multiple times consecutively (noise filter)
if( testKeys.all != stableKeys.all )
{
this->stableKeys = testKeys;
this->stableCount = 1;
}
else
{
if( this->stableCount < MIN_CONSECUTIVE_READS )
{
this->stableCount++;
}
}

return this->stableCount >= MIN_CONSECUTIVE_READS;
}

void ControlPanel :: setMessage( const Uint16 *message )
{
this->message = message;
Expand Down
6 changes: 6 additions & 0 deletions els-f280049c/ControlPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ class ControlPanel
// current key states
KEY_REG keys;

// number of times current key state has been seen
KEY_REG stableKeys;
Uint16 stableCount;

// current override message, or NULL if none
const Uint16 *message;

Expand All @@ -159,6 +163,8 @@ class ControlPanel
Uint16 reverse_byte(Uint16 x);
void initSpi();
void configureSpiBus(void);
bool isValidKeyState(KEY_REG);
bool isStable(KEY_REG);

public:
ControlPanel(SPIBus *spiBus);
Expand Down
7 changes: 7 additions & 0 deletions els-f280049c/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Core :: Core( Encoder *encoder, StepperDrive *stepperDrive )
this->previousSpindlePosition = 0;
this->previousFeedDirection = 0;
this->previousFeed = NULL;

this->powerOn = true; // default to power on
}

void Core :: setReverse(bool reverse)
Expand All @@ -54,6 +56,11 @@ void Core :: setReverse(bool reverse)
}
}

void Core :: setPowerOn(bool powerOn)
{
this->powerOn = powerOn;
this->stepperDrive->setEnabled(powerOn);
}



Expand Down
10 changes: 10 additions & 0 deletions els-f280049c/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class Core

int32 feedRatio(Uint32 count);

bool powerOn;

public:
Core( Encoder *encoder, StepperDrive *stepperDrive );

Expand All @@ -62,6 +64,9 @@ class Core
Uint16 getRPM(void);
bool isAlarm();

bool isPowerOn();
void setPowerOn(bool);

void ISR( void );
};

Expand All @@ -84,6 +89,11 @@ inline bool Core :: isAlarm()
return this->stepperDrive->isAlarm();
}

inline bool Core :: isPowerOn()
{
return this->powerOn;
}

inline int32 Core :: feedRatio(Uint32 count)
{
#ifdef USE_FLOATING_POINT
Expand Down
Loading