-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Invert VARIABLE_SPINDLE PWM output #246
base: master
Are you sure you want to change the base?
Conversation
Is possible star a file on specific line? |
It doesn't work for me, no signal on the 11 pin. |
Sorry to hear that. Did you remember to uncomment line 214 in config.h?
It's disabled by default for the pull request. Maybe an interaction with some other spindle related setting? |
Yes I did, But now I'm trying with the normal code and no pwm signal on D11. Any suggestion? |
A bit hard to say. Could be so many things. Make sure you're not in an
alarm state. Can be triggered randomly by unfiltered limit switch signals.
Check for shorts? Sorry I can't help much more than that without being
there!
|
I've tried with 2 different arduinos, both connected to cnc shield and disconnected. Checking the D11 with a tester. |
You sure you are on the right pin? The pin changes when you enable PWM |
Did you clean out your Arduino libraries after you changed the config? You
must also load the test sketch.
…On Sep 25, 2017 11:43 AM, "biasedlogic" ***@***.***> wrote:
You sure you are on the right pin? The pin changes when you enable PWM
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#246 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AQlzDCSVTxOvZud4T7sLzhkmZ5Kdhdcgks5sl7wQgaJpZM4O0TTx>
.
|
yeah, I did it, and doesn't work. The only way I can make my Laser work It's to enable USE_SPINDLE_DIR_AS_ENABLE_PIN and plug the laser to the spindle dir pin. (No pwm enabled) PS: Now PWM is working but no inverting, even uncommenting INVERT_SPINDLE_PWM |
Updating: I used a nand on the output and comment out the INVERT_SPINDLE_PWM, eveything works fine now. |
Why do you need to invert duty cycle? For me it worked uninverted with HY VFD... |
hey, any more detail on how anyone was able to get this to work? ive tried enabling USE_SPINDLE_DIR_AS_ENABLE_PIN and VARIABLE_SPINDLE with no luck. my laser just stays active on the +Z pin |
Now there seems to be quite elegant solution integrating Huanyang RS485 communication directly to GRBL, i would be happy if you can help with testing: |
Does not work for me. I added a new pull request (#1040) with a different approach to invert PWM signal. |
This PR does not work for me, I applied it to the latest available commit (bfb67f0). PR #1040 from @oMtQB4 works fine, except in my case laser does not operating at full power, it much weaker than it was before. I tried to fix #1040 version, but I wasn't successful. So I fixed this PR. uint8_t corr_pwm_value;
#ifdef INVERT_SPINDLE_PWM
corr_pwm_value = 255 - pwm_value;
#else
corr_pwm_value = pwm_value;
#endif
SPINDLE_OCR_REGISTER = corr_pwm_value; // Set corrected PWM output level. and replaced After this correction everything works perfect, PWM is inverted and laser is operating at full power. This is whole code for the function void spindle_set_speed(uint8_t pwm_value)// Sets spindle speed PWM output and enable pin, if configured. Called by spindle_set_state()
// and stepper ISR. Keep routine small and efficient.
void spindle_set_speed(uint8_t pwm_value)
{
uint8_t corr_pwm_value;
#ifdef INVERT_SPINDLE_PWM
corr_pwm_value = 255-pwm_value;
#else
corr_pwm_value = pwm_value;
#endif
SPINDLE_OCR_REGISTER = corr_pwm_value; // Set PWM output level.
#ifdef SPINDLE_ENABLE_OFF_WITH_ZERO_SPEED
if (pwm_value == SPINDLE_PWM_OFF_VALUE) {
spindle_stop();
} else {
SPINDLE_TCCRA_REGISTER |= (SPINDLE_TCCRA_ENABLE_PWM_MASK); // Ensure PWM output is enabled.
#ifdef INVERT_SPINDLE_ENABLE_PIN
SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT);
#else
SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT);
#endif
}
#else
if (pwm_value == SPINDLE_PWM_OFF_VALUE) {
SPINDLE_TCCRA_REGISTER &= ~(SPINDLE_TCCRA_ENABLE_PWM_MASK); // Disable PWM. Output voltage is zero.
} else {
SPINDLE_TCCRA_REGISTER |= (SPINDLE_TCCRA_ENABLE_PWM_MASK); // Ensure PWM output is enabled.
}
#endif
} |
Is there any way to include this PR into GRBL? |
Hello @dingorock, just a suggestion... when you turn off the PWM the D11 pin goes low (0V), right? In terms of inverted PWM this is equivalent of 100% duty cycle. Would not be more consistent when turning off the PWM to also set the D11 high, that is, again in terms of inverted PWM equivalent of 0% duty cycle? So the inverted PWM disable code would look like this: SPINDLE_TCCRA_REGISTER &= ~(SPINDLE_TCCRA_ENABLE_PWM_MASK); |
Adds the option to invert the duty cycle of the variable speed spindle output pin.
Tested with VFD Controller (Huanyang Invertor Model: HY01D523B)