Skip to content

Commit 4e8106d

Browse files
author
Jan Knipper
committed
Add polyphony, update readme
1 parent a915339 commit 4e8106d

File tree

9 files changed

+76
-48
lines changed

9 files changed

+76
-48
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
# Raspberry Pi Pico DCO
1+
# Raspberry Pi Pico Polyphonic DCO
22

3-
This repository contains source code and schematics for a digitally controlled oscillator (DCO) which is driven by a Raspberry Pi Pico. It uses PIO to generate a highly accurate frequency which is controlled by MIDI USB. The analog oscillator part is based on the Juno 106 and generates sawtooth and square wave signal with a 10Vpp amplitude. Amplitude compensation is done by a smoothed PWM signal coming from the Pico.
3+
This repository contains source code, schematics and PCB for a digitally controlled oscillator (DCO) with up to 6 voices which are driven by a Raspberry Pi Pico. It uses PIO to generate a highly accurate frequency which is controlled by USB or serial MIDI. The analog oscillator part is based on the Juno 106 and generates sawtooth and square wave signal with a 10Vpp amplitude. Amplitude compensation is done by a smoothed PWM signal coming from the Pico.
44

5-
This is how it sounds: [Ramp sample](https://soundcloud.com/polykit/pico-dco-ramp) [Pulse sample](https://soundcloud.com/polykit/pico-dco-pulse)
5+
This is how it sounds: [Ramp sample](https://soundcloud.com/polykit/pico-dco-ramp) [Pulse sample](https://soundcloud.com/polykit/pico-dco-pulse) [Polyphonic sample](https://soundcloud.com/polykit/pico-dco-polyphonic)
66

7-
## Schematics
7+
## Schematics and PCB
88

99
![Raspberry Pi Pico DCO](pico-dco.png)
1010

11+
![Raspberry Pi Pico DCO PCB](pico-dco-pcb.png)
12+
1113
## Installing (simple)
1214

1315
Press `BOOTSEL` button on the Pico while powering it with USB. Copy file `build/pico-dco.uf2` onto the USB mass storage device.
1416

1517
## Usage
1618

17-
After installing the Pico should register as USB MIDI device. The DCO listens to note on/note off messages on MIDI channel 1.
19+
After installing the Pico should register as USB MIDI device. Alternatively serial MIDI input is available. The DCO listens to note on/note off messages on MIDI channel 1.
1820

19-
## Todo
21+
## Known issues
2022

21-
- Add DIN MIDI input
22-
- Add polyphony (up to 8 voices should be possible)
23-
- Add velocity and pitch bend output (additional DAC needed)
23+
- USB MIDI apparently looses notes while playing. This seems to be caused by the TinyUSB library included in the Raspberry Pi Pico SDK. Hopefully this will be fixed in a future release.
2424

2525
## References
2626

build/pico-dco.uf2

1 KB
Binary file not shown.

kicad/Pico-DCO-1.sch

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ AR Path="/60ADE329/60873A52" Ref="R34" Part="1"
3636
AR Path="/60ADFCBC/60873A52" Ref="R48" Part="1"
3737
AR Path="/60AE15A4/60873A52" Ref="R62" Part="1"
3838
AR Path="/60AE2DA8/60873A52" Ref="R76" Part="1"
39-
F 0 "R20" V 3693 2850 50 0000 C CNN
39+
F 0 "R76" V 3693 2850 50 0000 C CNN
4040
F 1 "100k" V 3784 2850 50 0000 C CNN
4141
F 2 "Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal" V 3830 2850 50 0001 C CNN
4242
F 3 "~" H 3900 2850 50 0001 C CNN
@@ -58,7 +58,7 @@ AR Path="/60ADE329/60873A58" Ref="R33" Part="1"
5858
AR Path="/60ADFCBC/60873A58" Ref="R47" Part="1"
5959
AR Path="/60AE15A4/60873A58" Ref="R61" Part="1"
6060
AR Path="/60AE2DA8/60873A58" Ref="R75" Part="1"
61-
F 0 "R19" V 2893 3100 50 0000 C CNN
61+
F 0 "R75" V 2893 3100 50 0000 C CNN
6262
F 1 "100k" V 2984 3100 50 0000 C CNN
6363
F 2 "Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal" V 3030 3100 50 0001 C CNN
6464
F 3 "~" H 3100 3100 50 0001 C CNN
@@ -128,7 +128,7 @@ AR Path="/60ADE329/60873A7B" Ref="R43" Part="1"
128128
AR Path="/60ADFCBC/60873A7B" Ref="R57" Part="1"
129129
AR Path="/60AE15A4/60873A7B" Ref="R71" Part="1"
130130
AR Path="/60AE2DA8/60873A7B" Ref="R85" Part="1"
131-
F 0 "R29" H 6280 4204 50 0000 R CNN
131+
F 0 "R85" H 6280 4204 50 0000 R CNN
132132
F 1 "100k" H 6280 4295 50 0000 R CNN
133133
F 2 "Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal" V 6280 4250 50 0001 C CNN
134134
F 3 "~" H 6350 4250 50 0001 C CNN
@@ -150,7 +150,7 @@ AR Path="/60ADE329/60873A81" Ref="C19" Part="1"
150150
AR Path="/60ADFCBC/60873A81" Ref="C24" Part="1"
151151
AR Path="/60AE15A4/60873A81" Ref="C29" Part="1"
152152
AR Path="/60AE2DA8/60873A81" Ref="C34" Part="1"
153-
F 0 "C14" V 6355 3750 50 0000 C CNN
153+
F 0 "C34" V 6355 3750 50 0000 C CNN
154154
F 1 "10u" V 6264 3750 50 0000 C CNN
155155
F 2 "Capacitor_THT:CP_Radial_D5.0mm_P2.00mm" H 6138 3600 50 0001 C CNN
156156
F 3 "~" H 6100 3750 50 0001 C CNN
@@ -177,7 +177,7 @@ AR Path="/60ADE329/60873A8A" Ref="U5" Part="2"
177177
AR Path="/60ADFCBC/60873A8A" Ref="U6" Part="2"
178178
AR Path="/60AE15A4/60873A8A" Ref="U7" Part="2"
179179
AR Path="/60AE2DA8/60873A8A" Ref="U8" Part="2"
180-
F 0 "U4" H 3900 3567 50 0000 C CNN
180+
F 0 "U8" H 3900 3567 50 0000 C CNN
181181
F 1 "TL074" H 3900 3476 50 0000 C CNN
182182
F 2 "Package_DIP:DIP-14_W7.62mm_Socket_LongPads" H 3850 3300 50 0001 C CNN
183183
F 3 "http://www.ti.com/lit/ds/symlink/tl071.pdf" H 3950 3400 50 0001 C CNN
@@ -228,7 +228,7 @@ AR Path="/60ADE329/60873A9A" Ref="R36" Part="1"
228228
AR Path="/60ADFCBC/60873A9A" Ref="R50" Part="1"
229229
AR Path="/60AE15A4/60873A9A" Ref="R64" Part="1"
230230
AR Path="/60AE2DA8/60873A9A" Ref="R78" Part="1"
231-
F 0 "R22" V 4343 3200 50 0000 C CNN
231+
F 0 "R78" V 4343 3200 50 0000 C CNN
232232
F 1 "100k" V 4434 3200 50 0000 C CNN
233233
F 2 "Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal" V 4480 3200 50 0001 C CNN
234234
F 3 "~" H 4550 3200 50 0001 C CNN
@@ -254,7 +254,7 @@ AR Path="/60ADE329/60873AA2" Ref="U5" Part="1"
254254
AR Path="/60ADFCBC/60873AA2" Ref="U6" Part="1"
255255
AR Path="/60AE15A4/60873AA2" Ref="U7" Part="1"
256256
AR Path="/60AE2DA8/60873AA2" Ref="U8" Part="1"
257-
F 0 "U4" H 5300 3667 50 0000 C CNN
257+
F 0 "U8" H 5300 3667 50 0000 C CNN
258258
F 1 "TL074" H 5300 3576 50 0000 C CNN
259259
F 2 "Package_DIP:DIP-14_W7.62mm_Socket_LongPads" H 5250 3400 50 0001 C CNN
260260
F 3 "http://www.ti.com/lit/ds/symlink/tl071.pdf" H 5350 3500 50 0001 C CNN
@@ -321,7 +321,7 @@ AR Path="/60ADE329/60873ABA" Ref="C17" Part="1"
321321
AR Path="/60ADFCBC/60873ABA" Ref="C22" Part="1"
322322
AR Path="/60AE15A4/60873ABA" Ref="C27" Part="1"
323323
AR Path="/60AE2DA8/60873ABA" Ref="C32" Part="1"
324-
F 0 "C12" V 3848 1550 50 0000 C CNN
324+
F 0 "C32" V 3848 1550 50 0000 C CNN
325325
F 1 "470p" V 3939 1550 50 0000 C CNN
326326
F 2 "Capacitor_THT:C_Rect_L7.2mm_W4.5mm_P5.00mm_FKS2_FKP2_MKS2_MKP2" H 4138 1400 50 0001 C CNN
327327
F 3 "~" H 4100 1550 50 0001 C CNN
@@ -343,7 +343,7 @@ AR Path="/60ADE329/60873AC0" Ref="R35" Part="1"
343343
AR Path="/60ADFCBC/60873AC0" Ref="R49" Part="1"
344344
AR Path="/60AE15A4/60873AC0" Ref="R63" Part="1"
345345
AR Path="/60AE2DA8/60873AC0" Ref="R77" Part="1"
346-
F 0 "R21" H 4520 1846 50 0000 L CNN
346+
F 0 "R77" H 4520 1846 50 0000 L CNN
347347
F 1 "10k" H 4520 1755 50 0000 L CNN
348348
F 2 "Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal" V 4380 1800 50 0001 C CNN
349349
F 3 "~" H 4450 1800 50 0001 C CNN
@@ -365,7 +365,7 @@ AR Path="/60ADE329/60873AC6" Ref="R37" Part="1"
365365
AR Path="/60ADFCBC/60873AC6" Ref="R51" Part="1"
366366
AR Path="/60AE15A4/60873AC6" Ref="R65" Part="1"
367367
AR Path="/60AE2DA8/60873AC6" Ref="R79" Part="1"
368-
F 0 "R23" V 4593 1550 50 0000 C CNN
368+
F 0 "R79" V 4593 1550 50 0000 C CNN
369369
F 1 "1k" V 4684 1550 50 0000 C CNN
370370
F 2 "Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal" V 4730 1550 50 0001 C CNN
371371
F 3 "~" H 4800 1550 50 0001 C CNN
@@ -387,7 +387,7 @@ AR Path="/60ADE329/60873ACC" Ref="R41" Part="1"
387387
AR Path="/60ADFCBC/60873ACC" Ref="R55" Part="1"
388388
AR Path="/60AE15A4/60873ACC" Ref="R69" Part="1"
389389
AR Path="/60AE2DA8/60873ACC" Ref="R83" Part="1"
390-
F 0 "R27" H 5720 2396 50 0000 L CNN
390+
F 0 "R83" H 5720 2396 50 0000 L CNN
391391
F 1 "2k2" H 5720 2305 50 0000 L CNN
392392
F 2 "Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal" V 5580 2350 50 0001 C CNN
393393
F 3 "~" H 5650 2350 50 0001 C CNN
@@ -409,7 +409,7 @@ AR Path="/60ADE329/60873AD2" Ref="C18" Part="1"
409409
AR Path="/60ADFCBC/60873AD2" Ref="C23" Part="1"
410410
AR Path="/60AE15A4/60873AD2" Ref="C28" Part="1"
411411
AR Path="/60AE2DA8/60873AD2" Ref="C33" Part="1"
412-
F 0 "C13" V 5048 2700 50 0000 C CNN
412+
F 0 "C33" V 5048 2700 50 0000 C CNN
413413
F 1 "1n*" V 5139 2700 50 0000 C CNN
414414
F 2 "Capacitor_THT:C_Rect_L7.2mm_W4.5mm_P5.00mm_FKS2_FKP2_MKS2_MKP2" H 5338 2550 50 0001 C CNN
415415
F 3 "~" H 5300 2700 50 0001 C CNN
@@ -431,7 +431,7 @@ AR Path="/60ADE329/60873AD8" Ref="Q3" Part="1"
431431
AR Path="/60ADFCBC/60873AD8" Ref="Q4" Part="1"
432432
AR Path="/60AE15A4/60873AD8" Ref="Q5" Part="1"
433433
AR Path="/60AE2DA8/60873AD8" Ref="Q6" Part="1"
434-
F 0 "Q2" V 5535 1900 50 0000 C CNN
434+
F 0 "Q6" V 5535 1900 50 0000 C CNN
435435
F 1 "2N3904" V 5626 1900 50 0000 C CNN
436436
F 2 "Package_TO_SOT_THT:TO-92_Wide" H 5500 1825 50 0001 L CIN
437437
F 3 "https://www.onsemi.com/pub/Collateral/2N3903-D.PDF" H 5300 1900 50 0001 L CNN
@@ -453,7 +453,7 @@ AR Path="/60ADE329/60873ADE" Ref="U5" Part="4"
453453
AR Path="/60ADFCBC/60873ADE" Ref="U6" Part="4"
454454
AR Path="/60AE15A4/60873ADE" Ref="U7" Part="4"
455455
AR Path="/60AE2DA8/60873ADE" Ref="U8" Part="4"
456-
F 0 "U4" H 6200 5867 50 0000 C CNN
456+
F 0 "U8" H 6200 5867 50 0000 C CNN
457457
F 1 "TL074" H 6200 5776 50 0000 C CNN
458458
F 2 "Package_DIP:DIP-14_W7.62mm_Socket_LongPads" H 6150 5600 50 0001 C CNN
459459
F 3 "http://www.ti.com/lit/ds/symlink/tl071.pdf" H 6250 5700 50 0001 C CNN
@@ -477,7 +477,7 @@ AR Path="/60ADE329/60873AE5" Ref="R42" Part="1"
477477
AR Path="/60ADFCBC/60873AE5" Ref="R56" Part="1"
478478
AR Path="/60AE15A4/60873AE5" Ref="R70" Part="1"
479479
AR Path="/60AE2DA8/60873AE5" Ref="R84" Part="1"
480-
F 0 "R28" H 5580 4204 50 0000 R CNN
480+
F 0 "R84" H 5580 4204 50 0000 R CNN
481481
F 1 "10k" H 5580 4295 50 0000 R CNN
482482
F 2 "Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal" V 5580 4250 50 0001 C CNN
483483
F 3 "~" H 5650 4250 50 0001 C CNN
@@ -499,7 +499,7 @@ AR Path="/60ADE329/60873AF2" Ref="R40" Part="1"
499499
AR Path="/60ADFCBC/60873AF2" Ref="R54" Part="1"
500500
AR Path="/60AE15A4/60873AF2" Ref="R68" Part="1"
501501
AR Path="/60AE2DA8/60873AF2" Ref="R82" Part="1"
502-
F 0 "R26" H 5370 5996 50 0000 L CNN
502+
F 0 "R82" H 5370 5996 50 0000 L CNN
503503
F 1 "470k" H 5370 5905 50 0000 L CNN
504504
F 2 "Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal" V 5230 5950 50 0001 C CNN
505505
F 3 "~" H 5300 5950 50 0001 C CNN
@@ -521,7 +521,7 @@ AR Path="/60ADE329/60873AF8" Ref="R38" Part="1"
521521
AR Path="/60ADFCBC/60873AF8" Ref="R52" Part="1"
522522
AR Path="/60AE15A4/60873AF8" Ref="R66" Part="1"
523523
AR Path="/60AE2DA8/60873AF8" Ref="R80" Part="1"
524-
F 0 "R24" V 5007 4650 50 0000 C CNN
524+
F 0 "R80" V 5007 4650 50 0000 C CNN
525525
F 1 "150k" V 4916 4650 50 0000 C CNN
526526
F 2 "Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal" V 4730 4650 50 0001 C CNN
527527
F 3 "~" H 4800 4650 50 0001 C CNN
@@ -543,7 +543,7 @@ AR Path="/60ADE329/60873AFE" Ref="R39" Part="1"
543543
AR Path="/60ADFCBC/60873AFE" Ref="R53" Part="1"
544544
AR Path="/60AE15A4/60873AFE" Ref="R67" Part="1"
545545
AR Path="/60AE2DA8/60873AFE" Ref="R81" Part="1"
546-
F 0 "R25" V 5007 5600 50 0000 C CNN
546+
F 0 "R81" V 5007 5600 50 0000 C CNN
547547
F 1 "100k" V 4916 5600 50 0000 C CNN
548548
F 2 "Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal" V 4730 5600 50 0001 C CNN
549549
F 3 "~" H 4800 5600 50 0001 C CNN
@@ -597,7 +597,7 @@ AR Path="/60ADE329/60873B1E" Ref="R44" Part="1"
597597
AR Path="/60ADFCBC/60873B1E" Ref="R58" Part="1"
598598
AR Path="/60AE15A4/60873B1E" Ref="R72" Part="1"
599599
AR Path="/60AE2DA8/60873B1E" Ref="R86" Part="1"
600-
F 0 "R30" V 6593 5500 50 0000 C CNN
600+
F 0 "R86" V 6593 5500 50 0000 C CNN
601601
F 1 "10k" V 6684 5500 50 0000 C CNN
602602
F 2 "Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal" V 6730 5500 50 0001 C CNN
603603
F 3 "~" H 6800 5500 50 0001 C CNN
@@ -619,7 +619,7 @@ AR Path="/60ADE329/60873B24" Ref="R45" Part="1"
619619
AR Path="/60ADFCBC/60873B24" Ref="R59" Part="1"
620620
AR Path="/60AE15A4/60873B24" Ref="R73" Part="1"
621621
AR Path="/60AE2DA8/60873B24" Ref="R87" Part="1"
622-
F 0 "R31" H 7120 5796 50 0000 L CNN
622+
F 0 "R87" H 7120 5796 50 0000 L CNN
623623
F 1 "5k6" H 7120 5705 50 0000 L CNN
624624
F 2 "Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal" V 6980 5750 50 0001 C CNN
625625
F 3 "~" H 7050 5750 50 0001 C CNN
@@ -710,7 +710,7 @@ AR Path="/60ADE329/60873B5B" Ref="R32" Part="1"
710710
AR Path="/60ADFCBC/60873B5B" Ref="R46" Part="1"
711711
AR Path="/60AE15A4/60873B5B" Ref="R60" Part="1"
712712
AR Path="/60AE2DA8/60873B5B" Ref="R74" Part="1"
713-
F 0 "R18" V 2293 3100 50 0000 C CNN
713+
F 0 "R74" V 2293 3100 50 0000 C CNN
714714
F 1 "4k7" V 2384 3100 50 0000 C CNN
715715
F 2 "Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal" V 2430 3100 50 0001 C CNN
716716
F 3 "~" H 2500 3100 50 0001 C CNN
@@ -756,7 +756,7 @@ AR Path="/60ADE329/60873B69" Ref="C16" Part="1"
756756
AR Path="/60ADFCBC/60873B69" Ref="C21" Part="1"
757757
AR Path="/60AE15A4/60873B69" Ref="C26" Part="1"
758758
AR Path="/60AE2DA8/60873B69" Ref="C31" Part="1"
759-
F 0 "C11" V 2548 3400 50 0000 C CNN
759+
F 0 "C31" V 2548 3400 50 0000 C CNN
760760
F 1 "100n" V 2639 3400 50 0000 C CNN
761761
F 2 "Capacitor_THT:C_Rect_L7.2mm_W4.5mm_P5.00mm_FKS2_FKP2_MKS2_MKP2" H 2838 3250 50 0001 C CNN
762762
F 3 "~" H 2800 3400 50 0001 C CNN
@@ -801,7 +801,7 @@ AR Path="/60ADE329/60873A65" Ref="U5" Part="3"
801801
AR Path="/60ADFCBC/60873A65" Ref="U6" Part="3"
802802
AR Path="/60AE15A4/60873A65" Ref="U7" Part="3"
803803
AR Path="/60AE2DA8/60873A65" Ref="U8" Part="3"
804-
F 0 "U4" H 7350 4217 50 0000 C CNN
804+
F 0 "U8" H 7350 4217 50 0000 C CNN
805805
F 1 "TL074" H 7350 4126 50 0000 C CNN
806806
F 2 "Package_DIP:DIP-14_W7.62mm_Socket_LongPads" H 7300 3950 50 0001 C CNN
807807
F 3 "http://www.ti.com/lit/ds/symlink/tl071.pdf" H 7400 4050 50 0001 C CNN
@@ -822,7 +822,7 @@ AR Path="/60ADE329/60926AFD" Ref="U5" Part="5"
822822
AR Path="/60ADFCBC/60926AFD" Ref="U6" Part="5"
823823
AR Path="/60AE15A4/60926AFD" Ref="U7" Part="5"
824824
AR Path="/60AE2DA8/60926AFD" Ref="U8" Part="5"
825-
F 0 "U4" H 9958 5596 50 0000 L CNN
825+
F 0 "U8" H 9958 5596 50 0000 L CNN
826826
F 1 "TL074" H 9958 5505 50 0000 L CNN
827827
F 2 "" H 9950 5650 50 0001 C CNN
828828
F 3 "http://www.ti.com/lit/ds/symlink/tl071.pdf" H 10050 5750 50 0001 C CNN
@@ -886,7 +886,7 @@ AR Path="/60ADE329/609307F0" Ref="C20" Part="1"
886886
AR Path="/60ADFCBC/609307F0" Ref="C25" Part="1"
887887
AR Path="/60AE15A4/609307F0" Ref="C30" Part="1"
888888
AR Path="/60AE2DA8/609307F0" Ref="C35" Part="1"
889-
F 0 "C15" V 9398 5600 50 0000 C CNN
889+
F 0 "C35" V 9398 5600 50 0000 C CNN
890890
F 1 "100n" V 9489 5600 50 0000 C CNN
891891
F 2 "Capacitor_THT:C_Rect_L7.2mm_W4.5mm_P5.00mm_FKS2_FKP2_MKS2_MKP2" H 9688 5450 50 0001 C CNN
892892
F 3 "~" H 9650 5600 50 0001 C CNN

kicad/pico-dco.pro

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
update=Mo 10 Mai 2021 23:23:45 CEST
1+
update=So 23 Mai 2021 22:49:11 CEST
22
version=1
33
last_client=kicad
44
[general]
@@ -249,3 +249,13 @@ uViaDrill=0.1
249249
dPairWidth=0.2
250250
dPairGap=0.25
251251
dPairViaGap=0.25
252+
[schematic_editor]
253+
version=1
254+
PageLayoutDescrFile=
255+
PlotDirectoryName=../
256+
SubpartIdSeparator=0
257+
SubpartFirstId=65
258+
NetFmtName=
259+
SpiceAjustPassiveValues=0
260+
LabSize=50
261+
ERC_TestSimilarLabels=1

kicad/pico-dco.sch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,10 +814,10 @@ F 3 "~" H 3750 3800 50 0001 C CNN
814814
1 0 0 -1
815815
$EndComp
816816
$Comp
817-
L Regulator_Linear:L7805 U?
817+
L Regulator_Linear:L7805 U1
818818
U 1 1 61096C61
819819
P 1900 6400
820-
F 0 "U?" H 1900 6642 50 0000 C CNN
820+
F 0 "U1" H 1900 6642 50 0000 C CNN
821821
F 1 "L7805" H 1900 6551 50 0000 C CNN
822822
F 2 "Package_TO_SOT_THT:TO-220-3_Vertical" H 1925 6250 50 0001 L CIN
823823
F 3 "http://www.st.com/content/ccc/resource/technical/document/datasheet/41/4f/b3/b0/12/d4/47/88/CD00000444.pdf/files/CD00000444.pdf/jcr:content/translations/en.CD00000444.pdf" H 1900 6350 50 0001 C CNN

pico-dco-pcb.png

426 KB
Loading

pico-dco.c

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
#include "tusb.h"
1111
#include "hardware/uart.h"
1212

13-
#define NUM_VOICES 1
13+
#define NUM_VOICES 6
1414
#define MIDI_CHANNEL 1
1515

1616
const float BASE_NOTE = 440.0f;
17-
const uint8_t OUT_PINS[NUM_VOICES] = {2};
18-
const uint8_t RANGE_PINS[NUM_VOICES] = {3};
19-
const uint8_t GATE_PINS[NUM_VOICES] = {4};
17+
const uint8_t RESET_PINS[NUM_VOICES] = {13, 8, 12, 9, 11, 10};
18+
const uint8_t RANGE_PINS[NUM_VOICES] = {16, 19, 15, 18, 14, 17};
19+
const uint8_t GATE_PINS[NUM_VOICES] = {2, 3, 4, 5, 6, 7};
20+
const uint8_t VOICE_TO_PIO[NUM_VOICES] = {0, 0, 0, 0, 1, 1};
21+
const uint8_t VOICE_TO_SM[NUM_VOICES] = {0, 1, 2, 3, 0, 1};
2022
const uint16_t DIV_COUNTER = 1250;
2123
uint8_t RANGE_PWM_SLICES[NUM_VOICES];
2224
uint8_t NOTES[128];
@@ -58,9 +60,11 @@ int main() {
5860
}
5961

6062
// pio init
63+
uint offset[2];
64+
offset[0] = pio_add_program(pio[0], &frequency_program);
65+
offset[1] = pio_add_program(pio[1], &frequency_program);
6166
for (int i=0; i<NUM_VOICES; i++) {
62-
uint offset = pio_add_program(pio[0], &frequency_program);
63-
init_sm(pio[0], i, offset, OUT_PINS[i]);
67+
init_sm(pio[VOICE_TO_PIO[i]], VOICE_TO_SM[i], offset[VOICE_TO_PIO[i]], RESET_PINS[i]);
6468
}
6569

6670
// gate gpio init
@@ -84,7 +88,9 @@ void init_sm(PIO pio, uint sm, uint offset, uint pin) {
8488
}
8589

8690
void set_frequency(PIO pio, uint sm, float freq) {
87-
pio_sm_put(pio, sm, clock_get_hz(clk_sys) / 2 / freq);
91+
uint32_t clk_div = clock_get_hz(clk_sys) / 2 / freq;
92+
if (freq == 0) clk_div = 0;
93+
pio_sm_put(pio, sm, clk_div);
8894
pio_sm_exec(pio, sm, pio_encode_pull(false, false));
8995
pio_sm_exec(pio, sm, pio_encode_out(pio_y, 32));
9096
}
@@ -148,10 +154,11 @@ void serial_midi_task() {
148154
}
149155

150156
void note_on(uint8_t note, uint8_t velocity) {
157+
if (NOTES[note] > 0) return; // note already playing
151158
uint8_t voice_num = get_free_voice();
152159
NOTES[note] = voice_num;
153160
float freq = get_freq_from_midi_note(note);
154-
set_frequency(pio[0], voice_num, freq);
161+
set_frequency(pio[VOICE_TO_PIO[voice_num]], VOICE_TO_SM[voice_num], freq);
155162
// amplitude adjustment
156163
pwm_set_chan_level(RANGE_PWM_SLICES[voice_num], pwm_gpio_to_channel(RANGE_PINS[voice_num]), (int)(DIV_COUNTER*(freq*0.00025f-1/(100*freq))));
157164
// gate on
@@ -162,12 +169,23 @@ void note_off(uint8_t note) {
162169
// gate off
163170
gpio_put(GATE_PINS[NOTES[note]], 0);
164171
VOICES[NOTES[note]] = 0;
172+
NOTES[note] = 0;
165173
}
166174

167175
uint8_t get_free_voice() {
168-
uint8_t voice = 0;
169-
VOICES[voice] = board_millis();
170-
return voice;
176+
uint32_t oldest_time = board_millis();
177+
uint8_t oldest_voice = 0;
178+
for (int i=0; i<NUM_VOICES; i++) {
179+
if (VOICES[i] == 0) {
180+
VOICES[i] = board_millis();
181+
return i;
182+
}
183+
if (VOICES[i]<oldest_time) {
184+
oldest_time = VOICES[i];
185+
oldest_voice = i;
186+
}
187+
}
188+
return oldest_voice;
171189
}
172190

173191
void led_blinking_task(void) {

pico-dco.pdf

182 KB
Binary file not shown.

pico-dco.png

-51.2 KB
Loading

0 commit comments

Comments
 (0)