Transcript
Page 1: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)

ConnectingaVFDtoMach4throughModbus(RS485)

V2

June2019BillCaldwell

[email protected]

Connectingaspindlecontroller(VFD)toMach4throughtheModbus(RS-485serialport)isnotaneasytask,sincethereisnoformalMach4Modbusdocumentationyet,andnooverallLUAscript(thatIcouldfind)tosupportaVFDthroughModbus.

ThispostisasetofstepbystepinstructionsthathopefullywillhelpsomeoneelsegettheirVFDupandrunningquickly.

ForreferenceIamusingWindows10,Mach4V4.2.0.3804,andFDTIserialdriverV2.12.16.0

TheHuanyangVFDispopularonmanyInternetsites,howeverthereareseveralmodelsoutthereandmostofthemarenottrulyModbuscompatible.IchosetheHuanyangGTseries2.2KWformySpindlesinceitdoessupporttheModbusprotocolandinterfaceswithMach4’sModbuscorrectly.OtherVFDscaneasilybecontrolledaslongastheyareModbuscompliant.

Thesestepswillgiveyouthenecessarysetuptodothefollowingspindlecommands:

1. M3(CWspindle)2. M4(CCWspindle)3. M5(Stopspindle)4. Sxxxxx(Setspindlespeed)

InadditionthespindlewillbecontrollablethroughthefrontpanelbuttonsandexecutingGcode.

Step1

SetupyourVFDtocontrolyourparticularspindleusingthefrontpanelontheVFD.Thiswillincludemaxfrequency,minfrequency,maxcurrent,maxvoltage,rampparameters,etc.

RefertotheVFDmanualfortheinstructionsonhowtousethefrontpanelcontrolsontheVFDtomodifytheseparameters.Theywillbesavedacrosspoweron/offcycles,sothisonlyneedstobedoneonce.Pleasenoteoncethesesettingsarechanged,youwillnolongerbeabletocontrolthemotorfromtheVFDfrontpanel.

Page 2: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)

OnceyoucanturnthespindleonandoffandsetthespeedfromthefrontpaneloftheVFDyouarereadytomodifytheVFDparametersnecessarytoenabletheModbuscommunicationsportontheVFDsocommandsandstatuscanbesentandreceivedbetweenthecomputerandtheVFD,disablingthefrontpanelmotorcontrol.

TheHuanyangGTVFDrequiredthreevaluestobemodifiedfromthedefaultvalues.

1. P0.01=2(defaultis1)RuncommandsourceistheRS485port2. P0.07=7(defaultis0)FrequencysourceistheRS485port3. PC.00=1(defaultis0)SettheModbusnodeaddressto1

(6/29/2019update)MostGTseriesVFDsdefaulttoRTUmode1start,8data,noparity(1N8)at19.2KBPS.However,Ihavebeentoldthatsomedonot,somakesuretocheckalltheseparametersintheVFDandcorrectthemasnecessary.

TheVFDisnowsettoreceivecommandsandsendstatusto/fromtheserialModbus(RS-485port)at19.2Kbaud,noparityinRTUmode.

PleasenotethatcomputersdonotimplementRS-485directly.YoumustpurchaseaUSBtoRS-485converter.AllRS-485datawillbesentouttheselectedUSBportonthecomputerthroughtheconverter,acrosstheRS-485cabletotheVFD.TheRS-485protocolimplementsadifferentialelectricalconnectionthatprovidesagreatdealofcommonmodenoiseimmunity,whichisusefulintheCNCenvironment.

ConnecttheVFDtotheRS485converterwiththedifferentialRS485signalsconnectedD+toD+andD-toD-ontheVFD.Ifthesignalsarecrossed,nocommunicationswilloccur.

PlugintheUSBcablefromtheRS485convertortothecomputer.

TheHuanyangGTVFDusesthefollowingregisteraddressesandcommandbits.Inthefollowingstepsyouwillbereferencingthoseaddresses.

Commandregisteraddress4096decimalStatusregisteraddress4097decimalSpeedregister8192decimalThecommandregisterissetto:Runforward1Runreverse2Stop5TheStatusregisterreturns:Forward1Reverse2Standby3Fault4

Page 3: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)

Powergoingoff5IfyouuseadifferentVFDmostlikelytheseaddressesandvalueswillneedtobechangedintheModbusfunctionsandtheLUAcode.

Step2

ItisnecessarytoinstalltheUSBtoRS-485windowsdriverneededfortheconvertor.Followtheinstructionssuppliedwithyourconvertortoinstallthedriver.Oncethedriverisinstalled,notethecomportnumberitisassociatedwith(Com3inthiscase).

Page 4: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)

Step3

ThisstepsetsuptheMach4ModbuscontrollertosendcommandstotheselectedVFDandreceivestatusbackfromtheselectedVFD.OncethesechangesaremadetheywillbepermanentlystoredintheMach4profileyouarecurrentlyrunning.

Intheconfiguration/controlmenu,selectthePluginstabandenablethefollowingplugins.

Page 5: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)

SelectthespindletabandfillintheMaxRPMasshownbelow.

Page 6: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)

IntheConfigure/Controlmenu,selectthePluginspulldownmenuthenselecttheModbusplugin.

Page 7: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)

BegincreatingthecommunicationspathfromtheComporttotheMach4Modbuscontroller.Fillintheboxexactlyasseeninthefollowingscreen.

ThiscreatesaninstanceoftheModbuscontrollercalledmodbus0settoRTUmode.Generallythedefaultvalueswillwork.Makesuretocheckthezerobasedregisteraddressingmodebox.

