Paul Hoshovsky
New Member
Hello
Over the years there have been posts on the driving of stepping motors. Having read some of them, I would like to pose a question on how fast an 18M2 can drive an output pin to a stepping motor drive. I have written a very simple do loop code and measured on the scope the time elapsed between pulses. The code is:
do
high PinC.1
low PinC.1
loop
For a 18M2 with the setfreq m32, I get a pulse length of 350 us (microseconds) and a high time of 100 us. If I change the code to
do
pulsout PinC.1,10
pulseus 10
loop
For the same chip and frequency, I get a pulse length of 500 us with 40 us for the high time.
I must be missing something quite important. I don't understand how the max output frequency is less than 3kHz. Now I do understand about the overheads in the code generated by the compiler. Yet given that the clock frequency is stated at m32, I thought the output frequency at the pin would be somewhat higher.
It would be nice if someone would take a few minutes to confirm my numbers (assuming the scope, chip, etc is available). Or explain the reason why I cannot get a higher output frequency for the 18M2. The stepping motor drive spec sheet claims that it can accept pulses up to 200 kHz. I would like to prove that this drive manufacturer is correct. If I cannot get a higher speed, then I would need to look at external hardware or alternatives to validate the claim.
regards
Paul
Over the years there have been posts on the driving of stepping motors. Having read some of them, I would like to pose a question on how fast an 18M2 can drive an output pin to a stepping motor drive. I have written a very simple do loop code and measured on the scope the time elapsed between pulses. The code is:
do
high PinC.1
low PinC.1
loop
For a 18M2 with the setfreq m32, I get a pulse length of 350 us (microseconds) and a high time of 100 us. If I change the code to
do
pulsout PinC.1,10
pulseus 10
loop
For the same chip and frequency, I get a pulse length of 500 us with 40 us for the high time.
I must be missing something quite important. I don't understand how the max output frequency is less than 3kHz. Now I do understand about the overheads in the code generated by the compiler. Yet given that the clock frequency is stated at m32, I thought the output frequency at the pin would be somewhat higher.
It would be nice if someone would take a few minutes to confirm my numbers (assuming the scope, chip, etc is available). Or explain the reason why I cannot get a higher output frequency for the 18M2. The stepping motor drive spec sheet claims that it can accept pulses up to 200 kHz. I would like to prove that this drive manufacturer is correct. If I cannot get a higher speed, then I would need to look at external hardware or alternatives to validate the claim.
regards
Paul