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

Configuration for G0709 in ASW8 with iSV57T-180 servo #270

Draft
wants to merge 36 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ebf025f
Added custom threads.
kwackers Sep 15, 2022
7793568
Update README.md
kwackers Sep 15, 2022
3c6db59
Update README.md
kwackers Sep 15, 2022
c2f1517
Update README.md
kwackers Sep 15, 2022
a842a5a
Added electronic 'backlash' to remove any stepper noise when stationary
kwackers Sep 15, 2022
a135bb9
Default metric startup
kwackers Sep 15, 2022
3f6e9eb
Missing define!
kwackers Sep 15, 2022
c2ee626
Prefer no blanks in metric values so replaced with zeros.
kwackers Sep 15, 2022
4bb73bf
Prefer default to power off
kwackers Sep 15, 2022
2cc762b
Basic thread to shoulder working.
kwackers Sep 21, 2022
ca3463d
Basic functionality working.
kwackers Oct 7, 2022
4087fa9
Definitely works now...
kwackers Oct 15, 2022
cccd20b
Remove debug
kwackers Oct 15, 2022
75ee2cc
Some tidying, add acceleration for retraction, max motor speed for re…
kwackers Oct 16, 2022
8078898
Fix for retract ending early.
kwackers Oct 16, 2022
ceac561
Feed resolution makes more sense for most folk if it's set to the sam…
kwackers Oct 16, 2022
941d133
Add 2 character 'mode' prefix (visible at 0 rpm). PWR exits custom th…
kwackers Oct 17, 2022
1f6252d
Update README.md
kwackers Oct 17, 2022
da1990e
Make enable line reflect power setting on initial power up. (Initial …
kwackers Oct 17, 2022
c8bb7b0
Merge branch 'master' of https://github.com/kwackers/electronic-leads…
kwackers Oct 17, 2022
f8a6763
Allow + & - buttons to change brightness in power off state.
kwackers Oct 17, 2022
28485a6
Multistart threads, 1st pass (has bug whereby holdAtShoulder is relea…
kwackers Oct 24, 2022
a62146d
Working on bench.
kwackers Oct 24, 2022
723c105
Safe initial value for leadscrew RPM
kwackers Oct 24, 2022
018d395
Bump the version number to 1.6 for multistart threads.
kwackers Oct 24, 2022
0988c91
Update README.md
kwackers Oct 24, 2022
513816c
Accel/decell when retracting.
kwackers Oct 26, 2022
adc265d
Fix for losing sync on automatic retract.
kwackers Oct 26, 2022
c6f60c7
Update README.md
kwackers Oct 26, 2022
c841683
Prevent the "too fast" error being thrown if quitting 'thread to shou…
kwackers Oct 27, 2022
f59bb59
Merge branch 'clough42:master' into master
kwackers Oct 27, 2022
f4181a9
Fix for: Large pitch + multi-start sometimes don't quite make the sho…
kwackers Oct 28, 2022
ea505c2
Merge branch 'clough42:master' into master
kwackers Dec 9, 2022
6b9e60d
Add optional config for more thread specs, default thread/feed on start
johnsonm Apr 13, 2023
bd58fc5
Merge branch 'extended-thread-spec' into kwackers
johnsonm Jul 28, 2023
dd33ac1
Configuration for G0709 in ASW8 with 6:1 servo gears
johnsonm Apr 12, 2023
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
67 changes: 67 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,70 @@
## Update.
Fixed a bug I introduced earlier that causes the auto retract to lose sync on some threads (never edit code when you're tired).
Added deceleration to end of auto retract.
## Added multistart threads (see below)
To function this adds one extra step to the shoulder operation to select the number of starts.
## Added thread to shoulder, custom thread pitches and angular position of spindle.
Allows the threading to shoulder (with retraction to start of thread without requiring the spindle to be rotated).
Allows the setting of custom thread pitches from 0.01mm to 9.99mm.
Can display the angular position of the spindle instead of RPM.

The three modes are accessed via an options menu by pressing "Set".

You can now cycle between the options using the "+" and "-" buttons.

Press "Set" to select one (options will time out after a few seconds).


#### Custom Thread ("CUSt tHd").
Left hand display shows "Ct" and the first digit of the pitch will be flashing.

Use "+" and "-" to change this, press "Set" to move to the next digit, repeat for all digits.

When the final digit has been entered the display will return to the normal threading display but using the new pitch.

(At any point while "Ct" is displayed pressing the power button will exit the mode).

#### Thread to shoulder ("SHOULdEr").
Display shows Multi 1 ("MULtI 1") this is the number of starts the thread has, use the + & - keys to change this value and press Set to accept.
(A value of '1' is a normal single start thread)

Display shows Go Shoulder ("GO SHLdr"), move the carriage to the shoulder position (either manually or by engaging the half nuts and driving the spindle).

If you haven't already engage the half nuts - they MUST now remain engaged for the duration of the threading operation.

Press "Set" to mark the shoulder position. Display will now show Go Start ("GO StArt").

Move the carriage by using the spindle to the start position of the thread and press "Set" once there.

You've now marked the shoulder and start positions of the thread so we can cut the thread.

Display shows Begin ("BEGIN n.x") until the spindle starts to rotate, where 'n' is the start number and x is the number of starts. For normal single start threads this will show "1.1".
Each subsequent loop will increment the 'n' value and the thread will start at the new position. When all starts have been machined n will loop back to 1 and the process can be repeated.

Cut one pass, when the carriage reaches the shoulder it will stop and the display will show Stop ("StOP").

Stop the spindle, once it reaches zero rpm the display will show Retract ("rEtrACt").
You should now retract the tool from the work and press either the "+" button or the "set" button which will cause the carriage to return to the start position.
Whilst the carriage is moving the display will show Wait ("WAIt")

Display once again shows Begin. Repeat the above until you've cut your thread.

When the spindle is at zero RPM the display will have the prefix "SH" to remind you you're in Cut-to-shoulder mode.
Press "Pwr" once to exit.

#### Position ("POSItION").

RPM is replaced by the angular position of the spindle.

Exit by going back into the menu and selecting RPM.


# Notes
Retraction speed is set in configuration.h "retractSpeed" - currently set to 100rpm.

Display brightness can be changed when in "powered off" mode using the + & - buttons.


# Clough42 Lathe Electronic Leadscrew Controller

This is the firmware for a lathe electronic leadscrew controller. The goal is to replace the change
Expand Down
84 changes: 75 additions & 9 deletions els-f280049c/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
//================================================================================

// For Imperial leadscrews: pitch in Threads Per Inch (TPI)
#define LEADSCREW_TPI 12
#define LEADSCREW_TPI 8

// For metric leadscrews: pitch in hundredths of a millimeter (HMM)
// Example: 200hmm = 2mm
//#define LEADSCREW_HMM 200
//#define LEADSCREW_HMM 300



Expand All @@ -64,26 +64,33 @@
//================================================================================

// Steps and microsteps
#define STEPPER_MICROSTEPS 8
#define STEPPER_RESOLUTION 200
#define STEPPER_MICROSTEPS 1
// ASW8
// 6:1 servo:input
// 275:144 input:output
// python -c 'print(str([z for z in [(i, i*6*275/144) for i in range(100, 500)] if z[1]%1 < .01 and z[1] < 2001]))'
// 168 steps/rev (choose largest for integer result <= 2000, program into servo)
// 168*6*275/144 = 1925
#define STEPPER_RESOLUTION 1925

// 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
// Choose Z feed rate, X is approximately 1/4 of Z
// This is relative to the leadscrew TPI, choose nearest integer, not exact
// STEPPER_RESOLUTION/factor 1925/0.4152 ~= 4636
#define STEPPER_RESOLUTION_FEED 4636

// 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

// Enable servo alarm feedback
#define USE_ALARM_PIN




//================================================================================
// ENCODER
//
Expand All @@ -103,6 +110,66 @@
//#define ENCODER_USE_EQEP2


//================================================================================
// power on state when booted
//================================================================================

#define START_POWER_ON true


//================================================================================
// backlash value
// This fixes an issue (which may only apply to me) in that the encoder at certain
// positions 'dithered' causing the stepper to 'vibrate' resulting in noise when the
// lathe was stopped.
// This value effectively adds backlash to the system so that the minimum number of
// steps have to be issued before the motor will move
// set to zero if not required.
//================================================================================

#define backlash 2


//================================================================================
// for automatic retraction we can set the maximum rpm of the leadscrew.
// The speed shouldn't be too high since the leadscrew doesn't decelerate plus
// high speeds could result in missed steps and loss of sync between spindle and leadscrew
// (slightly odd equation layout to stop it issuing integer overflow warnings)
//================================================================================

#define leadscrewRPM(rpm) ((200000 * 60) / rpm) / (STEPPER_MICROSTEPS * STEPPER_RESOLUTION);
// default to 200rpm
const int32 retractSpeed = leadscrewRPM( 200 );

//================================================================================
// DEFAULTS
//
// Choose initial startup values to values close to what you typically use,
// to reduce scrolling through values you seldom need, and choose the sets
// of values you wish to include. The extended sets of threads give you more
// values, but also make you click "up" and "down" more to get to the thread
// you want. See the definitions in Table.cpp
//================================================================================
#define EXTENDED_INCH_THREADS
#define EXTENDED_METRIC_THREADS

#ifdef EXTENDED_INCH_THREADS
#define INITIAL_INCH_THREAD_INDEX 23 // 24TPI
#else
#define INITIAL_INCH_THREAD_INDEX 12 // 24TPI
#endif
#ifdef EXTENDED_METRIC_THREADS
#define INITIAL_METRIC_THREAD_INDEX 10 // 0.5mm
#else
#define INITIAL_METRIC_THREAD_INDEX 6 // 0.5mm
#endif


#define INITIAL_INCH_FEED_INDEX 4
#define INITIAL_METRIC_FEED_INDEX 4





//================================================================================
Expand All @@ -117,7 +184,6 @@




//================================================================================
// HARDWARE
//
Expand Down
43 changes: 41 additions & 2 deletions els-f280049c/ControlPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,28 @@ void ControlPanel :: decomposeRPM()
this->sevenSegmentData[i] = (rpm == 0 && i != 3) ? 0 : lcd_char(rpm % 10);
rpm = rpm / 10;
}

// add a 2 char prefix to show mode if rpm is zero
if (this->rpm == 0)
{
this->sevenSegmentData[0] = this->curMode[0];
this->sevenSegmentData[1] = this->curMode[1];
}
}

void ControlPanel :: decomposeSpindleAngle()
{
Uint16 angle = this->spindleAngle;
int i;

for(i=3; i>=0; i--)
{
if (i == 2 )
this->sevenSegmentData[i] = lcd_char(angle % 10) | lcd_char(10);
else
this->sevenSegmentData[i] = (angle == 0 && i != 3) ? 0 : lcd_char(angle % 10);
angle = angle / 10;
}
}

void ControlPanel :: decomposeValue()
Expand All @@ -199,6 +221,7 @@ void ControlPanel :: decomposeValue()
}
}


