User Tools

Site Tools


plc:spindle_speed_control_through_-10v_dac_channel_et10

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plc:spindle_speed_control_through_-10v_dac_channel_et10 [2017/05/22 23:24] skirillovplc:spindle_speed_control_through_-10v_dac_channel_et10 [2022/09/13 13:51] (current) ivan
Line 13: Line 13:
 == PLC controller (Hardware) == == PLC controller (Hardware) ==
  
-DAC offset register is mapped to address 0x32 of [[mycnc:extern_variables|Extern CNC Variables]] Area.+DAC offset register is mapped to address 0x32 of [[mycnc:extern_variables|Extern CNC Variables]] array.
 <code c>#define EXT_ET5_DAC_OFFSET 0x32</code> <code c>#define EXT_ET5_DAC_OFFSET 0x32</code>
  
Line 20: Line 20:
 high 4 bits is DAC channel high 4 bits is DAC channel
  
-Message PLCCMD_SET_CNC_EXTVAR should be sent to myCNC control core from PLC to get access [[External CNC Variables]], then 2 ms delay should be initiated to push the message from PLC to myCNC Core.+Message PLCCMD_SET_CNC_EXTVAR should be sent to myCNC control core from PLC to get access [[mycnc:extern_variables|Extern CNC Variables]], then 2 ms delay should be initiated to push the message from PLC to myCNC Core.
  
 <code c>#define PLCCMD_SET_CNC_EXTVAR 1020</code> <code c>#define PLCCMD_SET_CNC_EXTVAR 1020</code>
Line 32: Line 32:
 command=0x32;//EXT_ET5_DAC_OFFSET              //setup command register (var00) for DAC register access command=0x32;//EXT_ET5_DAC_OFFSET              //setup command register (var00) for DAC register access
 parameter=dac_value+(2<<12);                   //setup parameter register (var01), DAC channel is #2 parameter=dac_value+(2<<12);                   //setup parameter register (var01), DAC channel is #2
-texit=timer+2;do{timer++;}while(timer<texit);  //2ms delay ti push the message +texit=timer+2;do{timer++;}while(timer<texit);  //2ms delay to push the message 
 </code> </code>
  
Line 47: Line 47:
 {{doc-mycnc-dac-offset.png}} {{doc-mycnc-dac-offset.png}}
  
 +=== New functionality for DAC control ===
 +
 +As of September 2022, the firmware for the ET10 boards has been updated to make DAC control easier. For instance, now users can run code such as this:
 +
 +<code C>main()
 +
 +{  timer=0;
 +  proc=plc_proc_spindle;
 +  val=eparam;  //for ET6-ET9
 +  
 +  //if (val>0xfff) {val=0xfff;};
 +  //if (val<0) {val=0;};  //for ET10 -ET12
 +  
 +  val=2048+val/2;
 +  
 +  if (val>0xFFF) {val=0xFFF;};  dac01=val;
 +  gvarset(7371,eparam); 
 +  timer=30;do{timer--;}while(timer>0); //Spindle State  
 +  
 +  dac01=val;  
 +  
 +  portclr(OUTPUT_CCW_SPINDLE);
 +  portset(OUTPUT_SPINDLE);  
 +  gvarset(7370,1);timer=30;do{timer--;}while (timer>0); //Spindle State
 +  gvarset(7371,eparam);timer=30;do{timer--;}while (timer>0); //Spindle Speed Mirror register  
 +  //gvarset(7372,0);//Mist State
 +  
 +  //timer=30;do{timer--;}while (timer>0); //
 +  //gvarset(7373,0);//Flood State
 +  //timer=30;do{timer--;}while (timer>0); //</code>
 +  
 +Here, we are utilizing the usual ''dac01'' variable instead of the more complex solutions used in the past:
 +
 +{{:plc:dac-et10-new-001.png}}
 +
 +You can change the DAC used in the following config window, however it will still be listed as ''dac01'' in the PLC:
 +
 +{{:plc:dac-et10-new-002.png}}
 +
 +Please note that since it is necessary to have a voltage value between -10 and +10 V, the value of 2048 is assigned to 0V. Therefore, for the maximum value we will be adding 2048 (i.e.,  the original value divided by 2, as can be seen in the   ''val=2048+val/2'' line).
plc/spindle_speed_control_through_-10v_dac_channel_et10.1495509880.txt.gz · Last modified: 2017/05/22 23:24 by skirillov

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki