User Tools

Site Tools


plc:plc_examples

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
plc:plc_examples [2018/09/09 19:39]
skirillov
plc:plc_examples [2019/07/12 12:51] (current)
ivan
Line 177: Line 177:
  
 </​code>​ </​code>​
 +
 +=== Eliminating tangential knife spin at the start of the program (M212) ===
 +
 +Because of how the system records angles, the software shows angles larger than 360 degrees (one full revolution) if a number of turns in the same direction have been taken by the knife. For example, if the knife has turned around its axis from 0 degrees twice in the positive direction, the angle now will be recorded as 720 degrees (2 full revolutions). After the program completes, and the angle is left at this number, the next time the program starts, the knife will rotate back until the angle is equal to zero. This behaviour is not ideal for some users, as it can extend the cutting process time. 
 +
 +The M212 macro exists to remove this positive/​negative degree turn that is larger than 360 degrees at the program start. This is useful if the user wants to stop the knife from spinning back multiple times to its 0 position on the c-axis as the program is starting (however, this will still allow the knife to rotate an angle less than a full revolution in order to align itself properly).
 +
 +The macro is provided with the myCNC software, and looks as follows: ​
 +
 +<​code>​main()
 +{
 + ​c=gvarget(17006);​ //get C-position in PLC units (0.01 degree)
 +
 + ​m=18000;​ //180 degree in PLC units (0.01 degree)
 + if (c>m)
 + {
 +  do{ c=c-36000; }while (c>m); //remove the whole positive turns 
 + };
 +
 + ​m=0-m;​ //-180 degree in PLC units (0.01 degree)
 + if (c<m)
 + {
 +   do{ c=c+36000; }while (c<m); //remove the whole negative turns 
 + };
 +
 + ​gvarset(7080,​1000);​ //set speed 3000 degree/s;
 + ​timer=10;​do{timer--;​}while(timer>​0);​
 + ​g0moveA(0x0,​0x20,​0-c);​ //C axis, move to C=0
 + ​timer=200;​do{timer--;​}while(timer>​0);​
 + do { code=gvarget(6060);​ }while(code!=0x4d);//​wait till motion finished
 +
 + ​timer=100;​do{timer--;​}while(timer>​0);​ //delay for any case
 +
 + ​exit(99);​
 +};</​code>​
 +
 +This macro can be added to the DXF footer in **Settings > Config > DXF Import Settings** to run every time when the program generated from an imported DXF file finishes running. ​
  
  
Line 403: Line 440:
 }; };
 </​code>​ </​code>​
- 
plc/plc_examples.txt · Last modified: 2019/07/12 12:51 by ivan