RAMPS 1.4 Spindle Speed

So I am using D4 for spindle speed which is the default for a RAMPS/mega2560 combo I believe. That appears on the second set of “servo” pins on the RAMPS board, second set from the reset button. The D4 pin is used because it is specifically a PWM capable pin I believe. I haven’t tried switching to using the D8 pin. Looking at the schematic for the RAMPS board, it looks possible to use D* to get a 12V signal, BUT it would still be a PWM signal. You would still have to convert it to a DC voltage for the 0-1V input on the spindle power controller. That could probably be done by sending the signal through a resistor to a capacitor to filter it to smooth (enough) DC. It may also be possible to choose a resistor value high enough that you end up with 10V DC out of a nearly 100% duty cycle 12V PWM signal if you get what I am trying to say.

Something like this
image
With the D8 input on the left and the 0-10V output on the right. Not sure what the values might be. I may get a chance to experiment with this at some point to see.

That said, I REALLY like the idea of my spindle and my arduino being opto isolated so I will be trying the off the shelf converter like the one mentioned in @robertbu post below (above?)

I should also add that I did some fiddling with setting min max values in Marlin for the LCD controls and I got some very strange results… I think the defaults are 5000 and 30000 for LCD RPM control of spindle speed or something… Well since software can set from 0-50000 I figured that was the way to set the LCD min max. Things were not scaling right on the LCD settings…

I admit to lazy here… I don’t use LCD to set spindle speed, I use software to set it. So I said to hell with working on that. Wouldn’t surprise me that given that RPM didn’t work correctly because of a float issue in the code, the same issue may apply as soon as you set a max above 32767 or something strange like that and I just got too lazy to track that one down…

If you want it now and have a Prime account, one like it are available on Amazon for about $10.

Yeah I have prime. Call me cheap. My $5 from eBay is $5 canadian. Amazon is $14 Canadian. Mine is working fine fir now so I will be patient. It does me good to learn patience.

Big hurdle this morning. My first aluminum cutting.

Huge wohoo moment. Failed yesterday and I figured out my DRV8825 chips were overheating. Y axis stopped. Yeah I had the mill plough through 4mm cutting through the part until I could hit the reset button.

Dropped my drive voltage from above .8V to .7V and ran the same GCODE to completion this time. May add a cooling fan to the RAMPS setup as insurance.

2 Likes

So in having a discussion with someone I know, I’ve learned a few things about the RAMPS board that makes this annoying. First is that the servo pwm is actually 5V. The pwm to 0-10V DC converter would probably work fine with this. Second is that the heater headers (D8-D10) are switched ground, not switched 12v, which makes controlling the spindle difficult for reasons I still don’t perfectly understand haha.

So to overcome these things, here’s what I’ll probably try to do:

This is a combination of a pull up resistor, a voltage divider, and an RC filter. I’m a little flaky on some of the details because I don’t have the background, but I’m assured it makers sense lmao. The internal resistance of the 0-10V input on the PSU is 90k ohms, so that’s taken into account in the voltage divider, along with the pull up resistor.

Also of note is that the spindle pwm from D9 has to be inverted in marlin because it’s switched ground. I’m told that during its off cycles, it’s actually full 12v, which is not what we want when the output is ground.

“It may also be possible to choose a resistor value high enough that you end up with 10V DC”

This requires to know the exact current being drawn, V = I*R. I think I’d rather make a voltage divider that doesn’t depend on current, and is very flexible with what resistors you use. The output voltage is also perfectly proportional to the input.

“Failed yesterday and I figured out my DRV8825 chips were overheating”

Wow, do you have heatsinks on them? I’ll be using the a4988’s I have on hand, with heatsinks and a fan. That only gives me 16x microstepping, but that’s already like 0.01mm, so I don’t care much about that.

Depending on the ramps, it is actually floating when it is off. It switches between off and floating. The rambo is tied through an LED to 12V, but I think the ramps isn’t.

I get continuity between the positive terminals on the heater headers and the 12V input when the board is turned off, so at least in my case it seems to be as I described before.

I agree with that. But I just am saying the (-) side switches between floating and ground. You just may be able to use a pull up to 10V on the ground and it can switch between 10V and ground (but still be inverted).

Oh wow, I had a major brain fart, I don’t know why I tested the positive terminals when that wasn’t a question. I even stated it earlier, switching ground.

I’ll check the ground pins lol.

Don’t know if this is what you’re looking for but I found an inverter circuit I posted in this thread that worked to drive a +12v pwm signal from the fan output on the RAMPS board.

FWIW, you cant do this on a rambo. The (-) side is connected through a resistor and led to 12V.

Ok, I was just set straight, I’m on board with how the FET works now.

Ok, I got it working. Actually really well too. I set the spindle speed to 12000 rpm and get a perfect 10V, and at 6000 rpm I get 4.88V. Close enough for me, just about linear. This is what I ended up doing:

The two 1k resistors are in parallel for pull up just because it doubles the thermal mass, so each one heats up less. If someone else tries this, they’ll have to measure the internal resistance of their PSU’s 10V input and modify the voltage divider based on that.

I also set up a relay from the RAMPS to the spindle PSU’s on/off header. I’m not really sure if this is strictly necessary because just setting the spindle speed to 0 turns it off too (M3 S0), and M5 also sets the speed to 0. Maybe someone will tell me it’s actually a good thing I wired the relay. Redundancy I guess.

Do they heat up significantly? There is only 12mA going through them.

Power through the resistor is (V^2)/R, or (12^2)/500. Or if you want to first get current, I = V/R = 12/500 = 24mA, P = RI^2 = 500*0.024^2. That’s 0.288W, which is a bit much for standard quarter watt resistors.

If you only had one (and it was still 1k) though, it would be 12mA and 144mW. Not sure why you need both for a pull up, but I will trust you’re paying closer attention than me.

Initially I tried using a larger pull up resistor at 4.7k, but it was making the voltage divider not very linear. At a set 6000 rpm, I was getting more like 4.3V. I’m not too sure on why exactly this is, but I’ve been told that a lower value pull up would make it more linear, and it seems to be correct.

1 Like

I want to followup on this post after I have been having some issues… Will also follow up on the original thread you referenced.

I started having random milling errors. It would random detour… so far the way I have resolved these is to disable the spindle control. My current working theory is that spindle control is probably fine IF you are using PWM255 mode on an 8 bit RAMPS/mega256 setup but the RPM mode may be causing corruption elsewhere even thought RPM seems to be working… So for now I would hold off on the RPM fix and use PWM255 until I confirm.

Any progress on this issue?

What specifically are you asking about? There were a few things discussed in this thread. Initially I was trying to get a live RPM feed back to my controller board, but quickly abandoned that in favor of simply setting the RPM through gcode and assuming it’s close enough to reality, which works quite well.