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

add servo motor support using cprezzi and DWiskow approach #811

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lavolpecheprogramma
Copy link

I merge the changes done by @DWiskow in this repository with grbl 1.1h version.

DWiskow explains his work in this post and I replicate it in 1.1h release.

Now you can enable the servo on z axis directly in config.h like the @cprezzi approach.

Thanks for your work.

@BenjaminPoilve
Copy link

Hello,
I don't know if this is the right place for this discussion, so feel free to tell me If that's not the case.
This PR worked quite well for me, and I think servos are a common enough usage to be integrated. Though the current method (relying on the pre-scaler to have a PWM "close enough" to 50hz and use the PWM rate to set the signal length) does have a significant shortfall: the precision is limited to the available steps. For me that's 31 steps over 270°, so almost a 10° step. This makes it impossible to program smooth tool movement using G4 commands.

Do you have any idea how to solve such a problem? My knowledge of C is quite limited, but one thing is for sure, it could not rely on the standard PWM! I think solving this issue would make this inclusion to the grbl controller much more versatile.

Thanks, and thanks to the grbl maintainers !

@cprezzi
Copy link

cprezzi commented Sep 22, 2020

The hardware PWM approach was the only option to fit in the extremly limited space of the atmega328 chip. Grbl already uses almost all available space.

@BenjaminPoilve
Copy link

Thanks for the answer! That's what I feared. For those who face the same issue as me, the alternative is to use a separate board to convert the PWM to a servo signal. You can then use the standard spindle code to precisely control the servo.

You can make such a board with a simple 555, or find some sellers that make them (for exemple, see here)

@cprezzi
Copy link

cprezzi commented Sep 22, 2020

By the way. The servo option was not made to give you a fine controll of the servo position, it's made for pen plotters where you just need pen up or down. The exact positioning is made in hardware.

@Mazenalimam
Copy link

Mazenalimam commented Feb 9, 2022

Hi I used this version 1.1h for plotter but I noticed that when homing the servo/spindle is disabled giving me unwanted pehavier.
I want the servo/spindle to stay up while homing can you help me what to change in the code to do that? Thx

edit:
i solved this by using the 3 files here and change the code in limits.c after line 163
#ifdef SPINDLE_IS_SERVO
pl_data->spindle_speed = gc_state.spindle_speed;
pl_data->condition = (PL_COND_FLAG_SYSTEM_MOTION|PL_COND_FLAG_NO_FEED_OVERRIDE|PL_COND_SPINDLE_MASK);
#else
memset(pl_data,0,sizeof(plan_line_data_t));
pl_data->condition = (PL_COND_FLAG_SYSTEM_MOTION|PL_COND_FLAG_NO_FEED_OVERRIDE);
#endif

@Kenabi31
Copy link

Inverting the Servo makes it move up and down whenever i want to home or move the axis.
#define SERVO_SHORT 15
#define SERVO_LONG 31

And the dual homing function does not work sadly.

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

Successfully merging this pull request may close these issues.

5 participants