mycnc:timers
Table of Contents
myCNC Timers
myCNC controllers support up to 4 timers.
- Each timer can be assigned to any output pin.
- Pulse time (in milliseconds) and Pause time (in milliseconds) can be setup for each timer
- Timers can be enabled/disabled from myCNC software setup dialog or through number of Global Variable registers.
myCNC software configuration dialog to setup Timers is shown below
Global Variable Registers to control myCNC Timers
Variable Name | Address | Description |
---|---|---|
Timer0 | ||
GVAR_TIMER0_ENABLED | 8100 | Writing “0” to this register will disable Timer0, writing “1” will enable Timer0 |
GVAR_TIMER0_PORT | 8101 | Writing to this register will change Output pin connected to Timer0. Writing value is the Output Pin# |
GVAR_TIMER0_PULSE | 8102 | A value written to this register is Timer 0 Pulse width in milliseconds |
GVAR_TIMER0_PAUSE | 8103 | A value written to this register is Timer 0 Pause in milliseconds |
Timer1 | ||
GVAR_TIMER1_ENABLED | 8104 | Writing “0” to this register will disable Timer1, writing “1” will enable Timer1 |
GVAR_TIMER1_PORT | 8105 | Writing to this register will change Output pin connected to Timer1. Writing value is the Output Pin# |
GVAR_TIMER1_PULSE | 8106 | A value written to this register is Timer 1 Pulse width in milliseconds |
GVAR_TIMER1_PAUSE | 8107 | A value written to this register is Timer 1 Pause in milliseconds |
Timer2 | ||
GVAR_TIMER2_ENABLED | 8108 | Writing “0” to this register will disable Timer2, writing “1” will enable Timer2 |
GVAR_TIMER2_PORT | 8109 | Writing to this register will change Output pin connected to Timer2. Writing value is the Output Pin# |
GVAR_TIMER2_PULSE | 8110 | A value written to this register is Timer 2 Pulse width in milliseconds |
GVAR_TIMER2_PAUSE | 8111 | A value written to this register is Timer 2 Pause in milliseconds |
Timer3 | ||
GVAR_TIMER3_ENABLED | 8112 | Writing “0” to this register will disable Timer3, writing “1” will enable Timer3 |
GVAR_TIMER3_PORT | 8113 | Writing to this register will change Output pin connected to Timer3. Writing value is the Output Pin# |
GVAR_TIMER3_PULSE | 8114 | A value written to this register is Timer 3 Pulse width in milliseconds |
GVAR_TIMER3_PAUSE | 8115 | A value written to this register is Timer 3 Pause in milliseconds |
How to use Timers in Hardware PLC
Here is an example of Timer0 setup in PLC procedure
M169 is Timer0 initialization and start
- M169.plc
main() { gvarset(8101,1); // Setup Out#1 as Timer0 output gvarset(8102,5); // Pulse width is 5ms gvarset(8103,45); // Pause time is 45ms (Period is 5+45=50ms) gvarset(8100,1); //Start Timer0 exit(99); };
M168 is Timer0 stop
The result is shown on a picture below
mycnc/timers.txt · Last modified: 2022/03/07 16:09 by ivan