Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

CAM definition in PLC

wfuehrer
2014-06-10
2024-01-18
  • wfuehrer - 2014-06-10

    Hi,
    I'm trying to start a 'self made' cam in the PLC.
    I've tryed to understand the example given in the PLCopenMultiCam.project.But I have some issue on it.
    Could someone give me an exmaple of Codesys program that use a cam calcultated in the PLC itself?

    Here is my actual declaration

    CAM_Table: SMC_CAMTable_UINT_128_1 := (fEditorMasterMax := 360, fEditorSlaveMax := 360, fTableMasterMax := 360,fTableSlaveMin:=0 ,fTableSlaveMax := 360);

    CAM: MC_CAM_REF := (byType := 0,byVarType:=1,xStart:=0, xEnd := 360, nElements := 128);
    and program is like this
    IF NOT(x_test) THEN

    FOR i:=0 TO 127 DO

    CAM_Table.Table [i] := REAL_TO_UINT (  i / 127 * 360);
    

    END_FOR

    x_test := TRUE;
    END_IF
    Cam.pce := ADR (CAM_Table);

    Then I use a virtual axis in velocity used as master
    and I start the slave with a MC_CamTableSelect then a MC_CamIn
    All is well working as long as I try to start a CamIn... I have a library exception.

    There are not a lot of documentation according to the CAM in the system.
    Could someone help me understanding what does what and how to make it run?
    Thanks
    Williams

    IMG: Codesys_Cam1.jpg

     
  • wfuehrer - 2014-06-12

    Here is a Self made cam (sinus) that works!
    All is in the delcaration of the MC_CAM_Ref and the way the data will be interpreted from the cam table to the cam movement itself!

    I still don't know exactly the way the fxxxSlaveMin and Max works, because you can set 360, 180 or other data without any change on the way ot moves!

    CAM_Table: SMC_CAMTable_UINT_128_1 := (fEditorMasterMin := 0 ,fEditorMasterMax := 360,
    fEditorSlaveMin := 0 ,fEditorSlaveMax := 180,
    fTableMasterMin := 0, fTableMasterMax := 360,
    fTableSlaveMin :=0 ,fTableSlaveMax := 180);

    CAM: MC_CAM_REF := (byType := 1,byVarType:=1,xStart:=0, xEnd := 360, nElements := 128);</span>
    

    The bByVartype gives the way the data from the table will be interpreted:
    ByVarType 1: INT
    2: UINT
    3: DINT
    4: UDINT
    5: REAL
    6: LREAL

    Then a program for the definition of the cam

    IF NOT(x_test) THEN

    FOR i:=0 TO 127 DO

    CAM_Table.Table [i] :=   REAL_TO_UINT (32767* SIN ( INT_TO_REAL(i) / 127.0 * 2.0 * PI));
    

    END_FOR
    x_test := TRUE;
    END_IF
    Cam.pce := ADR (CAM_Table);

    The amplitude of the Sinus should not be more than 32767 if the data interpreted from the table are in INT (16 bits)

    This amplitude of the Table will act directly on the amplitude of the movement.

    Then call the program of the cam like describe in the past post.
    It works

    IMG: Capture_sinue.JPG

     

Log in to post a comment.