Skip to content

Servo support added (switchable)#153

Open
cprezzi wants to merge 7 commits into
gnea:masterfrom
cprezzi:eggbot
Open

Servo support added (switchable)#153
cprezzi wants to merge 7 commits into
gnea:masterfrom
cprezzi:eggbot

Conversation

@cprezzi

@cprezzi cprezzi commented Mar 10, 2017

Copy link
Copy Markdown

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

chamnit commented Mar 10, 2017

Copy link
Copy Markdown
Contributor

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

@ghost

ghost commented Mar 10, 2017

Copy link
Copy Markdown

@chamnit

chamnit commented Mar 13, 2017

Copy link
Copy Markdown
Contributor

@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
Copy Markdown

@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

cprezzi commented Mar 14, 2017

Copy link
Copy Markdown
Author

@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

botboe commented May 6, 2017

Copy link
Copy Markdown

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

@chamnit

chamnit commented May 6, 2017

Copy link
Copy Markdown
Contributor

@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
Copy Markdown

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

KoljaWindeler commented Aug 5, 2017

Copy link
Copy Markdown

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
Copy Markdown

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

@KoljaWindeler

Copy link
Copy Markdown

@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

ghost commented Aug 27, 2017 via email

Copy link
Copy Markdown

@neilferreri

Copy link
Copy Markdown

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

@cprezzi

cprezzi commented Mar 4, 2019

Copy link
Copy Markdown
Author

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

@neilferreri

Copy link
Copy Markdown

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
Copy Markdown

+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
Copy Markdown

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

cprezzi commented Feb 11, 2020

Copy link
Copy Markdown
Author

@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
Copy Markdown

@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
Copy Markdown

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

@Piramidowy

Copy link
Copy Markdown

@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
Copy Markdown

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

jhaand commented Sep 30, 2022

Copy link
Copy Markdown

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

ingino commented Oct 21, 2022

Copy link
Copy Markdown

@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.