Close

Controlling the steppermotors in software, concept

A project log for Building the Thor robot

Building a 6-axis robot based on the Thor robot. When size DOES matter!

olaf-baeyensOlaf Baeyens 01/17/2017 at 21:380 Comments

Still busy thinking about how to implement the Thor software. If this was a conventional PC then it would already have been developed. But the Ultrasonics Pro v1.0 has only 96 KB of RAM (512 KB of Flash).

The idea is this: a FIFO buffer that for every byte has all 7 stepper motors set one step.

However to fill the FIFO I must create a stream of bytes for every single motor. This is easier to calculate and your RAM is used very efficiently.

The speed of the motor will be defined on the bits that is set.

Full speed : 1111 1111 1111 1111

Halve speed: 1010 1010 1010 1010

Quatre speed: 1000 1000 1000 1000

Assume motor 1: Full speed (1111 1111 1111 1111) and motor 2: Halve speed (1010 1010 1010 1010) the FIFO must have the bit rotated in 90 degrees.

Motor stream read from left to right

Motor 1: 1111 1111 1111 1111
Motor 2: 1010 1010 1010 1010

FIFO: Motor 1 bit 7, Motor 2 : bit 6, Motor 5 : bit 5... )
(Read from top to bottom)
1100 0000
1000 0000
1100 0000
1000 0000
1100 0000
1000 0000
1100 0000
1000 0000

Now assume that I want to precalculate the FIFO for 1 second and one rotation.. Then the FIFO memory would require 200 bytes.

If we have 32 micro steps then the memory increases 200x32 = 6,400 bytes.

A 5 gear ration would become 200x32x5 = 32,000 bytes.

So we are reaching the limit.


However all is not lost! :-)

These stepper-motors carry a payload and has inertia. So we must be sure that the movement is smooth. This means that we have an acceleration phase a steady state phase and a de-acceleration, phase. We could actually use the 512 KB Flash memory as pre-calculated values. On top of that, the continuous movement is just a repetitive pattern. This saves is again processor CPU.

Because we calculate a pos 1 to pos 2, then we only set the stepper direction for each motor first. Once we are in the steady movement phase until we reach pos 2, we basically just repeat the byte pattern. And we have a compressed FIFO buffer.


To compress the FIFO buffer even more we have to realize that once we do micro stepping, it does not matter much if we feed 1010 1010 or 1100 1100. What is important is the number of step bits (=1) as long as they are not too far separated.


These are the ideas I am trying to solve in my code.

Currently I am trying for Timer1 that has an interrupt code to execute the FIFO buffer. This frees up any CPU for calculating the FIFO

To be continued.....


Discussions