-
Notifications
You must be signed in to change notification settings - Fork 73
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
Spindle Enable pin isn't initialized as output. Easy fix. #63
Comments
There is USE_SPINDLE_DIR_AS_ENABLE_PIN definition. |
Look elsewhere in the code. On spindle_set_state it calls a macro to change the spindle enable pin when you don't have variable spindle speed, but it does nothing because after line 64 there's a conditional define and it only configures spindle enable bit if USE_SPINDLE_AS_ENABLE_PIN is defined, and they have sepparate definitions (enable is PB 13 and dir is PB 14), so it's likely the intention was to have separate spindle enable and dir controls. Some brushless spindles have an input to change the rotation direction, and with an H-bridge a regular DC motor can be reversed as well. When you have variable spindle enabled, the spindle dir can be toggled with M4, and the spindle pwm pin can be set to different duty cycles, therefore I think it makes sense that spindle enable be controlled separately. When variable spindle is disabled, there's no output on spindle PWM. If that was supposed to work as spindle enable too, it should be toggled, instead you have no output on either spindle pwm and spindle enable. |
Maybe. |
Kind of. The relay will hum if I do that. |
Why? 0% is full off, 100% is full on. It is equal to digital output off/on. |
Just think of it this way: there's a pin definition for a spindle enable pin, which is different from the spindle dir. If the code is kept the way it is, the spindle enable pin will never be toggled, regardless of #defines, because it isn't ever initialized as an output. Does that sound like an intented feature? The relay hums with an S value of anything other than 100. Yes, always use M3 S100, but how about the fact that the pin does nothing when reading through the comments would indicate it does? |
I have this issue, and I can't figure it out. I'm on the verge of buying a blackbox.. 🤷😅🥴 |
With the code the way it is, you cannot use M3 and M5 to toggle the state of the Spindle Enable pin because it's not initialized as an output. The fix is really simple.
If you add those two lines:
GPIO_InitStructure.GPIO_Pin = 1 << SPINDLE_ENABLE_BIT; GPIO_Init(SPINDLE_ENABLE_PORT, &GPIO_InitStructure); // <--- initializes the spindle enable pin
To the file spindle_control.c, after the line 68, which initializes the Spindle Dir pin with the function
GPIO_Init(SPINDLE_ENABLE_PORT, &GPIO_InitStructure);
Then M3 Sx will turn the spindle en bit high and M5 will turn it low, just like it was supposed to be.
The text was updated successfully, but these errors were encountered: