You are on page 1of 6

ModbusPLCProgrammingwithPanasonicAFPXPLC

JimAmos
January16,2014

Introduction
Forthisexercise,IconnectedaPanasonicAFPXC14RtoanAppliedMotionSTM24QF3AEintegratedstepper
drive.IprogrammedthePLCtocommandsimplemovesusingModbus/RTUprotocolandRS232
communication.UserinputwasaccomplishedbywiringapushbuttonswitchtotheX4digitalinput.Imusing
theFPWINGRfreedemoversionofPanasonicPLCprogrammingsoftware.

SerialConnection
Modbus/RTUcanuseRS232,RS422orRS485asaphysicallayer.Itcanuseanybitrateandanychoiceof
parityandstopbits.Itisthejoboftheusertomakesurebothsidesaresetthesameandproperlyconnected.
FortheseexamplesIusedanRS232,threewireconnection(RX,TX,andGND),38400bpsandnoparity.The
AFPXPLCusestheoptionalCOM5Cassetteadapterthathastwoconnectionpoints.COM1isanEthernetport
COM2isthescrewterminalRS232connectionpoint.

SerialPortSettings
Onthedriveend:useSTConfiguratortosetthedriveforModbusmode,commandmode21(pointtopoint
positioning),38400bps.Ourdrivesarealwayssetfornoparity.Thisisalsowhereyouwillenterthedrives
address;1hasbeenchosenforthisexample.

AfterclosingSTConfigurator,besuretopowercycletheSTM24soitwakesupatthecorrectbitrate.

OnthePLCside,ImconnectingthedrivetotheAFPXCOM2portontheCOM5adaptor.ThePLCcomeswitha
serialprogrammingcablethatIconnectedtoanFTDIbasedUSBserialadaptorforprogrammingwithFPWIN
GRsoftwarefromPanasonic.

RegisterMapping
TheModbusprotocolisallaboutmovingdatafromthememoryofonedevicetothatofanother.Youcan
moveaslittleasonebitoryoucanmoveoneormore16bitwords.Mostparametersandcommandsareone
16bitword.Movedistance(DI)is32bitsinourdrivesasaresomeofthemonitorvalues.Forthe32bitvalues
wehavetopayattentiontowordorderorendianess.
InourModbusimplementationwedefaulttohavingthebigendof32bitvaluesinthefirstwordofmemory.
Thatsbigendian.MyAFPXusesbigendiansoIdontneedtosettheendianregisterto1touselittleendian.
ThesearetheModbusregistersthatwellbeusingintheSTM24:
40125=commandregister
40123=endianregister
40028...40032=moveparameters(AC,DE,VEandDI)
40043...40045=jogparameters(JA,JLandJS)
40001...40015=immediateregistersformonitoringthedrive(AL,SC,IT,IU,etc)

Exercise1:PointtoPointMove
ForthisfirstexerciseIllmakeasimplefeedcommandbasedonpreviouslystoredacceleration,deceleration,
velocityanddistanceparametersintheSTM24.IusedourSCLUtilitytosetthoseparameters.TheFPXhas
generalpurposememoryarea(Dlocations)intherangeofD0throughD1659.Thisgivesus160016bitword
locations.WellusethoseforModbustransfers.

ImusingtheFtypehighlevelinstructiontoloadOpcode0x66intoDTregister20.ThisistheOpcodeforour
SCLFeedtoLength(FL)command.IllloadthedrivesaddressintoregisterDT10andloadtheCOM2(H2)word
intoregisterDT11.TolaunchthemoveIllusetheExecutableinstruction(F145)tosendthe0x66tothe
STM24scommandregister40125.ForsomeunknownreasonModbusadsorsubtractsregistersbyoneortwo
sometimessothatswhyweseeK124ratherthanK125.
Exercise2:SpeedChange
InthenextexercisewellletthePLCchangethespeedofthemovewhenX2istriggered.Thisloadsthedrives
Vregisterwithavelocityvalue,whichisexpressedinunitsof0.25ofoneRPM.Inthiscase,480x0.25=120
RPM.TheModbusregisteronthedriveforvelocityis40030soweload240intoK29ratherthanK30.

Exercise3:ChangeDistance
NowImgoingtoletthePLCsetthedistance.

AgainImusingX4tolaunchamovebasedondefaultvaluesstoredintheSTM.WhenX2risesitsendsthefirst
wordofanewDIvaluethenthefallingedgesendsthesecondword.InthiscaseIsent100,000counts
(000186A0hex).Thereisahighlevelfunction(F1DMV)thatcanbeusedtosenda32bitvalue,butIwanted
toclearlydemonstratetheorderofendianess.

Exercise4:AlarmMonitoring
Mostapplicationswouldwanttomonitorthehealthofthedrive.ThenextexampleshowsmyX2input
triggeringareadofthealarmregister40001.Thismonitoringwouldnormallybedonewithaninternaltimer
settomonitorthealarmcodeeveryfewmilliseconds.Theresultswouldbecomparedtostoreddatausing
logictodeterminecorrectiveactionsandornotificationtotheoutsideworld.ForsimpledemonstrationI
manuallystalledtheSTM.Itsoptionalencoderdetectedthestallandchangedthealarmcodefrom0to1
whichwasloadedintotheFPXregister90.


CompleteprojectfilesfortheFPWINGRsoftwareareavailableatwww.appliedmotion.com.

You might also like