I'm trying to control an unknown stepper motor with the high-end timer (NHET) module of a Texas Instruments Hercules microcontroller I got a freebee from TI almost a year ago. An unknown stepper motor, a driver board and a Hercules RM57 LaunchPad. The code to run the motor was expected to arrive too (it was an assignment for an internal) but that never materialised. In this blog series I'm trying to program the NHET module so that it sends the right signals to make the stepper step.
In this third post I snoop SPI traffic between MSP430 microcontroller and the stepper motor controller. The PWM signals are for the fourth blog. |
Snooping Traffic
There are two types of commands flying towards the DRV8711 Stepper Motor Controller: Setup commands and Step commands.
The Setup ones configure the modules in the stepper motor driver and use SPI as protocol.
The Step commands (handled in the next blog) are just pulses, where each pulse tells the driver to give the motor a kick. The result of that is depending of the driver setup
Setup Commands
The DRV8711 is a microcontroller on its own, with a few registers that you can set and read with SPI.
You can configure the internal modules such as the current control network, microstepping indexer, decay and blanking blocks, ...
The image below is a capture of setting the driver using the TI demo application for this motor.
You see 8 blocks of commands, each writing to a particular register. The register map from the DRV8711 datasheet shows what each of the controls:
The GUI of the demo app gives an easier view - and you can change and read them directly from the app.
The SPI capture from my protocol analyser shows the result of shooting the following init settings:
Full output of the analyser (ignore the MISO columns, there's only traffic from MSP430 to DRV8711 in this scenario):
SPI Analysis results
Configuration | |
---|---|
SPI mode | Mode 0 (CPOL = 0, CPHA = 0) |
MOSI | MISO | ||||||||
---|---|---|---|---|---|---|---|---|---|
Index | Time | Hex | Bin | Dec | ASCII | Hex | Bin | Dec | ASCII |
0 | -1,66 μs | CS_LOW | CS_LOW | ||||||
1 | 20,00 ns | 0x0f19 | 0b0000111100011001 | 3865 | 0xffff | 0b1111111111111111 | 65535 | ||
3 | 9,92 μs | CS_LOW | CS_LOW | ||||||
4 | 12,24 μs | CS_HIGH | CS_HIGH | ||||||
5 | 13,68 μs | 0x10ba | 0b0001000010111010 | 4282 | 0xffff | 0b1111111111111111 | 65535 | ||
7 | 23,82 μs | CS_LOW | CS_LOW | ||||||
8 | 26,14 μs | CS_HIGH | CS_HIGH | ||||||
9 | 27,82 μs | 0x2030 | 0b0010000000110000 | 8240 | 0xffff | 0b1111111111111111 | 65535 | ||
11 | 37,70 μs | CS_LOW | CS_LOW | ||||||
12 | 40,04 μs | CS_HIGH | CS_HIGH | ||||||
13 | 41,46 μs | 0x3108 | 0b0011000100001000 | 12552 | 0xffff | 0b1111111111111111 | 65535 | ||
15 | 51,60 μs | CS_LOW | CS_LOW | ||||||
16 | 53,94 μs | CS_HIGH | CS_HIGH | ||||||
17 | 55,62 μs | 0x4310 | 0b0100001100010000 | 17168 | 0xffff | 0b1111111111111111 | 65535 | ||
19 | 65,50 μs | CS_LOW | CS_LOW | ||||||
20 | 67,46 μs | CS_HIGH | CS_HIGH | ||||||
21 | 68,76 μs | 0x5f40 | 0b0101111101000000 | 24384 | 0xffff | 0b1111111111111111 | 65535 | ||
23 | 78,64 μs | CS_LOW | CS_LOW | ||||||
24 | 81,54 μs | CS_HIGH | CS_HIGH | ||||||
25 | 82,90 μs | 0x6055 | 0b0110000001010101 | 24661 | 0xffff | 0b1111111111111111 | 65535 | ||
27 | 92,72 μs | CS_LOW | CS_LOW | ||||||
28 | 96,64 μs | CS_HIGH | CS_HIGH | ||||||
29 | 98,06 μs | 0x7000 | 0b0111000000000000 | 28672 | 0xffff | 0b1111111111111111 | 65535 | ||
31 | 108,20 μs | CS_LOW | CS_LOW |
The column of interest is MOSI - in the Hex or Bin format of line 1, 5, 9, 13, 17, 21, 25 and 29.
Compare those with each register's explanation in the DRV8711 datasheet to get what's happening.
As promised, the next post is about the (runtime controlled) PWM signals that actually drive the motor.
I need some time first to study the MSP430 timers and the stepper demo firmware ...
Top Comments