Author Topic: Spindle Control with Modbus  (Read 7719 times)

0 Members and 1 Guest are viewing this topic.

Offline swinn

  • Active Member
  • Posts: 6
    • View Profile
Spindle Control with Modbus
« on: March 23, 2007, 02:30:13 AM »
I read through the wiki on setting up Modbus, so I understand the basics.  My VFD has a modbus interface that will allow three commands that I'm interested in be set.

  • Stop/Start (0=Stop/1=Run)
  • FWD/REV (0=REV/1=FWD)
  • Motor Freq (0-4000)

How do I setup Mach3 to drive it with this?  My best guess is:

  • Setup modbus to map these to virtual outputs, pin 0 = Stop/Start, pin 1 = FWD/REV, pin 2 = Spindle Speed
  • Enable the spindle output in 'Motor Outputs'
  • Set the Dir Pin# to 1, Port to 0
  • Set the 'Spindle Relays' outputs to drive pin 0, port 0

Then there is the 'Modbus Spindle - Use Step/Dir as well' section of the Spindle Setup page.  What does this do? 

Guessing, I'd think that I should set the Max ADC Count to 4000 (max value my VFD accepts), choose enabled, and set the Reg to 2.

Does this all sound correct?

Is there any documentation on the Modbus Spindle section?  I've checked the PDF docs and the Customization Wiki. Thanks for any help!  I'll have my PC hooked up to the VFD in a few days, waiting on an RS-485 adapter to arrive.

Offline Brian Barker

  • Administrator
  • *
  • Posts: 3,517
    • View Profile
Re: Spindle Control with Modbus
« Reply #1 on: March 23, 2007, 09:54:40 PM »
That all sounds right... but you will need to write a bit of code to make the stop/run Fwd/Rev to work. Mach3 likes to have Fwd/Stop Rev/Stop
Fixing problems one post at a time ;)

www.newfangledsolutions.com
www.machsupport.com

Offline swinn

  • Active Member
  • Posts: 6
    • View Profile
Re: Spindle Control with Modbus
« Reply #2 on: March 25, 2007, 01:13:43 AM »
I got it partially working.  The first part of the setup, setting the VFD modbus params to drive the spindle on/off work fine.  Setting the Dir pin on the motor output has no effect, so I turned it off.  All I did was set the output for the relay control of the spindle to output #2 which is configured to go to port 0, pin 0.  Modbus autopoll is mapped to send the command to the VFD.

Additionally I found that the following VBScript will reverse the spindle direction.  I can execute this script before spindle rotation or during rotation, and it reverses direction.  (The VFD does a smooth slow down and direction reverse autmatically)

SetModOutput (1, 0) - Clockwise
SetModOutput (1, 1) - Counter Clockwise

How can I hook these script commands into the Mach 3 spindle commands?  If I could tell an M3 command to execute the first line, as well as doing the relay control it is already doing, and of course the second line for an M4 command.  Is this possible?

I can't get the variable speed to work at all though.  The variable speed is in a holding register.  I map it to output #64, and it sends out 0 continously so the motor runs at 0 speed.  I enable the 'modbus spindle - use step/dir as well' option and put in the max freq the VFD will accept.  It still outputs 0 and the motor doesn't turn of course.   What am I missing here?  While the spindle is running, I can use this command in the script editor to change its speed:

SetModOutput (64, 650)

This sets it to full speed.

So I've got some script commands that work, but I'm not sure what to do with them.  Can you point me in the right direction?
--Scott

Offline Brian Barker

  • Administrator
  • *
  • Posts: 3,517
    • View Profile
Re: Spindle Control with Modbus
« Reply #3 on: March 25, 2007, 09:04:32 AM »
You are doing VERY well and you are just about done!
You need to add your code to the M3.m1s ,M4.m1s and M5.m1s files to make the spindle work as you like.

Now I think you have to have the spindle relays turned on to have the modbus spindle working... just enable them and set the port to 3 (that will not hurt anything) and I think you should be good to go!

Good work
Brian
Fixing problems one post at a time ;)

www.newfangledsolutions.com
www.machsupport.com

Offline swinn

  • Active Member
  • Posts: 6
    • View Profile
Re: Spindle Control with Modbus
« Reply #4 on: March 25, 2007, 12:36:22 PM »
OK, I added the direction script commands to M3 and M4 and the spindle spins the proper direction when I ask it too, very cool!

Now I'm trying to get the speed to work.  I found a script called 'spindlespeed.m1s' and added my speed command there: SetModOutput (64, 650)

It doesn't work though, as the spindle speed remains at 0.  If I execute the command manually the spindle goes to the commanded relative speed.  Any ideas?

Thanks!

Offline Brian Barker

  • Administrator
  • *
  • Posts: 3,517
    • View Profile
Re: Spindle Control with Modbus
« Reply #5 on: March 25, 2007, 12:43:15 PM »
You need to set the speed max number on the Spindle settings tab in the ports and pins settings. that will point the data to the 64th register.

That should do it!
Fixing problems one post at a time ;)

www.newfangledsolutions.com
www.machsupport.com

Offline swinn

  • Active Member
  • Posts: 6
    • View Profile
Re: Spindle Control with Modbus
« Reply #6 on: March 25, 2007, 11:53:09 PM »
I can't find a 'Speed Max' setting.  I looked in Ports and Pins, Spindle tab.  I also looked through the other tabs and options screens.  I am using Mach 3, 2.0 version.  Is there also supposed to be a setting to tell it which register to put the speed into?  Where do I find them?

Offline swinn

  • Active Member
  • Posts: 6
    • View Profile
Re: Spindle Control with Modbus
« Reply #7 on: March 29, 2007, 01:41:14 PM »
Any additional thoughts on this?  I have the X and Y servo motors running now, and am now machining up the mounting plates for them.  I'd really like to have spindle speed control through Mach.  I should have the machine operational in two axis in a few days, and then will work on the Z axis.

Offline willy469

  • Active Member
  • Posts: 3
    • View Profile
Re: Spindle Control with Modbus
« Reply #8 on: December 15, 2009, 10:37:10 AM »
hi,

I have started a new topic for Spindline via modbus.
http://www.machsupport.com/forum/index.php/topic,13231.0.html

Can anyone give me a hand with this?

Thank you!