So I've been messing around with my spindle control and I've got it working

So I’ve been messing around with my spindle control and I’ve got it working however I have some confusion.

This works but…

Switch module for Spindle control

switch.spindle.enable true
switch.spindle.input_on_command M3
switch.spindle.input_off_command M5
switch.spindle.output_pin 2.13
switch.spindle.output_type pwm
switch_spindle_maximum_power 1
switch_spindle_minimum_power 0.0
switch_spindle_default_power 0.3
switch_spindle_pwm_period 400

I don’t have any reference to the actual rpm. If I send a M3 S255 it runs at it’s maximum speed and M3 S10 runs really slow. Is there a way to convert this via the firmware that I can set the PWM values between 0 and 255 to equal a theoretical RPM between 0 and my spindle’s maximum RPM?

There’s also a spindle module, that’s what I’m using I have it set up for analog control of my VFD but I’m pretty sure You could use it instead of the switch module. It’s just sending PWM exactly the same output as switch but it’s handled differently by smoothie. I’m guessing it’s converting RPM values to corresponding PWMs between 0 and 255.

It has a config for max spindle speed you just set that and your pwm output and you’re pretty much good to go. Then you specify the spindle speed with M3 S24000 in my case; for max speed. M3 S12000 for half speed etc, and you don’t need to worry about pwm values and how they correlate to the RPM you’re after.

http://smoothieware.org/spindle-module

I read that but it didn’t help. I’m not sure why. I tried the example for the analog module. Reading it seems like I should be able to cut and paste it but change my pin.

Yeah essentially that’s what I did, and don’t forget to specify your max rpm for your spindle.

Also you have to enable the module, that’s not in the text on the analog module example settings. You’ll need the line:

Spindle.enable true

Which is a little further up the page in case you missed it.:fu:

@Steven_Kirby This is what I tried. Do I need anything more than this?
spindle.type analog
spindle.max_rpm 12000
spindle.pwm_pin 2.13
spindle.pwm_period 1000

Just to enable the spindle module, see (previous comment) and you should be golden.

Oh and your switch pin for switching the spindle on, I’m presuming you have a relay connected for that?

There’s no direct relationship between PWM and RPM, you would need to add an encoder or something to measure it

Hi @Steven_Kirby ​, I do not have a relay. Just turning on or off the pwm signal. I will add the enable comment. I thought it looked funny. I’ll post back when I get to it tomorrow. Thanks for the input. @Triffid_Hunter ​, that did occur to me but bring the novice that I am I don’t want open that can of worms. Lol.

@Triffid_Hunter Yes I perhaps should have mentioned that but since @Chuck_Comito was already aware that the resultant RPM would only be theoretical anyway I just gave the most straight to the point answer I could.

I’m aware that the only true way to have 100% accurate spindle RPM, especially when other variables such as cutting friction are added, is to have a closed loop system that provides feedback to the controller about the current speed; so it’s able to adjust it’s output accordingly. It’s a feature I’d love to see in smoothie actually, I was asking if it was possible a couple of weeks ago as I’m converting a mini lathe to CNC and it’s essential for accurate thread cutting.

Perhaps you can better elaborate on how the spindle module works, I know you’re involved in the design of smoothie. But I’m guessing based on your specified max rpm smoothie distributes the pwm values between 0 and 255 across the range between 0 and the specified max RPM. Maybe with a touch of smoothie magic, some sort of fancy coefficient?

Worms anyone? :laughing:

Chuck, I hope you manage to get your spindle running to your satisfaction, I think spindle module will work better than switch at least. I checked out the self-designed machine you’re putting it on, props! It looks beefy. I was going to design my own too but since I don’t have a machine to cut plates etc. I just took the openbuilds route for now. Just need to get this darn VFD to behave!

switch_spindle_maximum_power 1
switch_spindle_minimum_power 0.0
switch_spindle_default_power 0.3
switch_spindle_pwm_period 400

are not legal switch statements even if they were formatted correctly, check the switch module docs in the wiki.

So unfortunately I wasn’t able to try the recommendations… I lost communication with my board. Note to others, do not put your controller in your pocket when covered in aluminum shavings and then power on your board… I’m clearly wasn’t thinking on so many levels. Lol. New controller on it’s way.

Oh dear @Chuck_Comito , “lost communication” is that a nice way of saying you fried it!? Was there smoke and fireworks? Does it still power up? I managed to accidentally fry a board by shorting the extruder heater cartridge terminals, one stray strand of copper is all it takes! Luckily it just blew a fuse on the main power input and liked the mosfet. After some fiddly solder work with a reflow station I borrowed from work I managed to replace the fuse and it works again. Cost me pence to fix and now I’m using it in this CNC build. Winner! Maybe you can rescue your board too? Guess I at least had a clue where to look for the fault, I suppose if yours was covered in aluminium chips you might not know where to start looking. It could be worth having a crack though!

