Page 1 of 1

Stepper problems with speed.

Posted: Thu Feb 06, 2020 2:48 pm
by astro1234
Hi.
I am having problems controlling two stepper motors with different
Speeds, using a pic 18F26K22 chip.
I am using two timers, so that I can control the two stepper motors speeds, but although
The timers show different speeds, the steppers are running both at the same speed.
Change one timer, and this effects the other stepper.
Am I using the timers’ correctly? (This is my first time using timers).
Can the chip operate ok with the two timers ? , or do I need a different pic chip.
Regards Roy.

PS. although this works in the simulation, it does not run right on the test bench .
Flow code V8.2.1.14
Win 10 pro.

Re: Stepper problems with speed.

Posted: Fri Feb 07, 2020 11:25 am
by Benj
Hello,

Having multiple independent timers on a single device should be no problem.

I might start by trying to reduce the code inside the interrupt routines to allow the timers to fire without potentially colliding with each other. For example timer 2 fires and starts being serviced. By the time you leave the macro timer 4 has fired and you start servicing that one, then when you leave timer 4 timer 2 has fired again etc. Changing the interrupt rate wouldn't have much effect in this case.

Try this and see if it's any better.
18F26K22_TWO_STEPPERS _TIMER.fcfx
(31.18 KiB) Downloaded 182 times
You could also try reducing the timer interrupt frequencies and see if this helps things, in which case you might need to use a faster device e.g. a 16-bit PIC running at 140MHz.