Yurigas75 Posted June 16, 2018 Report Posted June 16, 2018 Hello , It's been a long time since I last wrote here . Now I'm using NJ 501-1300 I would like to know if is it possible to have an array with a variable size and how to use it. Better I explain my problem so maybe you can suggest me a good way. I have several cam tables that I have to use depending on the format required , my idea is to have just a MC_CamIn function and , depending format required, change the cam table. Es. VAR_CamTableInFun (the variable that i want to use in the MC_CamIn function) CAM_Data1 (ARRAY[0..2500] of _sMC_CAM_REF) , CAM_Data2 (ARRAY[0..8500] of _sMC_CAM_REF), CAM_Data3 (ARRAY[0..800] of _sMC_CAM_REF) PAR_CamAxDivSrtMod :=_mcAbsolutePosition; VAR_CamAxDivSrtPos :=LREAL#0.0; VAR_CamAxDivMstSrtDis :=LREAL#0.0; VAR_CamAxDivMstScl :=LREAL#0.0; VAR_CamAxDivSlvScl :=LREAL#0.0; VAR_CamAxDivMstOfst :=LREAL#0.0; VAR_CamAxDivSlvOfst :=LREAL#0.0; PAR_CamAxDivRefTyp :=_mcFeedback; PAR_CamAxDivDir :=_mcPositiveDirection; PAR_CamAxDivBufMod :=_mcAborting; MC_CamIN_1 ( Master :=AxRac, Slave :=AxDiv, CamTable :=VAR_CamTableInFun, Execute :=CMD_AxDivCamIN Periodic :=True, StartMode :=PAR_CamAxDivSrtMod, StartPosition :=VAR_CamAxDivSrtPos, MasterStartDistance :=VAR_CamAxDivMstSrtDis, MasterScaling :=VAR_CamAxDivMstScl, SlaveScaling :=VAR_CamAxDivSlvScl, MasterOffset :=VAR_CamAxDivMstOfst, SlaveOffset :=VAR_CamAxDivSlvOfst, ReferenceType :=PAR_CamAxDivRefTyp, Direction :=PAR_CamAxDivDir, BufferMode :=PAR_CamAxDivBufMod ); VAR_AxDivCamIN_InCam :=Y_CamIN_1.InCam; VAR_AxDivCamIN_InSync :=Y_CamIN_1.InSync; VAR_AxDivCamIN_EndOfProf :=Y_CamIN_1.EndOfProfile; VAR_AxDivCamIN_Indx :=Y_CamIN_1.Index; VAR_AxDivCamIN_Busy :=Y_CamIN_1.Busy; VAR_AxDivCamIN_Active :=Y_CamIN_1.Active; VAR_AxDivCamIN_CmdAb :=Y_CamIN_1.CommandAborted; VAR_AxDivCamIN_Err :=Y_CamIN_1.Error; VAR_AxDivCamIN_ErrID :=Y_CamIN_1.ErrorID; If Format=1 then VAR_CamTableInFun := CAM_Data1 ; elsif Format=2 then VAR_CamTableInFun := CAM_Data2 ; elsif Format=3 then VAR_CamTableInFun := CAM_Data3 ; end_if; So you think is it possible? Of course VAR_CamTableInFun must be an array with variable size, otherwise error size data do not match. Best regards Yuri
innoaloe Posted June 17, 2018 Report Posted June 17, 2018 On it's very core, NJ is still a PLC, so unfortunately such dynamic memory management function is not implemented. IMO if you just have 3 Cam tables, it is way easier to create 3 MC_CamIn instructions and one MC_CamOut. Ensuring the Cam transition is easier by having multiple FBs. In the end if you want to only have one FB, you need to make each Cam Table to be in the same master-slave scale, so the array size of those 3 will be the same.
Crossbow Posted July 20, 2018 Report Posted July 20, 2018 We now have variable size arrays, but you must use them as input or output to a user-defined function block.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now