> From: Chris Albertson [mailto:[email protected]]
> If using a microcontroller to do steps, you would be taking advantage of
> one of the on-chip hardware counters.  These have a top speed of some MHz.
>  and then the software only has t stuff a few registers to set up the
> required step rate.

Actually, that's just one way although for the smaller 8 bit Arduino's it 
appears to be the method of choice.

Think of it a different way.  The trajectory planner knows what the maximum 
step rate is.  That's part of the system configuration.  For each step you need 
the time high and the time low.  You also need set up time for changing 
direction and holding the direction after the step goes inactive.

If your granularity is 1uS then a step going high or low or a direction signal 
changing happens on those 1uS boundaries.  

So there's no reason you cannot have your trajectory planner fill up an array 
of 16 bit words that represent each uS in time.  You'd need 1000 words to 
represent 1 millisecond (1khz).  Each two bits of that word (8 axis in total) 
can represent step/dir signals.

And if an axis doesn't move for an entire millisecond those two bits 
representing that axis remain 0.  Now create two of those (or even more) and 
refer to them as a ping pong buffer.  During that millisecond the one buffer is 
clocked out every microsecond the other is filled with new data.  

And how are they clocked out?  The dedicated DMA controller  (Direct Memory 
Access) which doesn't use processor time.  At the end of the 1000 word transfer 
they can be programed to automatically switch to the other buffer along with 
creating an event (interrupt) that it's now using the other one.

At this point it's up to the trajectory planner to fill the arrays of words 
with step/dir information.    At any point that an external event occurs, like 
a limit switch etc the current value of the DMA pointer is captured and the DMA 
programmed with a new buffer to perhaps decelerate.  But in either case the DMA 
pointer tells the system where the hardware was at the time of the event.

> Same for decoding quadrature.  There are hardware decoders so the software
> just has to read out the current value

That depends on the number of decoders that handle quadrature but any of the 
knob type for MPG can easily be dealt with using either interrupt on change or 
just polling at a fast enough rate.
> 
> This is one of the main things that define a "microcontroller", they have a
> large set of on-chip peripherals.  Usually, even more of them than there
> are pins, so you need to assign functions to pins.

Exactly.
John Dammeyer

> 
> The STM32F103 is a very low-end device so it only has (from memory) three
> counter/timers so it can't control two motors and to encoders all using
> hardware.   You and up having to do the encoders using interrupts in
> software.   Interrupts work fine for most uses but fir $10 mre you can have
> a board that uses a bigger STM32 chip with more pins and counters.
> 
> 



_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to