Maslow Home Maslow Community Garden

Colaboration request to add spindle speed via g-code in FW/GC

spindle-speed

#1

After completing my short c-beam z-axis with 500w spindle I discovered the possibility to have the speed of spindle controlled by g-code. (S commands)
From the hardware side it’s fairy simple unless I’ve overlooked something.
My spindle power supply has a potentiometer and a ‘speed input’ 0-10V DC.
image
With a PWM-to-voltage module like this https://www.amazon.com/KNACRO-voltage-module-converted-voltage/dp/B06XB6J4FV/ref=cm_cr_arp_d_pl_foot_top?ie=UTF8 I should be able to adjust the speed via the arduino.

Questions:

  • do we have a free pin that does PWM
  • how much effort is it to implement

GC feed rate adjustability
#2

So it’s either 0-10v or a potentiometer to control speed?


#3

No the potentiometer will be removed I guess.
From 0 to10V input will determine the speed of the spindle.
The aurduino can not supply that, so the ‘PWM-to-voltage module’ will translate the PWM from the arduino to the appropriate output. from what I read for calibration is that you create a 50% PWM as input to the module and adjust tiny potentiometer on the module for a 5V output to the spindle power supply.
How that translates to spindle speed I don’t know yet, but have RPM meter on hand to test.

Edit to my questions:
This might fail because the arduino has already enough to do and can’t handle a constant or changing PWM in addition?

Edit2: I’m 12 years out of programming. Was hoping for a 'simple addition to “if” ore “case” loops that sends a signal to 1 unused pin and if nothing is connected, no harm is done (eliminates a switch to turn on/off).


#4

I don’t fully understand the documentation on GitHub about the pinouts, but my interpretation that could easily be wrong, is that all the pwm pins are used. But I did find a thread that @blurfl mentioned the possibility of adding three pwm pins to the new motor control board… but Im not sure (hard to read through hundreds of posts on a phone)


#5

Big hopes have come up! Thank you!
Will dig the TLE now.
In what file are the pins set depending on the shield?

Edit: I can search for text in files, so ‘var names’ could help me find what i’m looking for.


#6

Not really sure how it is handled… but look in system.cpp.


#7

It was a bad day until you showed up! Biggest THANK.
Have more then enough to dig and the PWM->0-10V will arive 3’rd Jan acording to amazon-rain-forrest-killers :wink:


#8

Awesome. Let us know what you do to get it to work. I’m looking to switch over to a c-beam and spindle myself


#9

I looked at my crystal ball and it said that we might look into coordinated x/y/z/s moves :rofl:
I don’t have a crystal ball.

Going to bed. Have a good ‘what ever it is on your side of the globe’.
Regards, Gero


#10

ATmega2560. It has 54 digital input/output pins (of which 15 can be used as PWM outputs)
From their site.
2…13 + 45 & 46 = 14 from search and 46 seems to be or has been discussable.
Lets say 13.
Pin 13 seems to be free for the task of spindle speed.

TLE5206 part of System.cpp:

    else if(pcbVersion == 3){ // TLE5206
    //TLE5206 PCB v1.3 Detected
    //MP1 - Right Motor
    encoder1A = 20; // INPUT
    encoder1B = 21; // INPUT
    in1 = 6;        // OUTPUT
    in2 = 4;        // OUTPUT
    enA = 5;        // errorFlag

    //MP2 - Z-axis
    encoder2A = 19; // INPUT
    encoder2B = 18; // INPUT
    in3 = 7;        // OUTPUT
    in4 = 9;        // OUTPUT
    enB = 8;        // errorFlag

    //MP3 - Left Motor
    encoder3A = 2;   // INPUT
    encoder3B = 3;   // INPUT
    in5 = 10;        // OUTPUT
    in6 = 11;        // OUTPUT
    enC = 12;        // errorFlag

    //AUX pins
    aux1 = 40;
    aux2 = 41;
    aux3 = 42;
    aux4 = 43;
    aux5 = 68;
    aux6 = 69;
    aux7 = 45;
    aux8 = 46;
    aux9 = 47;
}

