Originally Posted by
Tracid
<snip>
I am using a microcontroller with 8 bit registers ( PIC ) so i can break down each
range(X and Y) into 256 positions.At the system reset the motors find their
zero positions (0,0) and all the following desired positions are searched
relatively to the actual position.
What i need:
i thought about using two separate Timer modules for both motors and
instead of switching the move between them , rotate both at the same time
and for the same time but with different speed.So if X motor have to move
100 positions and Y motor have to move only 50 positions that means X have
to do two times more and thus it have to move two times faster if i want
them to arrive at the destination at the same time.(so timer interrupts move the motors some steps)
I also have to place into account that theres a desired avarage(or
reference) speed at which one motor moves and the second motors speed is
referenced to this value.
So this is the description of my problem.
Since you are familiar with CNCs i thought maybe you can recommend me some ideas.
My application is very time-sensitive so i must avoid mathematical
calculations which steal a lot of processing time.
<snip>
!
Yes, this is good thinking.
Do a search on phase accumulators for the background but basically...
if you have a finite sized accumulator (i.e. adder register) and add a smaller or same sized value to it at regular intervals it will overflow at a frequency equal to the ratio of 2 raised to the power of the register size, to the addend. The overflow (carry out) can be used as a step signal for your axis.
For example, using an 8 bit accumulator, add 3 to the accumulating sum once every millisecond and the carry out from the accumulator will occur every 256/3 milliseconds.
similarily by adding 256 every millisecond you will have a step every 256/256=1 millisecond.
Note that the frequency resolution is 1 bit :-)
The computational overhead involves a load register, an add, a branch if carry set, and an output bit.... very fast ;-)
<edit added>
Also note that the vector velocity(below) is only calculated once before the relatively long (time) move.
So to succesfully interpolate your two axes:
1. select a maximum velocity and use as the frequency of your interrupt timer.
2. calculate the vector velocity = feedrate / sqrt((dist X * dist X) + (dist Y * dist Y)).
so that feed X = dist X * vector velocity
and feed Y = dist Y * vector velocity
3. use an X and a Y accumulator in your interrupt routine to sum feed X and feed Y
4. track your distance travelled to end motion with a zero velocity input.
The motion will complete approximately simultaneously within the tolerances of your arithmetic.
embrace enthusiasm to accomplish the task
Gary Davies... www.durhamrobotics.com