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

Laser and spindle on MKS Sbase V1.3 #45

Open
anarion999 opened this issue Feb 22, 2024 · 1 comment
Open

Laser and spindle on MKS Sbase V1.3 #45

anarion999 opened this issue Feb 22, 2024 · 1 comment

Comments

@anarion999
Copy link

Hey there,
Since two days I am trying to get a firmware ready based on grblHAL for the MKS Sbase v1.3 which is capable of using two different PWM pins for controlling laser and spindle. I think I am missing something or just being too stupid to put the pieces together.
I think I found the relevant parts in the respective *.h files but I was not able so far to get the things working.
From the mks_sbase_map.h the relevant part is to my mind the following:

_// Define driver spindle pins

#if DRIVER_SPINDLE_PWM_ENABLE
#ifdef SPINDLE_PWM_PIN_2_4
#define SPINDLE_PWM_CHANNEL PWM1_CH5 // MOSFET3 (P2.4)
#else
#define SPINDLE_PWM_CHANNEL PWM1_CH6 // BED MOSFET (P2.5)
#endif
#define SPINDLE_PWM_USE_PRIMARY_PIN false
#define SPINDLE_PWM_USE_SECONDARY_PIN true
#else
#define AUXOUTPUT0_PN 2
#define AUXOUTPUT0_PORT port(AUXOUTPUT0_PN)
#define AUXOUTPUT0_PIN 4
#endif_

I also found in the config.h the part for the definition of the number of spindles/PWM devices:

/*! \def N_SPINDLE
\brief Defines number of spindles supported - minimum 1, maximum 32.
*/
#if !defined N_SPINDLE || defined DOXYGEN
#define N_SPINDLE 2
#endif

Here, I suppose that I should increase the number to 2...

And then finally the part of my_machine.h:

#define SPINDLE0_ENABLE SPINDLE_PWM0
#define SPINDLE1_ENABLE SPINDLE_PWM1
//#define SPINDLE2_ENABLE SPINDLE_PWM0_CLONE
//#define SPINDLE3_ENABLE SPINDLE_NONE
// **********************

But now I don't understand how to tell the code that I want to use two different PWM pins for the devices and also were to remap the respective pins accordingly. Also the PWM-Channel thing form the mks_sbase_map.h is unclear for me. And the final question for me is how two switch between the two PWM devices in a respective controlling software?

I am really confused at this point and your help is more than aprreciated.

Thanks you and best regards

Florian

@terjeio
Copy link
Contributor

terjeio commented Feb 22, 2024

The LPC176x only has code support for a single PWM output. The allowed pin definitions for PWM can be found here.
Without adding code for a second PWM spindle the only option is to #define N_SPINDLE 2 in config.h and
#define SPINDLE0_ENABLE SPINDLE_PWM0
#define SPINDLE1_ENABLE SPINDLE_PWM0_CLONE
which will use the spindle direction output as spindle enable for the cloned spindle.
The cloned spindle has to be enabled with $511=1. Spindle switching is either by tool number or by M104.
Note that I have not yet tested this option with this driver.

With new code one has to add code explicitly for a new spindle (SPINDLE_PWM1) and register that with the core, something I have not done yet. Alternatively add code for an analog PWM output and enable SPINDLE_PWM2 which claims the output and register it as a spindle. The code neded for an analog output can be complex depending on the MCU, an example can be found here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants