On Tue, Apr 28, 2020 at 6:32 PM John Dammeyer <jo...@autoartisans.com> wrote:
> > Will you share some code on how you accelerate from 0 to 15kHz stepping > rate on your $1 processor? > No code. that is the entire point. The microcontroller has built-in hardware the bigger PC or Raspberry Pi lacks. The way it works is there is a counter register that counts clock cycles. The clock is derived from the main crystal and can be set to say 10 MHz or whatever. Then there is another register what you load in a cycle count and the output step rate is say maybe "475 cycles" and each cycle is some multiple of the crystal frequency. Once you load the registers the steps happen in hardware so there never is need for a real-time loop. But at the servo loop period you would re-oad the register with the new step period. The resolution is hat ever is needed up to the crystal frequency. Typically a processor has many of these timers. Cheaper chips have a few and bigger chips might have a dozen of them. YOu also get to asign the timer to a physical pin. So the software never has to write to the pin as it is connected to the timer register. You can do PWM in hardware too. There is a 10-bit register that holds the duty cycle and then the PWM output runs without any software. It is just logic gates So this is how people are running 4 axis machines at 200mm per second using low-end controllers. The controllers have quite a lot of useful hardware on them so they don't need fast software Same with reading quadrature encoders. The chips will have a hardware encoder made with flip-flops and a counter. So there is no polling or iterrupts. They use logic gates. The software reads the encoder value from a hardware register. To the little chip and drive a few motors I might do a 20Hz loop but run the motor at 1KHz. LinuxCNC with a Mesa card works sort of like this too. An FPGA is just hardware gates -- Chris Albertson Redondo Beach, California _______________________________________________ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users