Browse Source

app/README.md,tiny/README.md,ctrl/READM.md : Initial commit.

master
kevin 3 years ago
parent
commit
e3a5a9a6fa
4 changed files with 202 additions and 48 deletions
  1. 21
    48
      control/README.md
  2. 1
    0
      control/app/README.md
  3. 23
    0
      control/ctrl/README.md
  4. 157
    0
      control/tiny/README.md

+ 21
- 48
control/README.md View File

@@ -2,19 +2,19 @@ This folder contains the _picadae_ control code.
2 2
 
3 3
 The _picadae_ control program consists of three parts:
4 4
 
5
-- _tiny_ : Keyboard solenoid driver
6
-- _ctrl_ : Keyboard central controller
7
-- _app_  : Monitor and command utility.
5
+- _tiny_ : [ATtiny85 solenoid driver firmware](tiny/README.md)
6
+
7
+- _ctrl_ : [ATmega328 interface unit](ctrl/README.md) 
8
+
9
+- _app_  : [Python monitor and command utility](app/README.md)
8 10
 
9 11
 # Architecture
10 12
 
11
-The keyboard control hardware consists of 8 driver boards
12
-mounted above the solenoids on the keyboard assembly.
13
-Each driver board has 11 key driver circuits and can
14
-therefore control 11 piano keys. Each key driver
15
-circuit consists of an ATtiny85 microcontroller
16
-which controls a set of power transistors
17
-which in turn control the state of the solenoid.
13
+The keyboard control hardware consists of 8 driver boards mounted
14
+above the solenoids on the keyboard assembly.  Each driver board has
15
+11 key driver circuits which control 11 piano keys. Each key driver
16
+circuit consists of an ATtiny85 microcontroller which controls a set
17
+of power transistors which in turn control the state of the solenoid.
18 18
 The solenoid can be in one of three states:
19 19
 
20 20
 - off
@@ -25,56 +25,29 @@ The attack state is triggered by pulsing the
25 25
 the solenoid with a fast (250 microsecond to
26 26
 30 millisecond) 36 volt pulse. The duration
27 27
 of the pulse determines the attack dynamic.
28
-The hold state then holds the key down
29
-during the sustain portion of the note.
28
+Longer pulses produce louder notes.
29
+At the end of the attack state the solenoid
30
+transitions into a hold state. During
31
+this time the key is held down with just
32
+enough force to sustain the note.
30 33
 
31 34
 All 88 ATtiny85 microncontrollers are attached
32
-to a single I2C bus which is shared with
33
-an Arduino Uno.  The application computer
34
-communicate with the Uno via 
35
-a serial connection. The Uno in turn
36
-translates messages between the 
37
-ATtiny85 channel computers and the
38
-application computer.
39
-
40
-# Keyboard central controller : Arduino Uno Serial Interface
35
+to a single I2C bus which is mastered by an ATmega328 MCU
36
+which acts as a serial to I2C translator for the host computer.
41 37
 
42
-Read a register value of `<count>` bytes from channel `<i2c-addr>`
38
+The host API is implemented as the Python class 'Picadae' in app/picadae_api.py.
39
+The control shell program app/picadae_shell.py shows an example
40
+usage of the API.
43 41
 
44
-    'r' <i2c-addr> <register> <count>
45
-	
46
-Write a register value of `<count>` bytes from channel `<i2c-addr>`
47 42
 
48
-	'w' <i2c-addr> <register> <count> <value-0> <value-1> ... <value-n>
49 43
 
44
+ 
50 45
 
51
-# Keyboard solenoid driver : ATtiny85 Firmware
52 46
 
53 47
 
54
-PWM counter frequency and period.
55
-for each possible `div` setting
56
-with 16 Mhz system clock.
57 48
 
58
-Value | Div  | Frequency   | Period
59
-------|------|-------------|-------
60
- 1    |    1 |    16    M  | 62.5 n 
61
- 2    |    2 |     8    M  |  125 n
62
- 3    |    4 |     4    M  |  250 n
63
- 4    |    8 |     2    M  |  500 n
64
- 5    |   16 |     1    M  |    1 u
65
- 6    |   32 |   500    K  |    2 u
66
- 7    |   64 |   250    K  |    4 u
67
- 8    |  128 |   125    K  |    8 u
68
- 9    |  256 | 62500    Hz |   16 u
69
-10    |  512 | 31250    Hz |   32 u
70
-11    | 1024 | 15625    Hz |   64 u
71
-12    | 2048 | 7812.5   Hz |  128 u
72
-13    | 4096 | 3906.25  Hz |  256 u
73
-14    | 8192 | 1953.125 Hz |  512 u
74
-15    |16384 | 976.6625 Hz | 1024 u 
75 49
 
