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

Servo support added (switchable) #153

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Conversation

cprezzi
Copy link

@cprezzi cprezzi commented Mar 10, 2017

Hi Sonny

I have implemented support for servo instead of spindle (for EggBot). It's switchable by #define SPINDLE_IS_SERVO in config.h.
This defines a prescaler of 1/1024 (61Hz) and min/max PWM values for a pulse duration between 0.5 and 2.5ms in cpu_map.h.
In spindle_control.c I modified the function spindle_compute_pwm_value: If SPINDLE_IS_SERVO is defined, don't calc spindle override and use min PWM instead of stop_spindle.

I have tested it with an EggBot and LaserWeb3 and 4.

Hope this is usefull for you.

Regards Claudio

@chamnit
Copy link
Contributor

chamnit commented Mar 10, 2017

@cprezzi : Thanks Claudio! Looks nice and clean. I'll test it over the weekend.

@ghost
Copy link

ghost commented Mar 10, 2017

@chamnit
Copy link
Contributor

chamnit commented Mar 13, 2017

@cprezzi : Wasn't able to get to this over the weekend, but do have a question. Is this code particular to your eggbot servo? If so, what would be required to provide a more generic and universal servo support? I don't have any experience with servos and what they need.

@langwadt
Copy link

@chamnit looks like it would work with most servos, though it'll be rather coarse because of the limitation of the timer. regular servos need a pulse between ~0.5ms and ~2.5ms repeated every ~20ms to set the position

@cprezzi
Copy link
Author

cprezzi commented Mar 14, 2017

@chamnit This should be working with most rc servos.
They usually accept a pulse duration of 0.5 to 2.5ms with a PWM frequency of ~50Hz. The closest we can get with a prescaler of 1/1024 is 61Hz (=16ms cycle). That's within the specs of rc servos. See: https://en.wikipedia.org/wiki/Servo_control for detais.

For limiting the range of the servo movement, it could make sense to let the user also define the minimum and maximum values for the PWM, but that would probably need some more explanation (calculation sample).

Optional: It would probably be a nice option to invert the servo direction with a config param.

@botboe
Copy link

botboe commented May 6, 2017

Is there a schedule for merging the changes? I need it for my 4xidraw (Axidraw-clone, http://www.thingiverse.com/thing:1444216).

@chamnit
Copy link
Contributor

chamnit commented May 6, 2017

@Mad-Onion : My bad. Totally forgot about this. I'll get to it very soon. Can't say when exactly. My spring honey-do list seems to get longer no matter how many things I cross off.

@davidrisberg
Copy link

This is also useful for RC motors and ESC as spindles, which is very useful and is already being done. I think it would be a great feature.

@KoljaWindeler
Copy link

KoljaWindeler commented Aug 5, 2017

dang it .. should have checked here before doing the exact same thing ..

i used these values:
min 8 (512us)
max 39 (2497us)
any reason you've used lower numbers?

your define is active by default, intentionally?
and in the spindle_controllonly the changes at the bottom (spindle_compute_pwm_value) really matter, correct?

👍

@KoljaWindeler
Copy link

Hi claudia, would you take a look and tell me what you think:
#245
Kolja

@KoljaWindeler
Copy link

@cprezzi have thought about adding a delay after each call that alters the servo position? I see that sometimes lines aren't drawn completely due to high feed and "slow" servo speed.

@ghost
Copy link

ghost commented Aug 27, 2017 via email

@neilferreri
Copy link

@cprezzi Can the servo direction be inverted in your fork?

@cprezzi
Copy link
Author

cprezzi commented Mar 4, 2019

@neilferreri Unfortunately not. We just swapped the servo mechanically.

@neilferreri
Copy link

Unfortunately not. We just swapped the servo mechanically.

Thanks for the reply. Flipping the servo is not an option right now, so I'll have to work around it.
Thanks again.

@jonmccon
Copy link

+1 on this I'd love to have servo support along with the ugs cli.
@cprezzi Is there a way to merge core updates to your branch?

@lavolpecheprogramma
Copy link

If someone is interested, I have added the servo support by DWiskow to the latest version of grbl 1.1h
https://github.com/lavolpecheprogramma/grbl-1-1h-servo
It is ready to flash on Arduino for pen plotting.
Thanks a lot guys for your work!

@cprezzi
Copy link
Author

cprezzi commented Feb 11, 2020

@lavolpecheprogramma

If someone is interested, I have added the servo support by DWiskow to the latest version of grbl 1.1h
https://github.com/lavolpecheprogramma/grbl-1-1h-servo
It is ready to flash on Arduino for pen plotting.
Thanks a lot guys for your work!

Why didn't you start with a fork of gnea/grbl and just made your changes? Instead you copied the whole code so nobody can reproduce which code is from you. This is the WRONG WAY to do it, because it doesn't document where the original code came from and what you changed.

Starting with a fork has many advantages:

  1. Everyone can see where the code is comming from and what you have changed.
  2. You can easily integrate new features from the upstream repo.
  3. You can make pull requests to the original repo to get your changes into the upstream repo and this way help the community.

@lavolpecheprogramma
Copy link

@cprezzi it makes sense. I'll try my best to do it!
in the meanwhile, if you want you can get a check to the changes that are grouped in this commit lavolpecheprogramma/grbl-1-1h-servo@21b4532

thank you very much!

@lavolpecheprogramma
Copy link

@cprezzi done ;) #811
I appreciate your tips!
tell me what do you think about it ;)

@Piramidowy
Copy link

@cprezzi done ;) #811
I appreciate your tips!
tell me what do you think about it ;)

@lavolpecheprogramma
does you fork works with both servo and laser via S32 = 0/1 or it's just for servo? (Is it possible to switch PWM freq via grbl config?)

@lavolpecheprogramma
Copy link

Hi @Piramidowy,
servo works only if S32 is 0 and you define SPINDLE_IS_SERVO in config.h.
In this case, PWM will be calculated to control a servo otherwise it will be the default one.

@jhaand
Copy link

jhaand commented Sep 30, 2022

A rebase, testing and merge would be really appreciated after all this time.
I had quite a lot of trouble with getting a good gcode sender going for my pen plotter. UGS craps out on Linux and the rest expects GRBL 1.1 Only Lightburn still supports GRBL 0.9. But that's closed source.

@ingino
Copy link

ingino commented Oct 21, 2022

@cprezzi I am using your firmware grbl_v1.1f_Servo.hex on a elekslaser plotter with LaserGRBL app.
I'd like switch from RC servo mode to Laser Mode and viceversa using parameter $32 Laser Mode Enable when the firware is running. Do you think is possible to change the code to have this beahviour?

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.