#id: flatTRACK_demo_cycle_IN6.py rev2 2026-03-12 oh # Fullmo MovingCap CODE - micropython example. # original file name: flatTRACK_demo_cycle_IN6.py # Demo: position cycle triggered by IN6 input, with IN4 position as start and end position # preconditions: # - MovingCap flatTRACK, FATtrack or shortTRACK # - IN4 and IN6 configured and tested as "Timed Motion Absolute" in the web interface # with different target positions (see "IN Function Configurator" in the web interface) # - IN6 Input function then set to "0000h - off" so this script can use it for action import mcdrive as mc import time while True: # If IN6 goes high, all other IN6 are low and no IN6 action is already set up via web configuration if (mc.ChkIn(6) != 0 and all(mc.ChkIn(i) == 0 for i in range(1, 10) if i != 6) and mc.ReadObject(0x3516, 0x01) == 0): pos_in4 = mc.ReadObject(0x3514, 0x08) # this is IN4 target position in the "IN Function Configurator" pos_in6 = mc.ReadObject(0x3516, 0x08) # this is IN6 target position in the "IN Function Configurator" print("script-based IN6 run started...") if (mc.ChkError() == 0): # Trigger IN4 position run ret = mc.WriteObject(0x3510, 0x02, 0x0404) time.sleep_ms(10) # make sure this run has started while (mc.ChkReady() == 0): time.sleep_ms(1) if (mc.ChkError() == 0): # Trigger IN6 position run ret = mc.WriteObject(0x3510, 0x02, 0x0604) time.sleep_ms(10) while (mc.ChkReady() == 0): time.sleep_ms(1) if (mc.ChkError() == 0): # Back to IN4 target ret = mc.WriteObject(0x3510, 0x02, 0x0404) time.sleep_ms(10) while (mc.ChkReady() == 0): time.sleep_ms(1) # wait for IN6 low again while mc.ChkIn(6) != 0: time.sleep_ms(1) # idle time.sleep_ms(1)