1

I am implementing a code that create a pulse output via a digital IO for stepper driver. However i notice when there is a 'stray' program running (ie anti virus), the output(duty cycle) will become inconsistent. Is there anyway to assign that thread to 1 single CPU in multi-core CPUs so that other programs even windows managed cannot assign thread to that CPU? I am using C# as programming.

1 Answers1

4

The only way to do this would be to enumerate every other process in the system and set its affinity mask to exclude the CPU you're trying to save for your thread. You'll have to keep doing this, too, as additional processes may be created at any time.

A better approach is to simply run your process in the "real time" priority class and then set your thread priority to "time critical". (I hope it doesn't have to be actually executing at too high a percentage of the total time.)

However, interrupt handlers and DPC routines will still be able to interfere with your thread.

Your real problem here is that Windows is not intended for nor suited for tasks with "hard" real-time requirements, and yours sounds like that.

I suggest using a microcontroller that's dedicated to generating the variable-duty-cycle pulses your stepper motor needs.

What is the range of frequency and duty cycle the stepper motor needs? There may be another way to solve your problem.