fra589/grbl-Mega-5X

Invert Spindle PWM

GatzeTech opened this issue · 4 comments

I don't know if this is the right place to ask this question, but is it possible to invert the spindle PWM (preferable without changing the firmware) ?

I managed to rebuild a Mach3 board to Grbl, but on the outputs there is a optopcoupler in between which inverts the signal.

The only serious thing I found is this:
https://www.cnczone.com/forums/diy-cnc-router-table-machines/406528-grbl-mega-5x-ramps1-4-superpid.html

Hi @GatzeTech,

I don't quite understand what you need.
Can you be more specific in describing your problem?

<> does not make technical sense for me...
A PWM signal is an electrical signal composed of +5V pulses whose pulse width is variable, which varies the effective voltage.
Inverting it would mean generating -5V pulses? This is an electronic hardware problem, there is no software solution for it.

@++;
Gauthier.

Thank you for your answer.

I should indeed be a bit more specific, this is not what I meant, I think you can better say, 'invert the dutcycle of the PWM

What I need is, is that if for example the minimum spindle rpm is 1 and maximum is 1000 and if you sent for example M3 S250, the positive periode of the PWM should be 75% (instead of 25%).

And if you send M3 S750, the high period of the PWM should be 25% (instead of 75%)

This because I have a optocoupler between my output and pin of the microcontroller and inverts the signal.

But I have some experience with programming Avr's, I'm figuring it out right now, it's not that hard.

Hi @GatzeTech,

It was not hard to implement this new compilation config option. I just pushed a new v1.2e version which add this option in config.h.

To unable it, uncomment the line number 96 in the config.h file like this:
#define INVERT_PWM_VALUES

Tel me if it's that you need.

@++;
Gauthier.

I will try in the weekend, very thank you this is most likely what I need.