<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to CAM definition in PLC</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8d9880979a/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8d9880979a/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/8d9880979a/</id><updated>2020-02-27T14:00:48.762000Z</updated><subtitle>Recent posts to CAM definition in PLC</subtitle><entry><title>CAM definition in PLC</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8d9880979a/?limit=25#acda" rel="alternate"/><published>2020-02-27T14:00:48.762000Z</published><updated>2020-02-27T14:00:48.762000Z</updated><author><name>wfuehrer</name><uri>https://forge.codesys.com/u/wfuehrer/</uri></author><id>https://forge.codesys.com67204cc32d9e5037ad8b6ea9d4abef9cccfe120a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Here is a Self made cam (sinus) that works!&lt;br/&gt;
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!&lt;/p&gt;
&lt;p&gt;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!&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #40BF00;"&gt;CAM_Table: SMC_CAMTable_UINT_128_1 := (fEditorMasterMin := 0 ,fEditorMasterMax := 360, &lt;br/&gt;
                        fEditorSlaveMin := 0 ,fEditorSlaveMax := 180, &lt;br/&gt;
                        fTableMasterMin := 0, fTableMasterMax := 360,&lt;br/&gt;
                        fTableSlaveMin  :=0 ,fTableSlaveMax := 180);&lt;/span&gt;&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;CAM&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;MC_CAM_REF&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;byType&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="n"&gt;byVarType&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="n"&gt;xStart&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;xEnd&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="mi"&gt;360&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nElements&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="mi"&gt;128&lt;/span&gt;&lt;span class="o"&gt;);&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;span&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;The bByVartype gives the way the data from the table will be interpreted:&lt;br/&gt;
ByVarType   1: INT&lt;br/&gt;
        2: UINT&lt;br/&gt;
        3: DINT&lt;br/&gt;
        4: UDINT&lt;br/&gt;
        5: REAL&lt;br/&gt;
        6: LREAL&lt;/p&gt;
&lt;p&gt;Then a program for the definition of the cam&lt;br/&gt;
&lt;span style="color: #4000FF;"&gt;&lt;br/&gt;
IF NOT(x_test) THEN&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;FOR i:=0 TO 127 DO&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;CAM_Table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Table&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="n"&gt;REAL_TO_UINT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;32767&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;SIN&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;INT_TO_REAL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;127.0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;2.0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;PI&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;END_FOR&lt;br/&gt;
x_test := TRUE;&lt;br/&gt;
END_IF&lt;br/&gt;
Cam.pce := ADR (CAM_Table);&lt;/p&gt;
&lt;p&gt;The amplitude of the Sinus should not be more than 32767 if the data interpreted from the table are in INT (16 bits)&lt;/p&gt;
&lt;p&gt;This amplitude of the Table will act directly on the amplitude of the movement.&lt;/p&gt;
&lt;p&gt;Then call the program of the cam like describe in the past post.&lt;br/&gt;
It works&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: Capture_sinue.JPG" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=670"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>CAM definition in PLC</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/8d9880979a/?limit=25#d34b" rel="alternate"/><published>2020-02-27T14:00:48.465000Z</published><updated>2020-02-27T14:00:48.465000Z</updated><author><name>wfuehrer</name><uri>https://forge.codesys.com/u/wfuehrer/</uri></author><id>https://forge.codesys.com28b9089d677cfc478b716299f38e4689b982cff4</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;br/&gt;
I'm trying to start a 'self made' cam in the PLC.&lt;br/&gt;
I've tryed to understand the example given in the PLCopenMultiCam.project.But I have some issue on it.&lt;br/&gt;
Could someone give me an exmaple of Codesys program that use a cam calcultated in the PLC itself?&lt;/p&gt;
&lt;p&gt;Here is my actual declaration&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #408000;"&gt;CAM_Table: SMC_CAMTable_UINT_128_1 := (fEditorMasterMax := 360, fEditorSlaveMax := 360, fTableMasterMax := 360,fTableSlaveMin:=0 ,fTableSlaveMax := 360);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;CAM: MC_CAM_REF := (byType := 0,byVarType:=1,xStart:=0, xEnd := 360, nElements := 128);&lt;br/&gt;
and program is like this&lt;br/&gt;
&lt;span style="color: #0000FF;"&gt;IF NOT(x_test) THEN&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;FOR i:=0 TO 127 DO&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;CAM_Table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Table&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;REAL_TO_UINT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;127&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;360&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;END_FOR&lt;/p&gt;
&lt;p&gt;x_test := TRUE;&lt;br/&gt;
END_IF&lt;br/&gt;
Cam.pce := ADR (CAM_Table);&lt;/p&gt;
&lt;p&gt;Then I use a virtual axis in velocity used as master&lt;br/&gt;
and I start the slave with a MC_CamTableSelect then a MC_CamIn&lt;br/&gt;
All is well working as long as I try to start a CamIn... I have a library exception.&lt;/p&gt;
&lt;p&gt;There are not a lot of documentation according to the CAM in the system.&lt;br/&gt;
Could someone help me understanding what does what and how to make it run?&lt;br/&gt;
Thanks&lt;br/&gt;
Williams&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: Codesys_Cam1.jpg" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=669"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>