Page 8: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)

SelecttheporttocorrespondtotheportattachedtotheUSBtoRS484convertershownintheWindowsdevicemangerwindow(Com3inthisexample).Continuesettingtheparametersasshownbelow.

Page 9: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)

Whenyouaredonewiththisstepyouwillseetheconfirmationwindowasseenbelow.Yourcomportmaybedifferentthanshowninthisexample.

Page 10: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)

YouwillnowseetheModbuscontroller,justcreated,intheleftcolumnandasummaryoftheModbussettingsjustselectedontheright.SelectOK.

Page 11: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)

Step4

ThenextstepscreatethreenecessaryModbusfunctionstowritetotheVFDcommandregister,writetotheVFDspeedregister,andreadtheVFDstatusregister.Pleasemakesurethefunctionnamesareenteredexactlyasshown.TheyneedtomatchthecorrespondingfunctionnamescontainedintheLUAscripttofollow.

HighlighttheModbuscontrollerandselectthecreatefunctionbutton.Fromthepulldowncommandlist,select(0x06).Fillinthevariousparametersexactlyasshownbelow.Thenameofthisfunctioniswrtvfdcmd(typedin2places).Pressnext.

Page 12: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)

Thenextscreenconfirmsyoursettingsforthefirstfunction.PressOK

Page 13: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)

HighlighttheModbuscontrollerandselectthecreatefunctionbutton.Fromthepulldowncommandlist,select(0x03).Fillinthevariousparametersexactlyasshownbelow.Thenameofthisfunctionisrdvfdstatus(typedin2places).Pressnext.

Page 14: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)

Thenextscreenconfirmsyoursettingsforthesecondfunction.PressOK

Page 15: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)

HighlighttheModbuscontrollerandselectthecreatefunctionbutton.Fromthepulldowncommandlist,select(0x06).Fillinthevariousparametersexactlyasshownbelow.Thenameofthisfunctioniswrtvfdspeed(typedin2places).Pressnext.

Page 16: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)

Thenextscreenconfirmsyoursettingsforthethirdfunction.PressOK

Page 17: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)

Thisisthefinalconfirmationscreen.Ifeverythinglooksasitshould,pressOK

Page 18: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)

Step5

SetupthediagnosticswindowstotesttheModbustoVFDconnection.

FromthediagnosticsmenuselectModbusandRegfile.

Page 19: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)

Thiswillopentwowindows.TheModbuswindow,onceexpanded,willshowyouthethreefunctionsyoujustcreatedandtheircurrentstatusalongwithsometiminginformation.TheRegfilewindow,onceexpanded,willshowyouthecurrentModbusregistercontentsforthecommand,status,andspeedregistersfortheVFD.ThestatusregisterisreadingtheVFDstatusregisterbasedonthepollratesetintheModbussetup.ThewriteregisterscontainthevaluessetbyMach4tobesenttotheVFD.Onceavalueisputintoeitherwriteregister,itwillbesenttotheVFDbasedonthePollrate.

Page 20: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)

DoubleclickontheModbusspeedregisterandenterthevalue10000.Thisrepresents100.00%ofthemaximumspeedsetintheVFDpreviously(maxspeedis400HZ).400Hz*60sec=24,000RPM.

Page 21: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)

Doubleclickonthecommandregisterandenterthevalue1.Thespindleshouldrunclockwiseatfullspeed.

Page 22: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)

Enterthevalue5tostopthespindle.

Enterthevalue2toreversethespindle.

Atthispointyoushouldbeabletosetthespeedtoanyvaluebetween0and10000andrunthespindleineitherdirection.

Page 23: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)

Step6

DownloadtheLUAscriptfromthefollowinglocation:

https://code.porkrind.org/david/mach4-vfd/blob/master/Huanyang_GT_VFD.lua

ThiscodewasoriginallywrittenwiththePMCeditor,butwasmodifiedbymyson,DavidtoaddthenecessarylogicandvaluesthatIcouldn’tgetthePMCeditortodo.

PlacethedownloadedcodeinthePMCfolderinsidetheMach4mainfolderasshownbelow.

NotethefiletypeandmakesureitisaLUAfileandnotatextfile.Sometimesthingsgetalteredwhendownloadingtodifferentmachines.

ThiscodewillneedtobeslightlymodifiedifthecommandbitsinyourVFDaredifferentthantheHuanyangGT.

Page 24: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)

RestartMach4andselectthescreeneditorintheoperatormenu.

Selectthetop-levelscreeninthelefthandcolumn.GotothebottomleftandlocatethePMCline.Clickonthe3dotsontheright.SelecttheHuanyang_GT_VFD.Besuretochecktheboxnexttothename.Exitthescreeneditorbyclickingitsbuttonintheoperatormenu.

Page 25: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)

YoucannowcontrolthespindlefromeitherthebuttonsorwiththeMcommandsthroughtheMDIinterface.TheMDIinterfacenowrequiresthatthestartbuttonbepressedtoenterthecommands.ThespeedcanonlybeenteredthroughtheScommandthroughtheMDIinterface.

AllsupportedcommandsexecutefromGcode.

Questions,Comments,andimprovementsarewelcome.([email protected])

HaveFunwithyournewspindlecontroller!

Page 26: Connecting a VFD to Mach4 through the Modbus-v5...Connecting a VFD to Mach4 through Modbus (RS485) V2 June 2019 Bill Caldwell bill@caldwellfam.net Connecting a spindle controller (VFD)