diff --git a/KiCad/RP2040-Decoder-Rev_0_2.csv b/KiCad/RP2040-Decoder-Rev_0_2.csv
new file mode 100644
index 0000000..79c2e73
--- /dev/null
+++ b/KiCad/RP2040-Decoder-Rev_0_2.csv
@@ -0,0 +1,84 @@
+"Source:","/home/gab/Documents/RP2040-Decoder/KiCad/RP2040-Decoder-Rev_0_2.kicad_sch"
+"Date:","Mo 14 Feb 2022 19:02:20 CET"
+"Tool:","Eeschema (6.0.1)"
+"Generator:","/usr/share/kicad/plugins/bom_csv_grouped_by_value.py"
+"Component Count:","43"
+
+"Individual Components:"
+
+"Item","Qty","Reference(s)","Value","LibPart","Footprint","Datasheet","Comment","Frequency"
+"","","C1","10u","Device:C","Capacitor_SMD:C_0603_1608Metric","~","",""
+"","","C2","10u","Device:C","Capacitor_SMD:C_0603_1608Metric","~","",""
+"","","C3","100n","Device:C","Capacitor_SMD:C_0603_1608Metric","~","",""
+"","","C4","100n","Device:C","Capacitor_SMD:C_0603_1608Metric","~","",""
+"","","C5","2u2","Device:C","Capacitor_SMD:C_0603_1608Metric","~","",""
+"","","C6","2u2","Device:C","Capacitor_SMD:C_0603_1608Metric","~","",""
+"","","C7","100n","Device:C","Capacitor_SMD:C_0603_1608Metric","~","",""
+"","","C8","100n","Device:C","Capacitor_SMD:C_0603_1608Metric","~","",""
+"","","C9","100n","Device:C","Capacitor_SMD:C_0603_1608Metric","~","",""
+"","","C10","100n","Device:C","Capacitor_SMD:C_0603_1608Metric","~","",""
+"","","C11","100n","Device:C","Capacitor_SMD:C_0603_1608Metric","~","",""
+"","","C12","100n","Device:C","Capacitor_SMD:C_0603_1608Metric","~","",""
+"","","C13","100n","Device:C","Capacitor_SMD:C_0603_1608Metric","~","",""
+"","","C14","2u2","Device:C","Capacitor_SMD:C_0603_1608Metric","~","",""
+"","","C15","100n","Device:C","Capacitor_SMD:C_0603_1608Metric","~","",""
+"","","C16","33p","Device:C","Capacitor_SMD:C_0603_1608Metric","~","",""
+"","","C17","33p","Device:C","Capacitor_SMD:C_0603_1608Metric","~","",""
+"","","D1","KMB24F","RP2040-Decoder_Additional_Symbols:KMB24F","Package_TO_SOT_SMD:TO-269AA","https://datasheet.lcsc.com/lcsc/2010151636_FUXINSEMI-KMB24F_C880910.pdf","TO-269AA = MBS",""
+"","","D2","1N4148WS","Diode:1N4148WS","Diode_SMD:D_SOD-323","https://datasheet.lcsc.com/lcsc/2008281134_TWGMC-1N4148WS_C727111.pdf","",""
+"","","D3","BZT52C3V3S",":BZT52C3V3S_1","Diode_SMD:D_SOD-323","https://datasheet.lcsc.com/lcsc/2109071430_YONGYUTAI-BZT52C3V3S_C2892655.pdf","",""
+"","","D4","BZT52C3V3S",":BZT52C3V3S_2","Diode_SMD:D_SOD-323","https://datasheet.lcsc.com/lcsc/2109071430_YONGYUTAI-BZT52C3V3S_C2892655.pdf","",""
+"","","D5","BZT52C3V3S",":BZT52C3V3S_3","Diode_SMD:D_SOD-323","https://datasheet.lcsc.com/lcsc/2109071430_YONGYUTAI-BZT52C3V3S_C2892655.pdf","",""
+"","","J1","DCC_IN","Connector:Conn_01x02_Male","Connector_PinHeader_1.00mm:PinHeader_1x02_P1.00mm_Vertical","~","",""
+"","","J2","MOTOR_CONN","Connector:Conn_01x04_Male","Connector_PinHeader_1.00mm:PinHeader_1x04_P1.00mm_Vertical","~","",""
+"","","J3","GPIO_CONN","Connector:Conn_01x06_Male","Connector_PinHeader_1.00mm:PinHeader_1x06_P1.00mm_Vertical","~","",""
+"","","J4","DEBUG_CONN","Connector:Conn_01x04_Male","Connector_PinHeader_1.00mm:PinHeader_1x04_P1.00mm_Vertical","~","",""
+"","","Q1","WNM2030",":WNM2030_1","RP2040-Decoder_Additional_Footprints:SOT-723-Extended_Pad","https://datasheet.lcsc.com/lcsc/1809191616_WILLSEMI-Will-Semicon-WNM2030-3-TR_C239769.pdf","",""
+"","","Q2","WNM2030",":WNM2030_2","RP2040-Decoder_Additional_Footprints:SOT-723-Extended_Pad","https://datasheet.lcsc.com/lcsc/1809191616_WILLSEMI-Will-Semicon-WNM2030-3-TR_C239769.pdf","",""
+"","","Q3","WNM2030",":WNM2030_3","RP2040-Decoder_Additional_Footprints:SOT-723-Extended_Pad","https://datasheet.lcsc.com/lcsc/1809191616_WILLSEMI-Will-Semicon-WNM2030-3-TR_C239769.pdf","",""
+"","","Q4","WNM2030","RP2040-Decoder_Additional_Symbols:WNM2030","RP2040-Decoder_Additional_Footprints:SOT-723-Extended_Pad","https://datasheet.lcsc.com/lcsc/1809191616_WILLSEMI-Will-Semicon-WNM2030-3-TR_C239769.pdf","",""
+"","","R1","3k9","Device:R","Resistor_SMD:R_0603_1608Metric","~","",""
+"","","R3","200",":R_1","Resistor_SMD:R_0603_1608Metric","~","",""
+"","","R4","DNF","Device:R","Resistor_SMD:R_0603_1608Metric","~","",""
+"","","R5","3k9","Device:R","Resistor_SMD:R_0603_1608Metric","~","",""
+"","","R6","3k9","Device:R","Resistor_SMD:R_0603_1608Metric","~","",""
+"","","R7","3k9","Device:R","Resistor_SMD:R_0603_1608Metric","~","",""
+"","","R8","3k9","Device:R","Resistor_SMD:R_0603_1608Metric","~","",""
+"","","R9","1k","Device:R","Resistor_SMD:R_0603_1608Metric","~","",""
+"","","U1","PJ75AL33SA","RP2040-Decoder_Additional_Symbols:PJ75AL33SA","Package_TO_SOT_SMD:SOT-23","https://datasheet.lcsc.com/lcsc/1912111437_PJSEMI-PJ75AL33SA_C411736.pdf","",""
+"","","U2","BDR6133","RP2040-Decoder_Additional_Symbols:BDR6133","Package_SO:SOIC-8-1EP_3.9x4.9mm_P1.27mm_EP2.41x3.3mm_ThermalVias","https://datasheet.lcsc.com/lcsc/2101211904_Bardeen-Micro--BDR6133_C2687793.pdf","",""
+"","","U3","W25Q64JVSSIQ","RP2040-Decoder_Additional_Symbols:W25Q64JVSSIQ","Package_SO:SOIC-8_5.23x5.23mm_P1.27mm","https://www.winbond.com/resource-files/w25q64jv%20revj%2003272018%20plus.pdf","",""
+"","","U4","RP2040","RP2040-Decoder_Additional_Symbols:RP2040","RP2040-Decoder_Additional_Footprints:QFN-56-1EP_7x7mm_P0.4mm_EP3.2x3.2mm","https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf","",""
+"","","Y1","X322512MSB4SI",":X322512MSB4SI_1","Crystal:Crystal_SMD_3225-4Pin_3.2x2.5mm","https://datasheet.lcsc.com/lcsc/2103291203_Yangxing-Tech-X322512MSB4SI_C9002.pdf","","12MHz"
+
+
+
+"Collated Components:"
+
+"Item","Qty","Reference(s)","Value","LibPart","Footprint","Datasheet","Comment","Frequency"
+"1","2","C1, C2","10u","Device:C","Capacitor_SMD:C_0603_1608Metric","~","",""
+"2","10","C3, C4, C7, C8, C9, C10, C11, C12, C13, C15","100n","Device:C","Capacitor_SMD:C_0603_1608Metric","~","",""
+"3","3","C5, C6, C14","2u2","Device:C","Capacitor_SMD:C_0603_1608Metric","~","",""
+"4","2","C16, C17","33p","Device:C","Capacitor_SMD:C_0603_1608Metric","~","",""
+"5","1","D1","KMB24F","RP2040-Decoder_Additional_Symbols:KMB24F","Package_TO_SOT_SMD:TO-269AA","https://datasheet.lcsc.com/lcsc/2010151636_FUXINSEMI-KMB24F_C880910.pdf","TO-269AA = MBS",""
+"6","1","D2","1N4148WS","Diode:1N4148WS","Diode_SMD:D_SOD-323","https://datasheet.lcsc.com/lcsc/2008281134_TWGMC-1N4148WS_C727111.pdf","",""
+"7","1","D3","BZT52C3V3S",":BZT52C3V3S_1","Diode_SMD:D_SOD-323","https://datasheet.lcsc.com/lcsc/2109071430_YONGYUTAI-BZT52C3V3S_C2892655.pdf","",""
+"8","1","D4","BZT52C3V3S",":BZT52C3V3S_2","Diode_SMD:D_SOD-323","https://datasheet.lcsc.com/lcsc/2109071430_YONGYUTAI-BZT52C3V3S_C2892655.pdf","",""
+"9","1","D5","BZT52C3V3S",":BZT52C3V3S_3","Diode_SMD:D_SOD-323","https://datasheet.lcsc.com/lcsc/2109071430_YONGYUTAI-BZT52C3V3S_C2892655.pdf","",""
+"10","1","J1","DCC_IN","Connector:Conn_01x02_Male","Connector_PinHeader_1.00mm:PinHeader_1x02_P1.00mm_Vertical","~","",""
+"11","1","J2","MOTOR_CONN","Connector:Conn_01x04_Male","Connector_PinHeader_1.00mm:PinHeader_1x04_P1.00mm_Vertical","~","",""
+"12","1","J3","GPIO_CONN","Connector:Conn_01x06_Male","Connector_PinHeader_1.00mm:PinHeader_1x06_P1.00mm_Vertical","~","",""
+"13","1","J4","DEBUG_CONN","Connector:Conn_01x04_Male","Connector_PinHeader_1.00mm:PinHeader_1x04_P1.00mm_Vertical","~","",""
+"14","1","Q1","WNM2030",":WNM2030_1","RP2040-Decoder_Additional_Footprints:SOT-723-Extended_Pad","https://datasheet.lcsc.com/lcsc/1809191616_WILLSEMI-Will-Semicon-WNM2030-3-TR_C239769.pdf","",""
+"15","1","Q2","WNM2030",":WNM2030_2","RP2040-Decoder_Additional_Footprints:SOT-723-Extended_Pad","https://datasheet.lcsc.com/lcsc/1809191616_WILLSEMI-Will-Semicon-WNM2030-3-TR_C239769.pdf","",""
+"16","1","Q3","WNM2030",":WNM2030_3","RP2040-Decoder_Additional_Footprints:SOT-723-Extended_Pad","https://datasheet.lcsc.com/lcsc/1809191616_WILLSEMI-Will-Semicon-WNM2030-3-TR_C239769.pdf","",""
+"17","1","Q4","WNM2030","RP2040-Decoder_Additional_Symbols:WNM2030","RP2040-Decoder_Additional_Footprints:SOT-723-Extended_Pad","https://datasheet.lcsc.com/lcsc/1809191616_WILLSEMI-Will-Semicon-WNM2030-3-TR_C239769.pdf","",""
+"18","5","R1, R5, R6, R7, R8","3k9","Device:R","Resistor_SMD:R_0603_1608Metric","~","",""
+"19","1","R3","200",":R_1","Resistor_SMD:R_0603_1608Metric","~","",""
+"20","1","R4","DNF","Device:R","Resistor_SMD:R_0603_1608Metric","~","",""
+"21","1","R9","1k","Device:R","Resistor_SMD:R_0603_1608Metric","~","",""
+"22","1","U1","PJ75AL33SA","RP2040-Decoder_Additional_Symbols:PJ75AL33SA","Package_TO_SOT_SMD:SOT-23","https://datasheet.lcsc.com/lcsc/1912111437_PJSEMI-PJ75AL33SA_C411736.pdf","",""
+"23","1","U2","BDR6133","RP2040-Decoder_Additional_Symbols:BDR6133","Package_SO:SOIC-8-1EP_3.9x4.9mm_P1.27mm_EP2.41x3.3mm_ThermalVias","https://datasheet.lcsc.com/lcsc/2101211904_Bardeen-Micro--BDR6133_C2687793.pdf","",""
+"24","1","U3","W25Q64JVSSIQ","RP2040-Decoder_Additional_Symbols:W25Q64JVSSIQ","Package_SO:SOIC-8_5.23x5.23mm_P1.27mm","https://www.winbond.com/resource-files/w25q64jv%20revj%2003272018%20plus.pdf","",""
+"25","1","U4","RP2040","RP2040-Decoder_Additional_Symbols:RP2040","RP2040-Decoder_Additional_Footprints:QFN-56-1EP_7x7mm_P0.4mm_EP3.2x3.2mm","https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf","",""
+"26","1","Y1","X322512MSB4SI",":X322512MSB4SI_1","Crystal:Crystal_SMD_3225-4Pin_3.2x2.5mm","https://datasheet.lcsc.com/lcsc/2103291203_Yangxing-Tech-X322512MSB4SI_C9002.pdf","","12MHz"
diff --git a/KiCad/RP2040-Decoder-Rev_0_2.kicad_sch b/KiCad/RP2040-Decoder-Rev_0_2.kicad_sch
index aff7e22..bde1116 100644
--- a/KiCad/RP2040-Decoder-Rev_0_2.kicad_sch
+++ b/KiCad/RP2040-Decoder-Rev_0_2.kicad_sch
@@ -4041,7 +4041,7 @@
(in_bom yes) (on_board yes)
(uuid 00000000-0000-0000-0000-0000621db99e)
(property "Reference" "R1" (id 0) (at 36.83 25.4 0))
- (property "Value" "10k" (id 1) (at 36.83 27.94 0))
+ (property "Value" "3k9" (id 1) (at 36.83 27.94 0))
(property "Footprint" "Resistor_SMD:R_0603_1608Metric" (id 2) (at 34.798 26.67 90)
(effects (font (size 1.27 1.27)) hide)
)
@@ -4091,7 +4091,7 @@
(in_bom yes) (on_board yes)
(uuid 00000000-0000-0000-0000-0000623b9b34)
(property "Reference" "R6" (id 0) (at 250.19 115.57 0))
- (property "Value" "10k" (id 1) (at 250.19 118.11 0))
+ (property "Value" "3k9" (id 1) (at 250.19 118.11 0))
(property "Footprint" "Resistor_SMD:R_0603_1608Metric" (id 2) (at 248.158 116.84 90)
(effects (font (size 1.27 1.27)) hide)
)
@@ -4106,7 +4106,7 @@
(in_bom yes) (on_board yes)
(uuid 00000000-0000-0000-0000-0000623ba784)
(property "Reference" "R8" (id 0) (at 250.19 125.73 0))
- (property "Value" "10k" (id 1) (at 250.19 128.27 0))
+ (property "Value" "3k9" (id 1) (at 250.19 128.27 0))
(property "Footprint" "Resistor_SMD:R_0603_1608Metric" (id 2) (at 248.158 127 90)
(effects (font (size 1.27 1.27)) hide)
)
@@ -4121,7 +4121,7 @@
(in_bom yes) (on_board yes)
(uuid 00000000-0000-0000-0000-0000623ce82a)
(property "Reference" "R7" (id 0) (at 217.17 125.73 0))
- (property "Value" "10k" (id 1) (at 217.17 128.27 0))
+ (property "Value" "3k9" (id 1) (at 217.17 128.27 0))
(property "Footprint" "Resistor_SMD:R_0603_1608Metric" (id 2) (at 222.758 127 90)
(effects (font (size 1.27 1.27)) hide)
)
@@ -4136,7 +4136,7 @@
(in_bom yes) (on_board yes)
(uuid 00000000-0000-0000-0000-0000623ce830)
(property "Reference" "R5" (id 0) (at 217.17 115.57 0))
- (property "Value" "10k" (id 1) (at 217.17 118.11 0))
+ (property "Value" "3k9" (id 1) (at 217.17 118.11 0))
(property "Footprint" "Resistor_SMD:R_0603_1608Metric" (id 2) (at 222.758 116.84 90)
(effects (font (size 1.27 1.27)) hide)
)
@@ -5041,7 +5041,7 @@
(reference "Q4") (unit 1) (value "WNM2030") (footprint "RP2040-Decoder_Additional_Footprints:SOT-723-Extended_Pad")
)
(path "/00000000-0000-0000-0000-0000621db99e"
- (reference "R1") (unit 1) (value "10k") (footprint "Resistor_SMD:R_0603_1608Metric")
+ (reference "R1") (unit 1) (value "3k9") (footprint "Resistor_SMD:R_0603_1608Metric")
)
(path "/b8f41645-564e-4e6d-89bf-38ca4d783693"
(reference "R3") (unit 1) (value "200") (footprint "Resistor_SMD:R_0603_1608Metric")
@@ -5050,16 +5050,16 @@
(reference "R4") (unit 1) (value "DNF") (footprint "Resistor_SMD:R_0603_1608Metric")
)
(path "/00000000-0000-0000-0000-0000623ce830"
- (reference "R5") (unit 1) (value "10k") (footprint "Resistor_SMD:R_0603_1608Metric")
+ (reference "R5") (unit 1) (value "3k9") (footprint "Resistor_SMD:R_0603_1608Metric")
)
(path "/00000000-0000-0000-0000-0000623b9b34"
- (reference "R6") (unit 1) (value "10k") (footprint "Resistor_SMD:R_0603_1608Metric")
+ (reference "R6") (unit 1) (value "3k9") (footprint "Resistor_SMD:R_0603_1608Metric")
)
(path "/00000000-0000-0000-0000-0000623ce82a"
- (reference "R7") (unit 1) (value "10k") (footprint "Resistor_SMD:R_0603_1608Metric")
+ (reference "R7") (unit 1) (value "3k9") (footprint "Resistor_SMD:R_0603_1608Metric")
)
(path "/00000000-0000-0000-0000-0000623ba784"
- (reference "R8") (unit 1) (value "10k") (footprint "Resistor_SMD:R_0603_1608Metric")
+ (reference "R8") (unit 1) (value "3k9") (footprint "Resistor_SMD:R_0603_1608Metric")
)
(path "/00000000-0000-0000-0000-0000620f5623"
(reference "R9") (unit 1) (value "1k") (footprint "Resistor_SMD:R_0603_1608Metric")
diff --git a/KiCad/RP2040-Decoder-Rev_0_2.xml b/KiCad/RP2040-Decoder-Rev_0_2.xml
new file mode 100644
index 0000000..5c70409
--- /dev/null
+++ b/KiCad/RP2040-Decoder-Rev_0_2.xml
@@ -0,0 +1,1156 @@
+
+
+
+ /home/gab/Documents/RP2040-Decoder/KiCad/RP2040-Decoder-Rev_0_2.kicad_sch
+ Mo 14 Feb 2022 19:02:20 CET
+ Eeschema (6.0.1)
+
+
+ RP2040-Decoder
+
+ 0.2
+ 2022-01-28
+ RP2040-Decoder-Rev_0_2.kicad_sch
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 10u
+ Capacitor_SMD:C_0603_1608Metric
+
+
+
+
+ 00000000-0000-0000-0000-0000621f2298
+
+
+ 10u
+ Capacitor_SMD:C_0603_1608Metric
+
+
+
+
+ 00000000-0000-0000-0000-0000621d77c4
+
+
+ 100n
+ Capacitor_SMD:C_0603_1608Metric
+
+
+
+
+ 00000000-0000-0000-0000-000061f7c99b
+
+
+ 100n
+ Capacitor_SMD:C_0603_1608Metric
+
+
+
+
+ 00000000-0000-0000-0000-000061f7bf44
+
+
+ 2u2
+ Capacitor_SMD:C_0603_1608Metric
+
+
+
+
+ 00000000-0000-0000-0000-000061f48903
+
+
+ 2u2
+ Capacitor_SMD:C_0603_1608Metric
+
+
+
+
+ 00000000-0000-0000-0000-000061f4730f
+
+
+ 100n
+ Capacitor_SMD:C_0603_1608Metric
+
+
+
+
+ 00000000-0000-0000-0000-000061f49506
+
+
+ 100n
+ Capacitor_SMD:C_0603_1608Metric
+
+
+
+
+ 00000000-0000-0000-0000-000061f4d9a1
+
+
+ 100n
+ Capacitor_SMD:C_0603_1608Metric
+
+
+
+
+ 00000000-0000-0000-0000-000061f4de3b
+
+
+ 100n
+ Capacitor_SMD:C_0603_1608Metric
+
+
+
+
+ 00000000-0000-0000-0000-000061f4ee25
+
+
+ 100n
+ Capacitor_SMD:C_0603_1608Metric
+
+
+
+
+ 00000000-0000-0000-0000-000061fbb1a5
+
+
+ 100n
+ Capacitor_SMD:C_0603_1608Metric
+
+
+
+
+ 00000000-0000-0000-0000-000061fbb8ee
+
+
+ 100n
+ Capacitor_SMD:C_0603_1608Metric
+
+
+
+
+ 00000000-0000-0000-0000-000061fc1d7c
+
+
+ 2u2
+ Capacitor_SMD:C_0603_1608Metric
+
+
+
+
+ 00000000-0000-0000-0000-000061feda0c
+
+
+ 100n
+ Capacitor_SMD:C_0603_1608Metric
+
+
+
+
+ 00000000-0000-0000-0000-00006202d251
+
+
+ 33p
+ Capacitor_SMD:C_0603_1608Metric
+
+
+
+
+ 00000000-0000-0000-0000-0000620db00d
+
+
+ 33p
+ Capacitor_SMD:C_0603_1608Metric
+
+
+
+
+ 00000000-0000-0000-0000-0000620dea8b
+
+
+ KMB24F
+ Package_TO_SOT_SMD:TO-269AA
+ https://datasheet.lcsc.com/lcsc/2010151636_FUXINSEMI-KMB24F_C880910.pdf
+
+ TO-269AA = MBS
+
+
+
+
+
+
+ d8c9e157-c0f6-4df9-9ba5-0bb60d315c95
+
+
+ 1N4148WS
+ Diode_SMD:D_SOD-323
+ https://datasheet.lcsc.com/lcsc/2008281134_TWGMC-1N4148WS_C727111.pdf
+
+
+
+
+ 00000000-0000-0000-0000-00006219c1a3
+
+
+ BZT52C3V3S
+ Diode_SMD:D_SOD-323
+ https://datasheet.lcsc.com/lcsc/2109071430_YONGYUTAI-BZT52C3V3S_C2892655.pdf
+
+
+
+
+ d801ac1b-19d7-4a6c-9e9e-c3524f1e6f82
+
+
+ BZT52C3V3S
+ Diode_SMD:D_SOD-323
+ https://datasheet.lcsc.com/lcsc/2109071430_YONGYUTAI-BZT52C3V3S_C2892655.pdf
+
+
+
+
+ 36efa69d-129e-4573-89ef-3ac56919e797
+
+
+ BZT52C3V3S
+ Diode_SMD:D_SOD-323
+ https://datasheet.lcsc.com/lcsc/2109071430_YONGYUTAI-BZT52C3V3S_C2892655.pdf
+
+
+
+
+ 380187f9-5366-4713-a781-9139a026a48e
+
+
+ DCC_IN
+ Connector_PinHeader_1.00mm:PinHeader_1x02_P1.00mm_Vertical
+
+
+
+
+ 00000000-0000-0000-0000-0000621bb5b9
+
+
+ MOTOR_CONN
+ Connector_PinHeader_1.00mm:PinHeader_1x04_P1.00mm_Vertical
+
+
+
+
+ 0ddb090e-4661-43b7-b7d9-cb3227885415
+
+
+ GPIO_CONN
+ Connector_PinHeader_1.00mm:PinHeader_1x06_P1.00mm_Vertical
+
+
+
+
+ 00000000-0000-0000-0000-0000624b0471
+
+
+ DEBUG_CONN
+ Connector_PinHeader_1.00mm:PinHeader_1x04_P1.00mm_Vertical
+
+
+
+
+ 00000000-0000-0000-0000-0000624e62e3
+
+
+ WNM2030
+ RP2040-Decoder_Additional_Footprints:SOT-723-Extended_Pad
+ https://datasheet.lcsc.com/lcsc/1809191616_WILLSEMI-Will-Semicon-WNM2030-3-TR_C239769.pdf
+
+
+
+
+ 93453ddd-b55e-4ec8-8c2c-2de58d2427d1
+
+
+ WNM2030
+ RP2040-Decoder_Additional_Footprints:SOT-723-Extended_Pad
+ https://datasheet.lcsc.com/lcsc/1809191616_WILLSEMI-Will-Semicon-WNM2030-3-TR_C239769.pdf
+
+
+
+
+ 7f252d06-5fe5-4970-b92f-115484bc237e
+
+
+ WNM2030
+ RP2040-Decoder_Additional_Footprints:SOT-723-Extended_Pad
+ https://datasheet.lcsc.com/lcsc/1809191616_WILLSEMI-Will-Semicon-WNM2030-3-TR_C239769.pdf
+
+
+
+
+ 95c0e16d-8a77-4c69-8ac9-e10237e6fd29
+
+
+ WNM2030
+ RP2040-Decoder_Additional_Footprints:SOT-723-Extended_Pad
+ https://datasheet.lcsc.com/lcsc/1809191616_WILLSEMI-Will-Semicon-WNM2030-3-TR_C239769.pdf
+
+
+
+
+ f0aa5d28-bdfe-47ba-9201-641e44fa359f
+
+
+ 3k9
+ Resistor_SMD:R_0603_1608Metric
+
+
+
+
+ 00000000-0000-0000-0000-0000621db99e
+
+
+ 200
+ Resistor_SMD:R_0603_1608Metric
+
+
+
+
+ b8f41645-564e-4e6d-89bf-38ca4d783693
+
+
+ DNF
+ Resistor_SMD:R_0603_1608Metric
+
+
+
+
+ 00000000-0000-0000-0000-0000620484ef
+
+
+ 3k9
+ Resistor_SMD:R_0603_1608Metric
+
+
+
+
+ 00000000-0000-0000-0000-0000623ce830
+
+
+ 3k9
+ Resistor_SMD:R_0603_1608Metric
+
+
+
+
+ 00000000-0000-0000-0000-0000623b9b34
+
+
+ 3k9
+ Resistor_SMD:R_0603_1608Metric
+
+
+
+
+ 00000000-0000-0000-0000-0000623ce82a
+
+
+ 3k9
+ Resistor_SMD:R_0603_1608Metric
+
+
+
+
+ 00000000-0000-0000-0000-0000623ba784
+
+
+ 1k
+ Resistor_SMD:R_0603_1608Metric
+
+
+
+
+ 00000000-0000-0000-0000-0000620f5623
+
+
+ PJ75AL33SA
+ Package_TO_SOT_SMD:SOT-23
+ https://datasheet.lcsc.com/lcsc/1912111437_PJSEMI-PJ75AL33SA_C411736.pdf
+
+
+
+
+ e2c2b2de-c597-41d8-88b7-dd957f57a7ab
+
+
+ BDR6133
+ Package_SO:SOIC-8-1EP_3.9x4.9mm_P1.27mm_EP2.41x3.3mm_ThermalVias
+ https://datasheet.lcsc.com/lcsc/2101211904_Bardeen-Micro--BDR6133_C2687793.pdf
+
+
+
+
+ 015952e7-15cf-4988-8378-751c6a0293ce
+
+
+ W25Q64JVSSIQ
+ Package_SO:SOIC-8_5.23x5.23mm_P1.27mm
+ https://www.winbond.com/resource-files/w25q64jv%20revj%2003272018%20plus.pdf
+
+
+
+
+ 11b43075-515f-45da-8f63-74ef52534506
+
+
+ RP2040
+ RP2040-Decoder_Additional_Footprints:QFN-56-1EP_7x7mm_P0.4mm_EP3.2x3.2mm
+ https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf
+
+
+
+
+ 5be710a2-fcda-4b2d-9820-ecc5222143f9
+
+
+ X322512MSB4SI
+ Crystal:Crystal_SMD_3225-4Pin_3.2x2.5mm
+ https://datasheet.lcsc.com/lcsc/2103291203_Yangxing-Tech-X322512MSB4SI_C9002.pdf
+
+ 12MHz
+
+
+
+
+
+
+ 7e3144dd-ae35-4368-a7ae-3c7281afa76c
+
+
+
+
+ 200mW Zener Diode, SOD-323
+ https://datasheet.lcsc.com/lcsc/2109071430_YONGYUTAI-BZT52C3V3S_C2892655.pdf
+
+ D?SOD?123*
+
+
+ D
+ BZT52C3V3S_1
+ Diode_SMD:D_SOD-323
+ https://datasheet.lcsc.com/lcsc/2109071430_YONGYUTAI-BZT52C3V3S_C2892655.pdf
+
+
+
+
+
+
+
+ 200mW Zener Diode, SOD-323
+ https://datasheet.lcsc.com/lcsc/2109071430_YONGYUTAI-BZT52C3V3S_C2892655.pdf
+
+ D?SOD?123*
+
+
+ D
+ BZT52C3V3S_2
+ Diode_SMD:D_SOD-323
+ https://datasheet.lcsc.com/lcsc/2109071430_YONGYUTAI-BZT52C3V3S_C2892655.pdf
+
+
+
+
+
+
+
+ 200mW Zener Diode, SOD-323
+ https://datasheet.lcsc.com/lcsc/2109071430_YONGYUTAI-BZT52C3V3S_C2892655.pdf
+
+ D?SOD?123*
+
+
+ D
+ BZT52C3V3S_3
+ Diode_SMD:D_SOD-323
+ https://datasheet.lcsc.com/lcsc/2109071430_YONGYUTAI-BZT52C3V3S_C2892655.pdf
+
+
+
+
+
+
+
+ Resistor
+ ~
+
+ R_*
+
+
+ R3
+ 200
+ Resistor_SMD:R_0603_1608Metric
+ ~
+
+
+
+
+
+
+
+ 20V Vds, 0.95 Id, N-Channel MOSFET with ESD protection, SOT-723
+ https://datasheet.lcsc.com/lcsc/1809191616_WILLSEMI-Will-Semicon-WNM2030-3-TR_C239769.pdf
+
+ SOT?723*
+
+
+ Q
+ WNM2030_1
+ RP2040-Decoder_Additional_Footprints:SOT-723-Extended_Pad
+ https://datasheet.lcsc.com/lcsc/1809191616_WILLSEMI-Will-Semicon-WNM2030-3-TR_C239769.pdf
+
+
+
+
+
+
+
+
+ 20V Vds, 0.95 Id, N-Channel MOSFET with ESD protection, SOT-723
+ https://datasheet.lcsc.com/lcsc/1809191616_WILLSEMI-Will-Semicon-WNM2030-3-TR_C239769.pdf
+
+ SOT?723*
+
+
+ Q
+ WNM2030_2
+ RP2040-Decoder_Additional_Footprints:SOT-723-Extended_Pad
+ https://datasheet.lcsc.com/lcsc/1809191616_WILLSEMI-Will-Semicon-WNM2030-3-TR_C239769.pdf
+
+
+
+
+
+
+
+
+ 20V Vds, 0.95 Id, N-Channel MOSFET with ESD protection, SOT-723
+ https://datasheet.lcsc.com/lcsc/1809191616_WILLSEMI-Will-Semicon-WNM2030-3-TR_C239769.pdf
+
+ SOT?723*
+
+
+ Q
+ WNM2030_3
+ RP2040-Decoder_Additional_Footprints:SOT-723-Extended_Pad
+ https://datasheet.lcsc.com/lcsc/1809191616_WILLSEMI-Will-Semicon-WNM2030-3-TR_C239769.pdf
+
+
+
+
+
+
+
+
+ Four pin crystal 12MHz, GND on pins 2 and 4, SMD3225-4P Package
+ https://datasheet.lcsc.com/lcsc/2103291203_Yangxing-Tech-X322512MSB4SI_C9002.pdf
+
+ Crystal*
+
+
+ Y
+ X322512MSB4SI_1
+ Crystal:Crystal_SMD_3225-4Pin_3.2x2.5mm
+ https://datasheet.lcsc.com/lcsc/2103291203_Yangxing-Tech-X322512MSB4SI_C9002.pdf
+ 12MHz
+
+
+
+
+
+
+
+
+
+ Generic connector, single row, 01x02, script generated (kicad-library-utils/schlib/autogen/connector/)
+ ~
+
+ Connector*:*_1x??_*
+
+
+ J1
+ DCC_IN
+ ~
+
+
+
+
+
+
+
+ Generic connector, single row, 01x04, script generated (kicad-library-utils/schlib/autogen/connector/)
+ ~
+
+ Connector*:*_1x??_*
+
+
+ J
+ Conn_01x04_Male
+ ~
+
+
+
+
+
+
+
+
+
+ Generic connector, single row, 01x06, script generated (kicad-library-utils/schlib/autogen/connector/)
+ ~
+
+ Connector*:*_1x??_*
+
+
+ J
+ Conn_01x06_Male
+ ~
+
+
+
+
+
+
+
+
+
+
+
+ Unpolarized capacitor
+ ~
+
+ C_*
+
+
+ C
+ C
+ ~
+
+
+
+
+
+
+
+ Resistor
+ ~
+
+ R_*
+
+
+ R
+ R
+ ~
+
+
+
+
+
+
+
+ 75V 0.15A Fast switching Diode, SOD-323
+ https://www.vishay.com/docs/85751/1n4148ws.pdf
+
+ D*SOD?323*
+
+
+ D
+ 1N4148WS
+ Diode_SMD:D_SOD-323
+ https://www.vishay.com/docs/85751/1n4148ws.pdf
+
+
+
+
+
+
+
+ H-Bridge driver, 1A, Low Voltage, PWM input, WSON-8
+ https://datasheet.lcsc.com/lcsc/2101211904_Bardeen-Micro--BDR6133_C2687793.pdf
+
+ WSON*1EP*2x2mm*P0.5mm*
+
+
+ U
+ BDR6133
+ Package_SO:SOIC-8-1EP_3.9x4.9mm_P1.27mm_EP2.29x3mm
+ https://datasheet.lcsc.com/lcsc/2101211904_Bardeen-Micro--BDR6133_C2687793.pdf
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Schottky Surface Mount Bridge Rectifiers, 40V Vrms, 2A If, MBS (TO-269AA)
+ https://datasheet.lcsc.com/lcsc/2010151636_FUXINSEMI-KMB24F_C880910.pdf
+
+ TO?269AA*
+
+
+ D
+ KMB24F
+ Package_TO_SOT_SMD:TO-269AA
+ https://datasheet.lcsc.com/lcsc/2010151636_FUXINSEMI-KMB24F_C880910.pdf
+ TO-269AA = MBS
+
+
+
+
+
+
+
+
+
+ 100mA, Low Dropout Voltage Regulator, 3.3V positive fixed output, SOT-23 package
+ https://datasheet.lcsc.com/lcsc/1912111437_PJSEMI-PJ75AL33SA_C411736.pdf
+
+ SOT?23*
+
+
+ U
+ PJ75AL33SA
+ Package_TO_SOT_SMD:SOT-23
+ https://datasheet.lcsc.com/lcsc/1912111437_PJSEMI-PJ75AL33SA_C411736.pdf
+
+
+
+
+
+
+
+
+ https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf
+
+ U
+ RP2040
+ RP2040-Decoder_Additional_Footprints:QFN-56-1EP_7x7mm_P0.4mm_EP3.2x3.2mm
+ https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 64Mb Serial Flash Memory, Standard/Dual/Quad SPI, SOIC-8
+ https://www.winbond.com/resource-files/w25q64jv%20revj%2003272018%20plus.pdf
+
+ SOIC*5.23x5.23mm*P1.27mm*
+
+
+ U
+ W25Q64JVSSIQ
+ Package_SO:SOIC-8_5.23x5.23mm_P1.27mm
+ https://www.winbond.com/resource-files/w25q64jv%20revj%2003272018%20plus.pdf
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 20V Vds, 0.95 Id, N-Channel MOSFET with ESD protection, SOT-723
+ https://datasheet.lcsc.com/lcsc/1809191616_WILLSEMI-Will-Semicon-WNM2030-3-TR_C239769.pdf
+
+ SOT?723*
+
+
+ Q
+ WNM2030
+ RP2040-Decoder_Additional_Footprints:SOT-723-Extended_Pad
+ https://datasheet.lcsc.com/lcsc/1809191616_WILLSEMI-Will-Semicon-WNM2030-3-TR_C239769.pdf
+
+
+
+
+
+
+
+
+
+
+ /usr/share/kicad/symbols//Connector.kicad_sym
+
+
+ /usr/share/kicad/symbols//Device.kicad_sym
+
+
+ /usr/share/kicad/symbols//Diode.kicad_sym
+
+
+ /home/gab/Documents/RP2040-Decoder/KiCad/RP2040-Decoder_Additional_Symbols.kicad_sym
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/core0.c b/core0.c
index 68e9d64..2e02ce5 100644
--- a/core0.c
+++ b/core0.c
@@ -262,7 +262,7 @@ void instruction_evaluation(uint8_t number_of_bytes,const uint8_t byte_array[])
}
//Interrupt handler for DCC Logic Signal
void gpio_callback_rise(unsigned int gpio, long unsigned int events) {
- add_alarm_in_us(87, &readBit_alarm_callback, NULL, true);
+ add_alarm_in_us(87, &readBit_alarm_callback, NULL, false);
}
void evaluation(){
@@ -288,18 +288,21 @@ void evaluation(){
}
int main() {
- busy_wait_ms(2000);
+ //busy_wait_ms(2000);
stdio_init_all();
- printf("Launched successfully2.\n");
-// gpio_init(10);
-// gpio_set_dir(10,GPIO_OUT);
-// gpio_put(10,true);
+ printf("core0 init...\n");
+ //gpio_init(PICO_DEFAULT_LED_PIN);
+ //gpio_set_dir(PICO_DEFAULT_LED_PIN,GPIO_OUT);
+ //gpio_put(PICO_DEFAULT_LED_PIN,true);
gpio_init(DCC_INPUT_PIN);
gpio_set_dir(DCC_INPUT_PIN, GPIO_IN);
- gpio_init_mask(ALLOWED_GPIO_MASK);
- gpio_set_dir_out_masked(ALLOWED_GPIO_MASK);
+ //gpio_init_mask(ALLOWED_GPIO_MASK);
+ //gpio_set_dir_out_masked(ALLOWED_GPIO_MASK);
multicore_launch_core1(core1_entry);
gpio_set_irq_enabled_with_callback(DCC_INPUT_PIN, GPIO_IRQ_EDGE_RISE, true, &gpio_callback_rise);
- printf("Launched successfully.3\n");
- while (1) ;
+ printf("core0 done\n");
+ while (1){
+ printf("0\n");
+ printf("0-\n");
+ }
}
\ No newline at end of file
diff --git a/core0.h b/core0.h
index 693a6a5..ab1316a 100644
--- a/core0.h
+++ b/core0.h
@@ -9,7 +9,7 @@
#include "CV.h"
#define SIZE_BYTE_ARRAY 5
#define SIZE_ACTIVE_FUNCTIONS 32
-#define DCC_INPUT_PIN 11 //Custom: 11 Default: 14
+#define DCC_INPUT_PIN 9
//Default
//#define ALLOWED_GPIO_MASK 0b00000000000000000000111111111100 //prevents setting GPIO's that are not allowed (ADC, PWM, ...)
//Custom
diff --git a/core1.c b/core1.c
index f748680..cc7fd66 100644
--- a/core1.c
+++ b/core1.c
@@ -5,9 +5,9 @@
//////////////////////////
#include "core1.h"
-int msr_arr[10000] = {0};
-uint current_target = 0;
+uint16_t current_target = 0;
+float current_target_voltage = 0;
struct repeating_timer pid_control_timer,speed_helper_timer;
typedef struct pid_params{
@@ -15,12 +15,12 @@ typedef struct pid_params{
float t_s;
float a_1;
float a_2;
- int sum_limit_max;
- int sum_limit_min;
+ float sum_limit_max;
+ float sum_limit_min;
float output;
- int e;
- int e_prev;
- int e_sum;
+ float e;
+ float e_prev;
+ float e_sum;
}pid_params;
pid_params pid;
@@ -31,50 +31,28 @@ typedef struct measure_params{
uint8_t right_side_array_cutoff;
}measure_params;
measure_params msr;
+uint8_t a_factor = 30; /*CV_ARRAY_FLASH[59];..................*/
-void quicksort(uint16_t number[], int first, int last){
- int i, j, pivot, temp;
- if(firstnumber[pivot])
- j--;
- if(i Time for 1 Speed Step := (speed_helper timer delay)*(accel_rate)
static uint8_t speed_helper_counter;
//Emergency Stop
if (target_speed_step == 129 || target_speed_step==1) {
@@ -83,15 +61,15 @@ bool speed_helper() {
}
//Acceleration
else if (end_target > current_target && speed_helper_counter == accel_rate) {
- current_target += CV_ARRAY_FLASH[59];
+ current_target += a_factor;
speed_helper_counter = 0;
}
//Deceleration
else if (end_target < current_target && speed_helper_counter == decel_rate) {
- current_target -= CV_ARRAY_FLASH[59];
+ current_target -= a_factor;
speed_helper_counter = 0;
}
- //Accel/Decel "scheduled"
+ //Acceleration/Deceleration "scheduled"
else if (end_target != current_target){
speed_helper_counter++;
}
@@ -99,51 +77,88 @@ bool speed_helper() {
else{
speed_helper_counter = 0;
}
+ current_target_voltage = (float)current_target/1260;
return true;
}
-int measure(){
+float measure(){
pwm_set_gpio_level(MOTOR_PWM_FORWARD,0);
pwm_set_gpio_level(MOTOR_PWM_REVERSE,0);
adc_select_input(!target_direction);
- busy_wait_us(msr.delay_in_us);
- //gpio_put(9,true);
+ busy_wait_us(100/*msr.delay_in_us*/);
uint32_t sum = 0;
- uint16_t adc_values[msr.total_iterations];
- for (int i = 0; i < msr.total_iterations; ++i) {
- adc_values[i] = adc_read();
+ uint16_t adc_val[100/*msr.total_iterations*/];
+ adc_run(true);
+ int key, j;
+ for (int i = 0; i < 100/*msr.total_iterations*/; ++i) {
+ adc_val[i] = adc_fifo_get_blocking();
+ //Insertion Sort (1 Step)
+ key = adc_val[i];
+ j = i - 1;
+ while (j >= 0 && adc_val[j] > key) {
+ adc_val[j + 1] = adc_val[j];
+ j = j - 1;
+ }
+ adc_val[j + 1] = key;
}
- //gpio_put(9,false);
- quicksort(adc_values, 0, msr.total_iterations - 1);
- for (uint8_t i = msr.left_side_array_cutoff; i < msr.total_iterations - msr.right_side_array_cutoff ; ++i) {
- sum = sum+adc_values[i];
+ adc_run(false);
+ for (uint8_t i = msr.left_side_array_cutoff; i < 100/*msr.total_iterations*/ - msr.right_side_array_cutoff ; ++i) {
+ sum += adc_val[i];
}
- float result_f = (float)sum/(float)(msr.total_iterations - 20);
- if(result_f>MEASURE_CORRECTION_THRESHOLD){
- result_f = 11*result_f*result_f/(1241*1241) - 43*result_f/1241 + 45;
+ //V_z is represented in 12bit
+ float V_z = (float)sum / (float)(100/*msr.total_iterations*/ - 30);
+ //Zener correction (approximated) & Conversion factor for V_z <= 1951
+ //Returns Value in "Volts"
+ if (V_z > 1951){
+ float V_z_sq = V_z * V_z;
+ return ( C0 + C1 * V_z + C2 * V_z_sq + C3 * V_z * V_z_sq + C4 * V_z_sq * V_z_sq);
}
- int result = (int)result_f;
- return result;
+ else{
+ return (L1*V_z);
+ }
+}
+void set_pid_params(float v){
+ float v_max = (float)a_factor/10;
+ pid.t_s = 5.0f / 1000;
+ pid.k_p = (-90*v)/v_max+100.0f;
+ pid.a_1 = 0.0f * pid.t_s; // k_i*t_s
+ pid.a_2 = 2.0f / pid.t_s; // k_d/t_s
+ if (pid.k_p<10)pid.k_p=10;
+ if (pid.a_2<0)pid.k_p=0;
+ /*if (v > 0.6f * max_voltage){
+ pid.k_p = 5.0f;
+ pid.t_s = 5.0f / 1000;
+ pid.a_1 = 0.5f * pid.t_s; // k_i*t_s
+ pid.a_2 = 0.0f / pid.t_s; // k_d/t_s
+ }
+ else if(v > 0.2f * max_voltage){
+ pid.k_p = 30.0f;
+ pid.t_s = 5.0f / 1000;
+ pid.a_1 = 0.0f * pid.t_s; // k_i*t_s
+ pid.a_2 = 5.0f / pid.t_s; // k_d/t_s
+ }*/
+ //else{
+
+ //}
}
bool pid_control(struct repeating_timer *t){
- static uint counter;
- int msr_val = measure();
- pid.e = (int)current_target - msr_val;
- msr_arr[counter] = msr_val;
- counter++;
+ float measured_voltage = measure();
+ set_pid_params(measured_voltage);
+ pid.e = current_target_voltage - measured_voltage;
pid.e_sum = pid.e_sum + pid.e;
if (pid.e_sum > pid.sum_limit_max) pid.e_sum = pid.sum_limit_max;
else if (pid.e_sum < pid.sum_limit_min) pid.e_sum = pid.sum_limit_min;
pid.output += (pid.k_p * (float)pid.e) +
- (pid.a_1 * (float)pid.e_sum) + // k_i*t_s*e_sum
- (pid.a_2 * (float)(pid.e - pid.e_prev)); // (k_d/t_s)*(e-e_prev)
- pid.e_prev = pid.e;
- if (current_target == 0) pid.output = 0;
- else if (pid.output > 5000) pid.output = 5000;
- else if (pid.output < 1000) pid.output = 1000;
- adjust_pwm_level((uint16_t )pid.output);
- return true;
+ (pid.a_1 * (float)pid.e_sum) + // k_i*t_s*e_sum
+ (pid.a_2 * (float)(pid.e - pid.e_prev)); // (k_d/t_s)*(e-e_prev)
+ pid.e_prev = pid.e;
+ if (current_target == 0) pid.output = 0;
+ else if (pid.output > 5000) pid.output = 5000;
+ else if (pid.output < 1000) pid.output = 1000;
+ adjust_pwm_level((uint16_t )pid.output);
+ adc_fifo_drain();
+ return true;
}
void init_pid(){
@@ -151,12 +166,12 @@ void init_pid(){
// pid.t_s = ((float)CV_ARRAY_FLASH[47] / 1000);
// pid.a_1 = ((float)CV_ARRAY_FLASH[49] / 64) * pid.t_s ; // k_i*t_s
// pid.a_2 = ((float)CV_ARRAY_FLASH[50] / 4096) / pid.t_s; // k_d/t_s
- pid.k_p = 1.0f;
- pid.t_s = 10.0f / 1000;
- pid.a_1 = 0.0f * pid.t_s ; // k_i*t_s
- pid.a_2 = 0.0f / pid.t_s; // k_d/t_s
- pid.sum_limit_max = CV_ARRAY_FLASH[51] * 10;
- pid.sum_limit_min = CV_ARRAY_FLASH[52] * (-10);
+ //pid.k_p = 5.0f;
+ //pid.t_s = 5.0f / 1000;
+ //pid.a_1 = 0.5f * pid.t_s; // k_i*t_s
+ //pid.a_2 = 0.0f / pid.t_s; // k_d/t_s
+ pid.sum_limit_max = 200.0f;/*(float)(CV_ARRAY_FLASH[51] );*/
+ pid.sum_limit_min = -200.0f;/*(float)(CV_ARRAY_FLASH[52] * (-1));*/
msr.total_iterations = 70;/*CV_ARRAY_FLASH[60];*/
msr.delay_in_us = CV_ARRAY_FLASH[61];
msr.left_side_array_cutoff = 15;/*CV_ARRAY_FLASH[62];*/
@@ -182,26 +197,32 @@ void print_cv_array(const uint8_t *buf, size_t len) {
}
}
void core1_entry() {
+ printf("core1 init...\n");
if(gpio_get_function(MOTOR_PWM_FORWARD)!=4){
gpio_set_function(MOTOR_PWM_FORWARD, GPIO_FUNC_PWM);
gpio_set_function(MOTOR_PWM_REVERSE, GPIO_FUNC_PWM);
adc_init();
adc_gpio_init(V_EMF_ADC_PIN_FORWARD);
adc_gpio_init(V_EMF_ADC_PIN_REVERSE);
+ adc_fifo_setup(true,false,0,false,false);
init_pwm(MOTOR_PWM_FORWARD);
init_pwm(MOTOR_PWM_REVERSE);
init_pid();
}
alarm_pool_add_repeating_timer_ms(alarm_pool_create(0,1),
- 10/*CV_ARRAY_FLASH[47]*/,
+ 5/*CV_ARRAY_FLASH[47]*/,
pid_control,
NULL,
&pid_control_timer);
- irq_set_priority(0,0x00); // 0x00 is equivalent to the highest priority!
+ irq_set_priority(0,0x00); // 0x00 = highest priority
alarm_pool_add_repeating_timer_ms(alarm_pool_create(1,1),
7,
speed_helper,
NULL,
&speed_helper_timer);
- while (1);
+ printf("core1 done\n");
+ while (1){
+ printf("1\n");
+ printf("-1\n");
+ }
}
\ No newline at end of file
diff --git a/core1.h b/core1.h
index bef2f44..00b692b 100644
--- a/core1.h
+++ b/core1.h
@@ -8,11 +8,18 @@
#include "shared.h"
#define V_EMF_ADC_PIN_FORWARD 26
#define V_EMF_ADC_PIN_REVERSE 27
-#define MEASURE_CORRECTION_THRESHOLD 2271
-void quicksort(uint16_t number[], int first, int last);
-uint calc_end_target();
+
+#define MEASURE_CORRECTION_THRESHOLD 1695
+#define L1 0.001611328125f
+#define C0 26.18270299751651f
+#define C1 -0.04661614287233649f
+#define C2 3.29589342261872e-05f
+#define C3 -1.000062393830345e-08f
+#define C4 1.15408454807169e-12f
+
+uint16_t calc_end_target();
bool speed_helper();
-int measure();
+float measure();
void init_pid();
void init_pwm(uint gpio);
void print_cv_array(const uint8_t *buf, size_t len);
\ No newline at end of file
diff --git a/shared.h b/shared.h
index fdd2016..cef2d7b 100644
--- a/shared.h
+++ b/shared.h
@@ -14,8 +14,8 @@
#include "hardware/flash.h"
#include "hardware/irq.h"
#include "stdint.h"
-#define MOTOR_PWM_FORWARD 10 //Custom: 10 Default: 12
-#define MOTOR_PWM_REVERSE 13
+#define MOTOR_PWM_FORWARD 22
+#define MOTOR_PWM_REVERSE 23
extern repeating_timer_t pid_control_timer;
extern repeating_timer_t speed_helper_timer;
extern bool target_direction;