--- /tmp/arisc.c	2021-09-26 22:37:42.356272166 +0200
+++ ./h3/arisc.c	2021-09-26 22:42:02.696804531 +0200
@@ -172,6 +172,7 @@
     hal_bit_t *cnt_mode; // io
     hal_bit_t *x4_mode; // io
     hal_bit_t *index_enable; // io
+    hal_bit_t *simulate_index; // io
     hal_bit_t *reset; // in
 
     hal_u32_t *a_port; // in
@@ -204,6 +205,7 @@
     hal_bit_t cnt_mode; // io
     hal_bit_t x4_mode; // io
     hal_bit_t index_enable; // io
+    hal_bit_t simulate_index; // io
     hal_bit_t reset; // in
 
     hal_u32_t a_port; // in
@@ -516,6 +518,7 @@
             EXPORT_PIN(HAL_IO,bit,cnt_mode,"counter-mode", 0);
             EXPORT_PIN(HAL_IO,bit,x4_mode,"x4-mode", 0);
             EXPORT_PIN(HAL_IO,bit,index_enable,"index-enable", 0);
+	    EXPORT_PIN(HAL_IO,bit,simulate_index,"simulate-index", 0);
             EXPORT_PIN(HAL_IN,bit,reset,"reset", 0);
 
             EXPORT_PIN(HAL_IN,u32,a_port,"A-port", UINT32_MAX);
@@ -945,11 +948,26 @@
         if ( eh.pos_scale < 1e-20 && eh.pos_scale > -1e-20 ) eh.pos_scale = 1.0;
         eh.pos = ((hal_float_t)eh.counts) / eh.pos_scale;
 
-        if ( ep.index_enable != eh.index_enable ) {
-            ep.index_enable = eh.index_enable;
-            enc_ch_data_set(ch, ENC_CH_Z_USE, (enc_z_pins_ok(ch) ? eh.index_enable : 0), 0);
+	if ( !(eh.simulate_index) ) {
+            if ( ep.index_enable != eh.index_enable ) {
+                ep.index_enable = eh.index_enable;
+                enc_ch_data_set(ch, ENC_CH_Z_USE, (enc_z_pins_ok(ch) ? eh.index_enable : 0), 0);
+            } else {
+                eh.index_enable = enc_ch_data_get(ch, ENC_CH_Z_USE, 0);
+            }
         } else {
-            eh.index_enable = enc_ch_data_get(ch, ENC_CH_Z_USE, 0);
+            if (eh.index_enable) {
+                if (!(ep.index_enable)) {				// first time call - prepare
+                    ep.pos = ceil(eh.pos);				// ep.pos is next full revolution
+                    ep.index_enable = 1;
+                } else if ((eh.pos - ep.pos) >= 0.0) {			// wait for full revolution
+                    eh.pos -= ep.pos;					// reset full revolutions, keep fractional part
+                    ep.counts = eh.counts = eh.pos * eh.pos_scale;	// set counts to current position
+                    enc_ch_pos_set(ch, eh.counts, eh.period_ticks, 0);
+                    eh.index_enable = 0;
+                    ep.index_enable = 0;
+                }
+            }
         }
 
         if ( eh.reset ) {