On a more positive note though, I’ve managed to sort out my VFD, a capacitor on the DAC output was all it took in the end. It seems I can’t hit max speed now though so after all this messing about I’m going to try getting modbus communication going. I don’t hold out much hope since this vfd isn’t even a huanyang so god knows what the manufacturer’s hex codes will be. Hopefully it’s not some other deviation from the norm, there’s nothing about their implementation in the manual! So yeah, should be really enjoyable! :roll_eyes:

I didn’t let any smoke out and I’m only hoping the aluminum was the issue. I found what looked like solder balls near and under the pins of the micro. I can access the sd card but otherwise I get a serial communication error. It’s definitely nothing obvious. I’m able to access some high end equipment and EE’s at work and we couldn’t sort it there. I’ll call it a parts board for now lol.

What vfd drive are you using? I’m glad you sort of got it sorted but sounds like it’s not gonna work in the end?? What rpm will it reach the way it is?

Man that’s a bummer! How long til your new board arrives? Guessing you’re still working on the mechanical side of things if you’re getting aluminium chips on your controller? How have you made your gantry plates etc? You got access to another machine?

The drive I have is a yl620-a, it looks identical to the huanyang drives. So essentially it’s a cheap Chinese copy of cheap Chinese VFD! I’m not sure what corners were cut but they certainly skimped out on the documentation. I know the genuine huanyang drives have their own implementation of the modbus protocol which smoothie actually supports, if I’m lucky they copied that too. If I’m unlucky, I’ll have to figure out the code and from the looks of things edit smoothie’s source code and compile my own version of the firmware with the right codes for the VFD I have. Mission! In over my head really but for the cost of the adapter it takes to try it out, I thought it was with a punt.

The max speed of my motor is 24,000rpm. I’ll probably not run it that fast but when I ask smoothie for top speed the driver is giving me ~350 Hz so ~21,000rpm. Conversely in the middle of the range it’s above the speed I’m asking for. I mean it’ll work but the feeds and speeds won’t match my CAM so it probably won’t work as well as it could. There’s some settings on the drive I can mess with and I have ordered a tachometer to measure the actual speed so I might be able to fudge it somehow. It’ll get me going but the drive will be the first thing I upgrade when I have the funds!

I next day’d the controller so it’ll be here tomorrow. I don’t have access to another machine though. This is my first build. I went the smoothie route because I have a 60 watt co2 laser running smoothie. I had a buddy at work water jet the gantry sides but the rest of the design was made to utilize 1/2" thick x 6" wide aluminum bar. This way I could cut it to length and then just drill holes where needed. I wish I had used 2 ball screws and 2 steppers and moved them to the outsides of the base though. I could have gotten more rigidity out of it that way. Good luck with the modbus. I wish I could help you with it but that’s way over my head.
missing/deleted image from Google+

She’s a beut @Chuck_Comito ! The gantry certainly looks nice and solid. So you’re just driving it with one screw in the middle? It’s a legit approach, those ballscrews ain’t cheap either! I dare say it won’t make much difference to the rigidity. Your frame and the linear rails will be more important for the load bearing. I’d be more worried about only having the torque of one stepper for moving all that gantry around. Looks like you maxed out on the Nema 23s though, so it probably won’t be an issue. Your steppers are bigger than your spindle! lol Are they the guys that only draw 1.8A but deliver 2.4Nm and you’re driving them straight from the smoothie?

You’re pretty much building the machine I wanted to build. I found some reasonably priced ballscrew and linear rail kits from China on ebay. I also have a water jet guy at work that occasionally machines things for me and figured he’d hook me up for the plates.Then I was just going to throw it all on some aluminium box section in much the same configuration you have there. But I found a workbee kit on alibaba with motors for £360(~$550) delivered and thought screw it; I’ll not beat that price buying everything separately. I’d just had the headache of designing and building 2 3D printers. Things always end up not quite going to plan with projects, which can be fun (fixing problems etc.) but I just wanted this to be straightforward. (Typically it still hasn’t been! :stuck_out_tongue: )

Yeah, I’m not looking forward to the modbus thing, It’ll probably drive me mad but I’ll get there in the end. I hope you manage to get the spindle going once you get your replacement board, let me know how it turns out.

Here’s my machine, basically just a leadscrew driven ox, It should be good enough to get me started though:

missing/deleted image from Google+

missing/deleted image from Google+