KEY_REG ControlPanel :: readKeys(void)
{
SpibRegs.SPICTL.bit.TALK = 1;
Expand Down Expand Up @@ -300,11 +323,27 @@ void ControlPanel :: setBrightness( Uint16 brightness )
this->brightness = brightness;
}

void ControlPanel :: refresh()
void ControlPanel :: incBrightness()
{
if (this->brightness < 8)
this->brightness++;
}

void ControlPanel :: decBrightness()
{
if (this->brightness > 1)
this->brightness--;
}

void ControlPanel :: refresh(bool showAngle)
{
configureSpiBus();

decomposeRPM();
if ( showAngle )
decomposeSpindleAngle();
else
decomposeRPM();

decomposeValue();

sendData();
Expand Down
19 changes: 18 additions & 1 deletion els-f280049c/ControlPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ class ControlPanel

// Current RPM value; 4 decimal digits
Uint16 rpm;
// Current spindle angle value
Uint16 spindleAngle;

// Current displayed setting value, 4 digits
const Uint16 *value;
Expand All @@ -150,10 +152,14 @@ class ControlPanel
// Derived state, calculated internally
Uint16 sevenSegmentData[8];

// prefix for mode
int curMode[2];

// dummy register, for SPI
Uint16 dummy;

void decomposeRPM(void);
void decomposeSpindleAngle(void);
void decomposeValue(void);
KEY_REG readKeys(void);
Uint16 lcd_char(Uint16 x);
Expand All @@ -178,6 +184,9 @@ class ControlPanel
// set the RPM value to display
void setRPM(Uint16 rpm);

// set the spindle angle value to display
void setSpindleAngle(Uint16 angle);

// set the value to display
void setValue(const Uint16 *value);

Expand All @@ -189,11 +198,19 @@ class ControlPanel

// set a brightness value, 0 (off) to 8 (max)
void setBrightness(Uint16 brightness);
void incBrightness();
void decBrightness();

void showCurMode(Uint16 dig1, Uint16 dig2) {curMode[0] = dig1; curMode[1] = dig2;}

// refresh the hardware display
void refresh(void);
void refresh(bool showAngle);
};

inline void ControlPanel :: setSpindleAngle(Uint16 angle)
{
this->spindleAngle = angle;
}

inline void ControlPanel :: setRPM(Uint16 rpm)
{
Expand Down
5 changes: 1 addition & 4 deletions els-f280049c/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Core :: Core( Encoder *encoder, StepperDrive *stepperDrive )
this->previousFeedDirection = 0;
this->previousFeed = NULL;

this->powerOn = true; // default to power on
setPowerOn(START_POWER_ON); // initial power on state
}

void Core :: setReverse(bool reverse)
Expand All @@ -64,6 +64,3 @@ void Core :: setPowerOn(bool powerOn)






Loading