void Update()
    {
        // don't bother if not connected to decoder...
        if (!nt.isConnected())
        {
            tryToConnect(1); // fast connection retry?
            if (!nt.isConnected())
            {
                return;
            }
        }

        nframe++;
        // don't update the code-stuff if in slowdown mode..
        if (nframe % Math.Max(FRAMESPERCODEBIT, 1) != 0)
        {
            return;
        }

        wasRunning = isRunning;
        isRunning  = nt.updateStimulusState(nframe);
        if (!isRunning)
        {
            if (wasRunning && sequenceCompleteEvent != null) // we have just finished a nt sequence
            {
                sequenceCompleteEvent.Invoke();
            }
            return;

            nt.startExpt(10, 10, .1f);
        }
        stimulusState = nt.getStimulusState();
        Debug.Log(stimulusState);
        if (stimulusState != null && stimulusState.targetState >= 0)
        {
            logstr += stimulusState.targetState > 0 ? "*" : ".";
        }
        else
        {
            logstr += String.Format("{0:d} ", nframe);
        }
        if (logstr.Length > 60)
        {
            Debug.Log(logstr); logstr = "";
        }
        nt.sendStimulusState(lastframetime);
    }