76 50
 
77
-# Monitor and command utility : Python Utility
78 51
 
79 52
 
80 53
 

+ 1
- 0
control/app/README.md View File

@@ -0,0 +1 @@
1
+# Picadea control and monitor shell

+ 23
- 0
control/ctrl/README.md View File

@@ -0,0 +1,23 @@
1
+# ATmega328 Interface Unit
2
+
3
+This MCU acts as a serial to I2C translator for the host
4
+computer.  The serial protocol implements two
5
+interfaces.  One for read requests and another for write commands.
6
+
7
+The data format of the write commands is given
8
+in the ATtiny85 I2C protocol document.
9
+
10
+Read requests return blocks of memory begining with the address
11
+specified in the last 'Set read address' command.
12
+
13
+## Read: Channel to Host
14
+
15
+Read a `<count>` bytes from a channel beginning at offset = 'offset'
16
+
17
+    'r' <i2c-addr> <offset> <count>
18
+
19
+## Write: Host to Channel
20
+
21
+Write `<count>` bytes from from the host to a channel
22
+
23
+    'w' <i2c-addr> <register> <count> <value-0> <value-1> ... <value-n>

+ 157
- 0
control/tiny/README.md View File

@@ -0,0 +1,157 @@
1
+# ATtiny85 I2C protocol
2
+
3
+
4
+Arguments in curly braces are optional.
5
+
6
+
7
+Function                 | Opcode | Arguments
8
+-------------------------|--------|---------------------------
9
+Set hold PWM duty cycle  |    0   | (duty) { (freq) { (div) }}
10
+
11
+Arguments | Range | Default | Note
12
+----------|-------|---------|------------------------------------------------------
13
+(duty)    | 0-255 |    127  | 0=0%, 255=100%
14
+(freq)    | 0-255 |    255  | Sets PWM top value
15
+(div)     | 1-15  |      5  | Set the PWM base clock frequency (See table below) 
16
+
17
+PWM frequency and period for each possible (div) setting.
18
+
19
+Reg.  |      | Base        | 
20
+Value | Div  | Frequency   | Period
21
+------|------|-------------|-------
22
+ 1    |    1 |    16    M  | 62.5 n 
23
+ 2    |    2 |     8    M  |  125 n
24
+ 3    |    4 |     4    M  |  250 n
25
+ 4    |    8 |     2    M  |  500 n
26
+ 5    |   16 |     1    M  |    1 u
27
+ 6    |   32 |   500    K  |    2 u
28
+ 7    |   64 |   250    K  |    4 u
29
+ 8    |  128 |   125    K  |    8 u
30
+ 9    |  256 | 62500    Hz |   16 u
31
+10    |  512 | 31250    Hz |   32 u
32
+11    | 1024 | 15625    Hz |   64 u
33
+12    | 2048 | 7812.5   Hz |  128 u
34
+13    | 4096 | 3906.25  Hz |  256 u
35
+14    | 8192 | 1953.125 Hz |  512 u
36
+15    |16384 | 976.6625 Hz | 1024 u 
37
+
38
+
39
+Function                 | Opcode | Arguments
40
+-------------------------|--------|---------------------------
41
+Note on velocity         |    1   | (vel)
42
+
43
+Arguments | Range | Default | Note
44
+----------|-------|---------|------------------------------------------------------
45
+(vel)     | 0-127 |  n/a    | Note on velocity.
46
+
47
+Execute a note onset.
48
+The (vel) value is translated to an attack pulse duration
49
+by looking up the pulse tick count in the velocity table.
50
+
51
+
52
+Function                 | Opcode | Arguments
53
+-------------------------|--------|-------------------------------------------------
54
+Note on ticks            |   2    | (pulse-ticks-high-byte) (pulse-ticks-low-byte)
55
+
56
+Execute a note onset.
57
+The 16 bit attack duration in ticks is calculated from microseconds.
58
+
59
+    pulse-ticks = (usec / 1e6) * (16e6/256)
60
+
61
+Where 16e6 is the system clock frequency and 256 is the timer0 clock divider.
62
+`TCCR0B:C02,C01,C00 = 100b (4)`
63
+
64
+
65
+ticks to micoseconds:
66
+
67
+    usecs = (pulse-ticks * 1e6)*(256/16e6)
68
+
69
+
70
+Function                 | Opcode | Arguments
71
+-------------------------|--------|---------------------------
72
+Note off                 |   3    | None
73
+
74
+Turn off a sounding note by settting the hold-voltage to 0.
75
+
76
+
77
+Function                 | Opcode | Arguments
78
+-------------------------|--------|---------------------------
79
+Set read address         |    4   | (src) {(addr)}
80
+
81
+Set the source and address of the next I2C read request.
82
+
83
+The read can come from one of three memory banks:
84
+Register File, MIDI velocity table or EEPROM.
85
+See the _Memory Location Id_ table below for the (src) id values.
86
+
87
+
88
+Arguments   | Range | Default | Note
89
+------------|-------|---------|-------------------------------------------------------
90
+(src)       | 0-2   |  n/a    | Memory location id. See _Memory Location Id_ table.
91
+(addr)      | 0-255 |  n/a    | Offset from base address set by (src)
92
+
93
+
94
+Function                 | Opcode | Arguments
95
+-------------------------|--------|---------------------------
96
+Write memory             |    5   |
97
+
98
+
99
+
100
+Function                 | Opcode | Arguments
101
+-------------------------|--------|---------------------------
102
+Set hold delay           |    6   | { high {low}}
103
+
104
+Set the length of the delay, in ticks, between when the attack pulse ends and when the
105
+hold voltage is applied.
106
+The high and low byte values are calculated identically to the
107
+attack pulse duration values.
108
+
109
+
110
+Function                 | Opcode | Arguments
111
+-------------------------|--------|---------------------------
112
+Set flags variable       |    7   | (flags)
113
+
114
+  7  |  6  |  5  |  4  |  3  |  2  |  1  |  0  
115
+-----|-----|-----|-----|-----|-----|-----|-----
116
+ n/a | n/a | n/a | n/a | n/a | n/a | n/a | HOA
117
+
118
+_HOA_ : Set to apply the hold voltage at the beginning of the attack.
119
+
120
+
121
+Register file
122
+
123
+Address | Label           | Note
124
+--------|-----------------|------------------------------------------------------------------------------------------------
125
+0       | Reg_Rd_Addr     | Next register file address to read.
126
+1       | Table_Rd_Addr   | Next MIDI velocity address to read.
127
+2       | EEPROM_Rd_Addr  | Next EEPROM address to read.
128
+3       | Read_Src_Addr   | Source of the next I2C read request. See Memory Location Id table below.
129
+4       | Reg_Wr_Addr     | Next register file address to write.
130
+5       | Table_Rd_Addr   | Next MIDI velocity address to write.
131
+6       | EEPROM_Rd_Addr  | Next EEPROM address to write.
132
+7       | Write_Dst_Addr  | Destination of the next 'write operation'. See Memory Location id table below.
133
+8       | Tmr_High_Addr   | Current attack pulse tick count high byte
134
+9       | Tmr_Low_Addr    | Current attack pulse tick count low byte
135
+10      | Tmr_Div_Addr    | Attack pulse counter frequency divider.
136
+11      | Pwm_Duty_Addr   | Duty cycle of the hold PWM generator
137
+12      | Pwm_Freq_Addr   | PWM counter max values. Determines the PWM frequency.
138
+13      | Pwm_Div_Addr    | PWM clock divider
139
+14      | State_Addr      | Current solenoied state.
140
+15      | Error_Addr      | Error status
141
+16      | Max_Tmr_Hi_Addr | Max attack pulse high byte tick count.
142
+17      | Delay_High_Addr | Hold delay onset tick count high byte
143
+18      | Delay_Low_Addr  | Hold delay onset tick count low byte
144
+19      | Flags_Addr      | Binary variable field.
145
+
146
+
147
+Memory Location Id table.
148
+
149
+Id | Memory         | Note
150
+---|----------------|-------------------------------
151
+ 0 | Register file  | See register table file
152
+ 1 | Velocity table | MIDI velocity to pulse ticks lookup table
153
+ 2 | EEPROM         | EEPROM data memory
154
+
155
+
156
+
157
+

Loading…
Cancel
Save