Line 25 does:

int SpindlePowerControlPin; // output for controlling spindle power

So is what I’m looking for already implemented???


#11

What pin is that connected to? I actually vaguely remember it being a thing


#12

Looks like aux1 to turn spindle/router/laser/plasma/waterjet on/off for relay?
Is pin 13 free?

Edit:

grep -rnw ~/Maslow/fw-test/Firmware-1.25 -e ‘SpindlePowerControlPin’ >spindle.txt
Firmware-1.25/cnc_ctrl_v1/GCode.h:47:extern int SpindlePowerControlPin;
Firmware-1.25/cnc_ctrl_v1/System.h:78:extern int SpindlePowerControlPin;
Firmware-1.25/cnc_ctrl_v1/System.cpp:25:int SpindlePowerControlPin; // output for controlling spindle power
Firmware-1.25/cnc_ctrl_v1/System.cpp:255: SpindlePowerControlPin = aux1; // output for controlling spindle power
Firmware-1.25/cnc_ctrl_v1/Spindle.cpp:20:// the variables SpindlePowerControlPin and LaserPowerPin are assigned in configAuxLow() in System.cpp
Firmware-1.25/cnc_ctrl_v1/Spindle.cpp:40: Serial.print(SpindlePowerControlPin);
Firmware-1.25/cnc_ctrl_v1/Spindle.cpp:54: myservo.attach(SpindlePowerControlPin); // start servo control
Firmware-1.25/cnc_ctrl_v1/Spindle.cpp:77: pinMode(SpindlePowerControlPin, OUTPUT);
Firmware-1.25/cnc_ctrl_v1/Spindle.cpp:80: digitalWrite(SpindlePowerControlPin, HIGH);
Firmware-1.25/cnc_ctrl_v1/Spindle.cpp:84: digitalWrite(SpindlePowerControlPin, LOW);
Firmware-1.25/cnc_ctrl_v1/Spindle.cpp:91: pinMode(SpindlePowerControlPin, OUTPUT);
Firmware-1.25/cnc_ctrl_v1/Spindle.cpp:94: digitalWrite(SpindlePowerControlPin, LOW);
Firmware-1.25/cnc_ctrl_v1/Spindle.cpp:98: digitalWrite(SpindlePowerControlPin, HIGH);


#13

myservo.attach(SpindlePowerControlPin);

That line looks to me like it is going to PWM the spindle control pin in servo more, but it will be a special kind of PWM meant to control a servo motor.

I’m shooting from the hip here but I think I remember pin 13 is used by one of the timer libraries we are using which means it can’t actually be used for PWM :confused:


#14

There’s a note on the documentation that says 11, 12, and 13 are used for timer one


#15

Pins 44, 45, and 46 on the megas end connector apparently is pwm as well.


#16

Do you have a post that describes your cbeam zaxis with spindle build? Parts list, where you sourced them, how you put it together? I’m very interested…


#17

I’ve ordered 8mm acrylic for the sled that will be cut on my desktop cnc.
I planed to put in the Garden when it’s a complete sled that has moved around.

I can easy pull the orders from aliexpress, did order stuff that does not fit and had to make it fit though :wink:
Might as well put it up in the garden tomorrow as collaboration, cause plenty of room for improvement but a clear target. Light weight, low CGZ, short, spindle Z-axis.


#18

And these seem to be free. Not connected on the original shield and pulled out as aux ports on @bee 's TLE shield. 44 it shall be then (aux 7 on the TLE shield).


#19

I read a thread somewhere someone had an issue with pin 44… so if it doesn’t seem to work, don’t be afraid to try a different pin just in case.


#20

yes, this was to run a hobby-type-servo to move the on-off switch on a router.
It was tied to the M command, not the S command

If we can get the firmware to put out a PWM signal based on the S command, there
are a lot of ways to adapt it to actually modify the speed (including having a
servo with a wheel on it rotate the router speed knob :slight_smile: )

David Lang