Upload
others
View
41
Download
0
Embed Size (px)
Citation preview
ConnectingaVFDtoMach4throughModbus(RS485)
V2
June2019BillCaldwell
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.
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
Powergoingoff5IfyouuseadifferentVFDmostlikelytheseaddressesandvalueswillneedtobechangedintheModbusfunctionsandtheLUAcode.
Step2
ItisnecessarytoinstalltheUSBtoRS-485windowsdriverneededfortheconvertor.Followtheinstructionssuppliedwithyourconvertortoinstallthedriver.Oncethedriverisinstalled,notethecomportnumberitisassociatedwith(Com3inthiscase).
Step3
ThisstepsetsuptheMach4ModbuscontrollertosendcommandstotheselectedVFDandreceivestatusbackfromtheselectedVFD.OncethesechangesaremadetheywillbepermanentlystoredintheMach4profileyouarecurrentlyrunning.
Intheconfiguration/controlmenu,selectthePluginstabandenablethefollowingplugins.
SelectthespindletabandfillintheMaxRPMasshownbelow.
IntheConfigure/Controlmenu,selectthePluginspulldownmenuthenselecttheModbusplugin.
BegincreatingthecommunicationspathfromtheComporttotheMach4Modbuscontroller.Fillintheboxexactlyasseeninthefollowingscreen.
ThiscreatesaninstanceoftheModbuscontrollercalledmodbus0settoRTUmode.Generallythedefaultvalueswillwork.Makesuretocheckthezerobasedregisteraddressingmodebox.
SelecttheporttocorrespondtotheportattachedtotheUSBtoRS484convertershownintheWindowsdevicemangerwindow(Com3inthisexample).Continuesettingtheparametersasshownbelow.
Whenyouaredonewiththisstepyouwillseetheconfirmationwindowasseenbelow.Yourcomportmaybedifferentthanshowninthisexample.
YouwillnowseetheModbuscontroller,justcreated,intheleftcolumnandasummaryoftheModbussettingsjustselectedontheright.SelectOK.
Step4
ThenextstepscreatethreenecessaryModbusfunctionstowritetotheVFDcommandregister,writetotheVFDspeedregister,andreadtheVFDstatusregister.Pleasemakesurethefunctionnamesareenteredexactlyasshown.TheyneedtomatchthecorrespondingfunctionnamescontainedintheLUAscripttofollow.
HighlighttheModbuscontrollerandselectthecreatefunctionbutton.Fromthepulldowncommandlist,select(0x06).Fillinthevariousparametersexactlyasshownbelow.Thenameofthisfunctioniswrtvfdcmd(typedin2places).Pressnext.
Thenextscreenconfirmsyoursettingsforthefirstfunction.PressOK
HighlighttheModbuscontrollerandselectthecreatefunctionbutton.Fromthepulldowncommandlist,select(0x03).Fillinthevariousparametersexactlyasshownbelow.Thenameofthisfunctionisrdvfdstatus(typedin2places).Pressnext.
Thenextscreenconfirmsyoursettingsforthesecondfunction.PressOK
HighlighttheModbuscontrollerandselectthecreatefunctionbutton.Fromthepulldowncommandlist,select(0x06).Fillinthevariousparametersexactlyasshownbelow.Thenameofthisfunctioniswrtvfdspeed(typedin2places).Pressnext.
Thenextscreenconfirmsyoursettingsforthethirdfunction.PressOK
Thisisthefinalconfirmationscreen.Ifeverythinglooksasitshould,pressOK
Step5
SetupthediagnosticswindowstotesttheModbustoVFDconnection.
FromthediagnosticsmenuselectModbusandRegfile.
Thiswillopentwowindows.TheModbuswindow,onceexpanded,willshowyouthethreefunctionsyoujustcreatedandtheircurrentstatusalongwithsometiminginformation.TheRegfilewindow,onceexpanded,willshowyouthecurrentModbusregistercontentsforthecommand,status,andspeedregistersfortheVFD.ThestatusregisterisreadingtheVFDstatusregisterbasedonthepollratesetintheModbussetup.ThewriteregisterscontainthevaluessetbyMach4tobesenttotheVFD.Onceavalueisputintoeitherwriteregister,itwillbesenttotheVFDbasedonthePollrate.
DoubleclickontheModbusspeedregisterandenterthevalue10000.Thisrepresents100.00%ofthemaximumspeedsetintheVFDpreviously(maxspeedis400HZ).400Hz*60sec=24,000RPM.
Doubleclickonthecommandregisterandenterthevalue1.Thespindleshouldrunclockwiseatfullspeed.
Enterthevalue5tostopthespindle.
Enterthevalue2toreversethespindle.
Atthispointyoushouldbeabletosetthespeedtoanyvaluebetween0and10000andrunthespindleineitherdirection.
Step6
DownloadtheLUAscriptfromthefollowinglocation:
https://code.porkrind.org/david/mach4-vfd/blob/master/Huanyang_GT_VFD.lua
ThiscodewasoriginallywrittenwiththePMCeditor,butwasmodifiedbymyson,DavidtoaddthenecessarylogicandvaluesthatIcouldn’tgetthePMCeditortodo.
PlacethedownloadedcodeinthePMCfolderinsidetheMach4mainfolderasshownbelow.
NotethefiletypeandmakesureitisaLUAfileandnotatextfile.Sometimesthingsgetalteredwhendownloadingtodifferentmachines.
ThiscodewillneedtobeslightlymodifiedifthecommandbitsinyourVFDaredifferentthantheHuanyangGT.
RestartMach4andselectthescreeneditorintheoperatormenu.
Selectthetop-levelscreeninthelefthandcolumn.GotothebottomleftandlocatethePMCline.Clickonthe3dotsontheright.SelecttheHuanyang_GT_VFD.Besuretochecktheboxnexttothename.Exitthescreeneditorbyclickingitsbuttonintheoperatormenu.
YoucannowcontrolthespindlefromeitherthebuttonsorwiththeMcommandsthroughtheMDIinterface.TheMDIinterfacenowrequiresthatthestartbuttonbepressedtoenterthecommands.ThespeedcanonlybeenteredthroughtheScommandthroughtheMDIinterface.
AllsupportedcommandsexecutefromGcode.
Questions,Comments,andimprovementsarewelcome.([email protected])
HaveFunwithyournewspindlecontroller!