Hello,
I am doing a project of building a digital readout (DRO). I use PIC18F452
controller. There are positive and negative sign readout digits when the moving head moves above or below a set zero respectively. Every thing
goes fine when the head move generally. However, when the head or stepper motor was driven up and down rapidly which likes an oscillation, wrong readings appear.
The construction of circuit includes feeding the positive and negative inputing pulses to the stepper driver to the microcontroller's first interrupt pin(INT0) and second interrupt pin(INT1). The program includes two interrupt subrountines to record number of positive and negative steps at every moment. Another subroutine does the multiplication of the number of steps with the length of step, it is a 16bits and 16bits multiplication.
The weird data include a sudden big increment or sudden opposite
sign in the data. I admit that the environment condition is not good because there is high frequency and large current sparkings which were emitted by the motor and relay when the head or motor reverses in directions.
So, there may be one of following cause or some others that I haven't figure out:
1) Sparkings. However, I may rule it out?? because, in the same program,
I write a timer to have readout of each second elapsing and there is no
erratic time readings occur. As well as, I have another IC 18F458 to
have PWM output to control PWM frequency and duty cylce. I haven't
observed any erratic waveform of it from scope, may be the enhance
pwm module have more interferenc immunity??
2) The controller and the program can't cope with the very short interval
time between consercutive pulses inputing to it, because time needed in
doing the multiplication subroutine takes much longer time than this
interval. The controller already run at 40MHz at maximum, is it
sufficient??
Does anyone have the knowledge and experience of this and share the advice and ammendments.
Thanks, and thanks for reading the long descriptions.
I am doing a project of building a digital readout (DRO). I use PIC18F452
controller. There are positive and negative sign readout digits when the moving head moves above or below a set zero respectively. Every thing
goes fine when the head move generally. However, when the head or stepper motor was driven up and down rapidly which likes an oscillation, wrong readings appear.
The construction of circuit includes feeding the positive and negative inputing pulses to the stepper driver to the microcontroller's first interrupt pin(INT0) and second interrupt pin(INT1). The program includes two interrupt subrountines to record number of positive and negative steps at every moment. Another subroutine does the multiplication of the number of steps with the length of step, it is a 16bits and 16bits multiplication.
The weird data include a sudden big increment or sudden opposite
sign in the data. I admit that the environment condition is not good because there is high frequency and large current sparkings which were emitted by the motor and relay when the head or motor reverses in directions.
So, there may be one of following cause or some others that I haven't figure out:
1) Sparkings. However, I may rule it out?? because, in the same program,
I write a timer to have readout of each second elapsing and there is no
erratic time readings occur. As well as, I have another IC 18F458 to
have PWM output to control PWM frequency and duty cylce. I haven't
observed any erratic waveform of it from scope, may be the enhance
pwm module have more interferenc immunity??
2) The controller and the program can't cope with the very short interval
time between consercutive pulses inputing to it, because time needed in
doing the multiplication subroutine takes much longer time than this
interval. The controller already run at 40MHz at maximum, is it
sufficient??
Does anyone have the knowledge and experience of this and share the advice and ammendments.
Thanks, and thanks for reading the long descriptions.