Hello Guest it is April 26, 2024, 06:04:51 AM

Author Topic: Spindle control via Modbus tied to OEM input switches and screen buttons  (Read 8961 times)

0 Members and 1 Guest are viewing this topic.

This is somewhat strange and maybe I am trying to do something that just isn't possible yet but it almost works.

What I am trying to do (in two parts). I have a VFD for my spindle that I communicate with via Modbus. Without enabling any thing on the Spindle config screen I was able to get it somewhat working. I configured the Modbus and then modified the M3, M4 and M5 VB scripts to set the appropriate bits. I also modified the spindlespeed script to calculate the appropriate value to send out and then send it. I am able to use the MDI screen and execute these scripts and they work fine. I can execute G code programs and they work fine.

What doesn't work is using the Spindle controls on any of the screens. Pressing the Toggle spindle button or F5 doesn't get any action on the GUI. This is probably caused by some code dependency on the Spindle configuration in the Config menu (proven below).

Next I wanted to configure three OEM inputs to run the spindle forward, reverse and stop. These are existing buttons on the control panel on my mill so I figured why not. I mapped them to the OEM codes for CW(110), CCW(173) and I couldn't use Spindle stop because the above are toggles. Not surprisingly it didn't work. It probably doesn't work for the same reason as the GUI buttons also don't work.

Second experiment. I setup Output 4 to map to the Modbus bit that enables the VFD. In the spindle configuration I enable the spindle relays and set both CW and CCW to #4. I enable Modbus Spindle control and set that to #64. I do not enable the spindle motor output because that forces me to assign it output pins for step and direction.

Now the GUI button can at least turn the spindle on/off and control the speed. Also the OEM buttons will cause the spindle to toggle on/off like the GUI. There isn't a true Enable/Disable signal in the OEM codes. In Modbus land Enable is a bit, Reverse is a bit and the speed is a register value. The available codes in Mach don't exactly map to the Modbus control of a VFD.

Another problem with this configuration. The M3, M4, and M5 scripts don't work anymore which means that G code won't be able to control the spindle. When you execute a script it changes the state for a brief instant. It appears that the script changes the internal state of the modbus bit and then something else comes along and wipes it out. I would guess that it is the update from the GUI that overwrites the memory with the state it currently wants to be in.

The questions:
  • What is the best way to solve this problem?
  • If I forget about the OEM buttons, how do I get the GUI and the M3 and M4 scripts to work properly?
  • Would a Brain controller have the ability to solve this problem?

Thanks for any suggestions.

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Ok on to your Quetions:

The questions:
What is the best way to solve this problem?
If I forget about the OEM buttons, how do I get the GUI and the M3 and M4 scripts to work properly?
Would a Brain controller have the ability to solve this problem?

I run Modbus controlled machines alot, Are you running Modbus Directly into your VFD? If so, you need to look and see if you can do "Block addressing" of parameters that is the easiest. If your perameters cannot be User block addressed, then you will have to look at the parameters you do want to access and Read and/or Write to.
Other way, is easier (but a little more expensive), Have Mach talk to a PLC and let the PLC talk to your VFD.... The PLC has much more sofisticated Modbus capability, and you can talk to your Servo Drive to if you have them.

Anyway on to the show:

