summaryrefslogtreecommitdiff
path: root/src/hal/drivers/pluto_servo_firmware/register-layout.txt
blob: fd3912e6ad399e4faed8d14f745aee2219b33800 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
Generalities
============

The register layout of the pluto-servo is an implementation detail and
may vary from release to release of emc.

The "address" is auto-incrementing after transfers.

Multi-byte data is transferred least-significant-byte-first.


Read registers
==============

The "read" registers (data transfer from pluto to PC) are each 4 bytes
long and start at address 0.  Beginning a read within a register (e.g.,
at address 2) results in undefined behavior.  Bits without an
interpretation are undefined.

Address     Bits        Interpretation
0..3        0..13       Encoder 0 count
            14..27      Encoder 0 last index pulse count
	    15		Encoder 0 index seen
4..7        0..13       Encoder 1 count
            14..27      Encoder 1 last index pulse count
	    15		Encoder 0 index seen
8..11       0..13       Encoder 2 count
            14..27      Encoder 2 last index pulse count
	    15		Encoder 0 index seen
12..15      0..13       Encoder 3 count
            14..27      Encoder 3 last index pulse count
	    15		Encoder 0 index seen
16..19      0..7        Dedicated digital inputs 0..7
            8..11       Encoder 0..3 "Z" input
            12..15      Encoder 0..3 "B" input
            16..20      Encoder 0..3 "A" input
            21..27      (future) watchdog timer value


Write registers
===============

The "write" registers (data transfer from pluto to PC) are each 2 bytes
long and start at address 0.  Beginning a read within a register (e.g.,
at address 1) results in undefined behavior.  Bits without an
interpretation should be sent as 0.

Address     Bits        Interpretation
0..1        0..10       PWM 0 duty cycle
            12          PWM 0 up invert
            13          PWM 0 down invert
            14          PDM mode indicator for PWM 0..3
            15          PWM 0 sign (0=force 'up' low; 1=force 'down' low)

2..3        0..10       PWM 1 duty cycle
            12          PWM 1 up invert
            13          PWM 1 down invert
            15          PWM 1 sign (0=force 'up' low; 1=force 'down' low)

4..5        0..10       PWM 2 duty cycle
            12          PWM 2 up invert
            13          PWM 2 down invert
            15          PWM 2 sign (0=force 'up' low; 1=force 'down' low)

6..7        0..10       PWM 3 duty cycle
            12          PWM 3 up invert
            13          PWM 3 down invert
            15          PWM 3 sign (0=force 'up' low; 1=force 'down' low)

8..9        0..9        Dedicated digital outputs 0..9
            13          write to 1 to enable encoder test mode
            14          write to 1 to enable watchdog and reset WDT
            15          Index signal polarity for encoder 0..3


Notes
=====

Encoder
=======
The encoder "count" and "last index pulse count" must be sign extended in the
driver.  This makes the maximum count rate 8191 counts per polling period.

When an index pulse has occurred, "last index pulse count" is updated with the
count on the rising edge of the index, and "index seen" will be set on the next
read cycle.  It is up to the HAL driver to perform index-enable logic.

PWM
===
In up/down mode, bit 15 functions like a sign bit.  In pwm/direction
mode, bit 13 functions like a direction bit.  Bits 12 and 13 function as
inverts (when PWM function is used) or as digital outputs (when PWM
function is disabled, bits 10..0 == 0).   It's up to the HAL driver to
set all the bits properly for the desired PWM/digital output mode.

Watchdog
========
The watchdog consists of a 7-bit counter and a 1-bit enable which gives a
watchdog period of approximately 6.5ms.  At power-up the enable is FALSE.  When
bit 14 of register 8..9 is written TRUE, the counter is reset to 0 and enable
is set to TRUE. (there is no provision for resetting the watchdog enable to
FALSE) Every time the PWM counter overflows (approximately 51.2us) the watchdog
counter is incremented if it is not already at its maximum.  When the watchdog
counter is at its maximum, the dedicated digital outputs and PWM outputs are
tristated.