Skip to content
Michael Mayer edited this page Feb 2, 2019 · 4 revisions

Internal operation of SMC3

The software is directly written in assembler. It is highly optimized and very compact (only 1.8kB), but the documentation is sparse and the code not too easy to understand. Here I try to add some documenation.

The most important bits so far:

Measurement units

  • positions are reference in encoder counts (which is diffent from encoder pules, see below)
  • speed is in counts/millisecond, which is means kHz. Normally just a 16 integer, exept for P6 parameter which is u8.8
  • voltage is expressed as a fraction of the maxium motor suppy voltage. The range is [-1.0;+1.0], in 8.8 fixed point that is -256 to +256. Basically just a 8 bit PWM value plus one bit for the sign.
  • torque means the motor current. Expressed as a fraction of the stall current, similar to the voltage.
  • gains are just numbers as 8.8 fixed point.

encoder resolution

The datasheet specifies the resolution of the physical line pattern. "150 lpi" actually means 150 line pairs of black and white strips per inch, "400 lpr" means 400 line pairs per revolution. These are the numbers Elm refers to in his parameter calculation formulas.

encoder counts

The software decodes the two encoder encoder outputs and generates 4 counts per line pair. A 150 lpi encoder results in 600 position counts per inch. Signed 24 bit.

speed

Is measured and specified as the frequency of the encoder counts in kHz (or counts/ms if you prefer). The internal loop runs every millisecond and speed is simply the number of encoder counts since the last run. Unsigned 16 bit.

motor voltage/torque/back-EMF-Voltage

Is specified as a proportion of the full scale value. The voltages refer to the maximum output voltage of the motor driver. This is the supply voltage minus the driver losses.

These numbers are represented as a signed fixed point 8:8 value. They are by definition smaller than one. That means the higher byte is only the sign and the lower byte contains the actual value.