1).Goto Ports and Pins>Spindle, "UNTICK" the use 64 and modbus spindle!!!! (Unless your using Peters Modbus board). Tick off, step and direction for you spindle and enable/use the spindle tick.
2). for G-Code Driven M3, M4, M5, M7, M8, M9 to work, you HAVE to use Relays OUTPUTs 1-6 (there are other ways but they are more complex). This will allow G-Code and MDI to control the above functions and it will show on your GUI.
3). In ports and Pins, You will need to ENABLE your Spindle!!! SET ANY Spindle, Inputs, outputs that you plan to use you HAVE to Enable them!! Set the Port # to 3 (three) This is a non-existant Port, but that is OK, we are gonna control this stuff by Brains anyway!!!
4). Your Spindle speed control (in Brians), will Be DRO(99) (the Spindle speed percent DRO), The percent goes from 0-1, so you will need to Multiply this number By 100 and then Multiply that Total by the resolution of your Analog Card in your PLC or the Bit resolution of the speed control of your controller. I.e. I use Automation Direct PLC with a 12 bit analog Card that drives my Spindle. The resolution of that Card is 12 bits, so 4095. (I have attached a Brain for you that shows the Spindle control, and how to Use the status of your M3/4 Leds to reset your Spindle Speed Percent.......
5).  Mach does have Enables they are called Enable 1-6, these bits only go Hot once Mach is up, you can send one of them, (your choice), out to your Spindle. You can also add a button that can toggle that Enable on and Off, (or put the code in an existing spindle button).
6). Brains......................   Brains is the ONLY way to go (Make sure you are using "Use Plug in Serial" in the Ports and Pins, and also in your modbus for brains. (Unless you are using Ethernet and that is very simular).

So in summery:
Set your M3 to OUTPUT1, M4 to OUTPUT2, (coolent to whatever), on the Spindle tab of Ports and pins. make sure the Disable Relays are UNticked.
turn OFF use Modbus Spindle (this is for Peters board), Tick On use Spindle Motor output and set it to Step and dir
Enable ANY Input/Output, or what ever you plan to use across the modbus, set the port to port 3. (Brains only looks at the function).
Enable your Spindle in motor control, set to port 3, pins are irrelevent.
Enable any Enables you wish to use for you various drives or functions that need an enable.
Make sure you have ticked: Modbus InputOutput Support, AND, Modbus Plugin Supported!! if they are not, tick them and reboot mach.

Under Setup Serial Modbus control:
I recommend using config 0 for your input stuff, and config 1 for your out put stuff
Make sure you Port #, Baud Rate, Protocol match the device your talking to, NOTE: Mach ONLY does 8-2-N, RTU Modbus
You will need to translate the Octal, or Hex address of your External device that you are talking to, to its decimal equivelent, put a start address and how many of the 16 bit registers you are bringin in, or going out to. (Note Currenlty Bit of Word is Broken, in Brains so if your device will only take a bit of Word type of control then you will need to go through a PLC to translate it.
READ your docs, Most stuff like PLCs, and VFD's will let you do Input Holding, and Output Holding, and drop those controls into User(Variable memory), or User Assigned parameter blocks......

Test your Modbus Connection here for Input and Output to your device......., if all is good, hit Apply, and OK, (Make sure the tick box for Modbus Run is ticked, and make sure NOT to forget to tick your Configs you will enable, and make sure the configs are also set to the port you are using!!!!

In Brains  (I highly, highly, highly recommend you watch the Brians vidio tutorials).  I am attaching a Working Spidle speed control Brian only, for ADC analog Card, but you can adapt it to your needs.

NOTE: INPUTS and OUTPUTs are TWO seperate things in Brains, so be careful since the Nomenclature is the SAME i.e. Modbus0 is the same for input and output as far as the name goes, you only differentiat it by ticking Input or Output when setting up the Ladder Rung.

see attached Brain.........

Scott







fun times
Thanks for the instructions. I was able to get it working through the GUI and M-codes.

A few comments.

The Outputs on the Motor tab only accepts port 1 and 2 pins. Luckily I have two unused pins right now, but I would like to get them back. If I didn't have to enable the step/direction section for the Spindle then I am not forced to throw these pins away.

In a previous thread I thought I was not supposed to be using the "Modbus PlugIn". It was implied that this was for the ModIO boards and it also doesn't show up in the Mach documentation. I enabled this "Modbus Plugin" and then configured using the newer spread sheet looking configuration tool.

Using your tips, I was able to find signals in the Brain editor that indicate Spindle CW and CCW. I use these to set the direction bit. I use the Spindle Enable to control the enable bit and I used the Spindle percent DRO through a formula to set the frequency in the VFD. It was pretty simple once I figured out which Modbus output serial box I needed to check in the termination tool.

I am using a Hitachi SJ200 VFD. These have modbus built-in which is awesome because it reduces the number of boards you need to zero and reduces the cost to use it.

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
re-read my last post to you, what is said was Set the "PORT" to 3 (pins are irrelevent for modbus)........

I highly recommend the Plug in for Modbus, you can selectivly configure your I/O especially if you have to jump around to different addresses for different functions......

Glad you got it working,

Scott
fun times

Offline sebba

*
  •  42 42
    • View Profile
hello,

I'm a newbie in this domain and I'm coming with some questions.
I hope will not be very stupid questions but if will really be stupid questions, please forgive me. :)

So, I intend to control a Fuling DZB200B spindle trough RS485 and Modbus.
As far as I read (and maybe learn) until now, I have done following:
I successfully connected the VFD to the computer through an RS232/RS485 adapter. everything seems to be OK because when I'm doing "test Modbus" in "Modbus configuration" I can read the VFD's parameters.

I watched the brains tutorials and I read some documentations but I'm afraid I'm not on the right way.

I have the manual for inverter here: http://www.ms-motor.com/frequency_inverter/DZB200&300Busermanual.pdf
...but I have no ideea what to do next

any hints will be very useful. thank you,
Seb