Thinking that my program can't be used in this situation

Thread Starter


Joined Nov 8, 2011
Hello everybody,

I finished a program to measure the moving head's vertical position.
The program works fine when the stepper motor and head moves generally. However, it is used in electrical sparking machine. That is the head oscillates upward and downward at high frequency when the -ve probe and +ve workpiece touch with each other (like the make and break of a relay), 6 ampere current draws at that moment. Then, unreasonable measured data come out from the 7 segments LEDs.

At first, I suspect that it is caused by the interference. And I made all the shielding, used optisolator to seperate the high and low voltage circuit but it does suceed. The interference is so serious that my LCD TV which is near to it have distorted image during sparking.

Two lines which are the step upward and step downward in stepper driver circuit enter PIC controller as two external interrupts. After doing calculation, readouts are output. From scope, as much as 30KHz short pulse observed in these two input lines. I tried to connect 150p capacitors
to these lines to ground but still the short pulse can't be filter during sparking? Can someone can figure it out? In the program, the two external interrupt routines composed of a few instrucitons of "if" causes. The controller runs at 20MHz. Will the cause is the interrupt events occurring too frequently that some of them are missed or will the main program can't share the time to be serviced? Or,? is
the CNY17 optoisolator that I used is not suitable?