User Tools

Site Tools


plc:m07_mist_coolant_on

This is an old revision of the document!


M07 - Mist Coolant ON

Normally M07 function is the simplest PLC procedure. It should just turn ON 1 relay and exit. PLC source code will look like -

M07.plc
main()
{
  portset(5);
  exit(99);  //normal exit.
};

Output #5 is used as coolant pin.

According to smart programming books it is a good style to avoid direct numbers in source code (like portset(5)) and use variables/define names instead.

In this case source code will be

M07.plc
#include vars.h
main()
{
  portset(OUT_COOLANT);
  exit(99);  //normal exit.
};

name “OUT_COOLANT is defined in “vars.h” file which is included in the first line.

vars.h
#define OUT_COOLANT   5

Spindle Speed control for ET10_DAC

SPN.plc
#define command     var00
#define parameter   var01
//set Spindle speed control via ET10 DAC channel #1
//Spindle Speed is given in **eparam** register
 
main()
{
  command=0x32; 
  //EXT_ET10_DAC_OFFSET; set ADC offset register address
  parameter=0x800-(eparam/2)+(1<<12);
  //0x800 - is the middle of 12bits range - represents 0V
  //Eparam contains 12bits DAC value in 0V range, ET10 DAC setup in +10V...-10V range, so need to /2
  //Encoder channel number is given in high 12 bits of 16bit word.
 
  message=PLCCMD_SET_CNC_EXTVAR;    
  //setup Message register with command for access to [[External CNC Variables]]
  texit=timer+2;do{timer++;}while(timer<texit);
  //2ms delay to push the command from PLC to myCNC Core
 
 
  //**Set Spindle Speed** is asynchronous operation. 
  //It's better to inform myCNC Software New Spindle Speed applied.
  //Send information about new Spindle Speed to myCNC Software
  message=PLCCMD_REPLY_TO_MYCNC;                   //Command code to send to myCNC software
  command=PLC_MESSAGE_SPINDLE_SPEED_CHANGED;       //Message code
  parameter=eparam;                                //New Spindle Speed information
  timeout=timer+10; do { timer++; } while (timer<timeout); //Delay to push the Message to myCNC Software
 
  gvarset(7371,eparam);           
  //myCNC register #7371 contains actual Spindle Speed. 
  //Another way to inform myCNC software about new Spindle Speed (to display on it DRO for example)
 
 
exit(99);  //normal exit.
};
plc/m07_mist_coolant_on.1500004393.txt.gz · Last modified: 2017/07/13 23:53 by skirillov

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki