esp32_motor-pcb-x3_old.py (11525B)
1 from skidl import * 2 3 # Set the default tool to KiCad 7 for footprint management. 4 set_default_tool(KICAD7) 5 6 # Create ESP32 and TMC5160 headers with updated part names 7 esp32_header1 = Part("Connector_Generic", "Conn_01x15", footprint="PinSocket_1x15_P2.54mm_Vertical", ref="ESP32_HEADER1") 8 esp32_header2 = Part("Connector_Generic", "Conn_01x15", footprint="PinSocket_1x15_P2.54mm_Vertical", ref="ESP32_HEADER2") 9 10 tmc5160_header1 = Part("Connector_Generic", "Conn_01x08", footprint="PinSocket_1x08_P2.54mm_Vertical", ref="TMC5160_HEADER1") 11 tmc5160_header2 = Part("Connector_Generic", "Conn_01x08", footprint="PinSocket_1x08_P2.54mm_Vertical", ref="TMC5160_HEADER2") 12 13 tmc5160_header1b = Part("Connector_Generic", "Conn_01x08", footprint="PinSocket_1x08_P11.04.20242.54mm_Vertical", ref="TMC5160_HEADER1B") 14 tmc5160_header2b = Part("Connector_Generic", "Conn_01x08", footprint="PinSocket_1x08_P2.54mm_Vertical", ref="TMC5160_HEADER2B") 15 16 tmc5160_header1c = Part("Connector_Generic", "Conn_01x08", footprint="PinSocket_1x08_P2.54mm_Vertical", ref="TMC5160_HEADER1C") 17 tmc5160_header2c = Part("Connector_Generic", "Conn_01x08", footprint="PinSocket_1x08_P2.54mm_Vertical", ref="TMC5160_HEADER2C") 18 19 # Create 1x4 connector for stepper motor connections 20 stepper_motor_header = Part("Connector_Generic", "Conn_01x04", footprint="PinHeader_1x04_P2.54mm_Vertical", ref="STEPPER_HEADER") 21 stepper_motor_header_b = Part("Connector_Generic", "Conn_01x04", footprint="PinHeader_1x04_P2.54mm_Vertical", ref="STEPPER_HEADER") 22 stepper_motor_header_c = Part("Connector_Generic", "Conn_01x04", footprint="PinHeader_1x04_P2.54mm_Vertical", ref="STEPPER_HEADER") 23 24 # Create 1x4 connector for CAN Bus connections 25 can_bus_header = Part("Connector_Generic", "Conn_01x04", footprint="PinHeader_1x04_P2.54mm_Vertical", ref="CAN_BUS_HEADER") 26 27 # Create 100uF 63V capacitor with correct footprint 28 capacitor = Part("Device", "C", value="100uF", voltage="63V", footprint="Capacitor_THT:CP_Radial_D10.0mm_P5.00mm") 29 capacitor_b = Part("Device", "C", value="100uF", voltage="63V", footprint="Capacitor_THT:CP_Radial_D10.0mm_P5.00mm") 30 capacitor_c = Part("Device", "C", value="100uF", voltage="63V", footprint="Capacitor_THT:CP_Radial_D10.0mm_P5.00mm") 31 32 # Define resistor 33 #resistor1 = Part("Device", "R", value="220", footprint="R_0603_1608Metric") 34 35 # Create 1x2 horizontal header for limit switch connections 36 # limit_switch_header = Part("Connector_Generic", "Conn_01x02", footprint="PinHeader_1x02_P2.54mm_Horizontal", ref="LIMIT_SWITCH_HEADER") 37 38 # Create a 3-pin terminal block for 36V connections 39 terminal_block = Part("Connector_Generic", "Conn_01x03", footprint="TerminalBlock_Phoenix_PT-1,5-2-5.0-H_1x02_P5.00mm_Horizontal", ref="TERMINAL_BLOCK") 40 41 # Create through-hole solder pads for 36V+ and 36V_GND connections with 2.54mm spacing 42 terminal_block_2 = Part("Connector_Generic", "Conn_01x02", footprint="TerminalBlock_Phoenix_MPT-0,5-2-2.54_1x02_P2.54mm_Horizontal", ref="TERMINAL_BLOCK_2") 43 44 # Create 36V_V+ and 36V_GND nets. 45 V_plus_36V = Net("36V_V+") 46 GND_36V = Net("36V_GND") 47 48 # Define the GPIO pins according to ESP32 30pin version. 49 esp32_vin = esp32_header1[1] 50 esp32_gnd1 = esp32_header1[2] 51 esp32_3v3 = esp32_header2[1] 52 esp32_gnd2 = esp32_header2[2] 53 esp32_gpio2 = esp32_header2[4] 54 esp32_gpio4 = esp32_header2[5] 55 esp32_gpio5 = esp32_header2[8] 56 esp32_gpio12 = esp32_header1[4] 57 esp32_gpio13 = esp32_header1[3] 58 esp32_gpio14 = esp32_header1[5] 59 esp32_gpio15 = esp32_header2[3] 60 esp32_gpio16 = esp32_header2[6] 61 esp32_gpio17 = esp32_header2[7] 62 esp32_gpio18 = esp32_header2[9] 63 esp32_gpio19 = esp32_header2[10] 64 esp32_gpio21 = esp32_header2[11] 65 esp32_gpio22 = esp32_header2[14] 66 esp32_gpio23 = esp32_header2[15] 67 esp32_gpio25 = esp32_header1[8] 68 esp32_gpio26 = esp32_header1[7] 69 esp32_gpio27 = esp32_header1[6] 70 esp32_gpio32 = esp32_header1[10] 71 esp32_gpio33 = esp32_header1[9] 72 73 # Define the pins for TMC5160 74 tmc5160_gnd2 = tmc5160_header1[8] 75 tmc5160_3v3 = tmc5160_header1[7] 76 tmc5160_m2b = tmc5160_header1[6] 77 tmc5160_m1b = tmc5160_header1[5] 78 tmc5160_m1a = tmc5160_header1[4] 79 tmc5160_m2a = tmc5160_header1[3] 80 tmc5160_gnd1 = tmc5160_header1[2] 81 tmc5160_vmot = tmc5160_header1[1] 82 tmc5160_en = tmc5160_header2[1] 83 tmc5160_sdi = tmc5160_header2[2] 84 tmc5160_sck = tmc5160_header2[3] 85 tmc5160_csn = tmc5160_header2[4] 86 tmc5160_sdo = tmc5160_header2[5] 87 #tmc5160_clk = 88 tmc5160_step = tmc5160_header2[7] 89 tmc5160_dir = tmc5160_header2[8] 90 91 # Define the pins for TMC5160b 92 tmc5160b_gnd2 = tmc5160_header1b[8] 93 tmc5160b_3v3 = tmc5160_header1b[7] 94 tmc5160b_m2b = tmc5160_header1b[6] 95 tmc5160b_m1b = tmc5160_header1b[5] 96 tmc5160b_m1a = tmc5160_header1b[4] 97 tmc5160b_m2a = tmc5160_header1b[3] 98 tmc5160b_gnd1 = tmc5160_header1b[2] 99 tmc5160b_vmot = tmc5160_header1b[1] 100 tmc5160b_en = tmc5160_header2b[1] 101 tmc5160b_sdi = tmc5160_header2b[2] 102 tmc5160b_sck = tmc5160_header2b[3] 103 tmc5160b_csn = tmc5160_header2b[4] 104 tmc5160b_sdo = tmc5160_header2b[5] 105 tmc5160b_step = tmc5160_header2b[7] 106 tmc5160b_dir = tmc5160_header2b[8] 107 108 # Define the pins for TMC5160c 109 tmc5160c_gnd2 = tmc5160_header1c[8] 110 tmc5160c_3v3 = tmc5160_header1c[7] 111 tmc5160c_m2b = tmc5160_header1c[6] 112 tmc5160c_m1b = tmc5160_header1c[5] 113 tmc5160c_m1a = tmc5160_header1c[4] 114 tmc5160c_m2a = tmc5160_header1c[3] 115 tmc5160c_gnd1 = tmc5160_header1c[2] 116 tmc5160c_vmot = tmc5160_header1c[1] 117 tmc5160c_en = tmc5160_header2c[1] 118 tmc5160c_sdi = tmc5160_header2c[2] 119 tmc5160c_sck = tmc5160_header2c[3] 120 tmc5160c_csn = tmc5160_header2c[4] 121 tmc5160c_sdo = tmc5160_header2c[5] 122 tmc5160c_step = tmc5160_header2c[7] 123 tmc5160c_dir = tmc5160_header2c[8] 124 125 # Create VIN and GND nets. 126 vin = Net("VIN") 127 gnd = Net("GND") 128 129 # Create 3.3v gnd net. 130 vcc_gnd = Net("VCC_GND") 131 132 # Connect 36V_V+ and 36V_GND to the terminal block 133 V_plus_36V += terminal_block[1] # Connect 36V_V+ to the first pin of the PT terminal block slot 1 134 GND_36V += terminal_block[2] # Connect 36V_GND to the third pin of the PT terminal block slot 2 135 136 # Connect VIN and GND to ESP32 header 2. 137 vin += terminal_block_2[1] # Connect VIN to the MPT TerminalBlock slot 1 138 gnd += terminal_block_2[2] # Connect GND to the MPT TerminalBlock slot 2 139 140 # Connect capacitor between 36V_V+ and 36V_GND nets 141 capacitor[1, 2] += V_plus_36V, GND_36V 142 143 # Connect one pin of the limit switch header to the resistor and the other pin to ESP32 3.3v (Pull-down Resistor!) 144 # limit_switch_header[1] += resistor1[2], esp32_header1[5] # Connect pin 1 of limit switch header to one pin of the resistor, and pin 5 on esp32 header 1 145 # limit_switch_header[2] += esp32_header2[1] # Connect pin 2 of limit switch header to ESP32 3.3v pin 146 147 # Connect VIN and GND to ESP32 and TMC5160 pins. 148 vin += esp32_vin 149 gnd += esp32_gnd1 150 151 vcc_gnd += esp32_gnd2 152 153 # vcc_gnd += resistor1[1] # GND connected to Resistor pin 1 154 155 # Connect all the CAN Bus headers to the ESP32 Header 2 156 can_bus_header[1] += esp32_3v3 # 3.3v 157 can_bus_header[2] += esp32_gnd2 # GND 158 can_bus_header[3] += esp32_gpio4 # CAN TX 159 can_bus_header[4] += esp32_gpio5 # CAN RX 160 161 # 162 # First TMC5160 Instance 163 # 164 165 # Connect ESP32 header 2 pins 1 and 2 to TMC5160 header 2 pins 7 and 8 respectively 166 esp32_3v3 += tmc5160_3v3 # 3.3v 167 esp32_gnd2 += tmc5160_gnd2 # Second ground 168 169 # Connect 36V_V+ and 36V_GND to TMC5160 header 1 170 V_plus_36V += tmc5160_vmot # Connect 36V_V+ to pin 1 of TMC5160 header 1 171 GND_36V += tmc5160_gnd1 # Connect 36V_GND to pin 2 of TMC5160 header 1 172 vcc_gnd += tmc5160_gnd2 173 174 # Connect the closest ESP32 header 1 and TMC5160 header 2 pins. 175 esp32_gpio13 += tmc5160_dir # (DIRECTION PIN) 176 esp32_gpio12 += tmc5160_step # (STEP PIN) 177 esp32_gpio15 += tmc5160_en # (ENABLE PIN) 178 179 # Additional connections for ESP32 header 2 and TMC5160 header 2 180 esp32_gpio23 += tmc5160_sdi # (SDI) 181 esp32_gpio19 += tmc5160_sdo # (SDO) 182 esp32_gpio18 += tmc5160_sck # (SCK) 183 esp32_gpio14 += tmc5160_csn # (CHIP SELECT) 184 185 # Connect stepper motor header pins to TMC5160 header 1 186 stepper_motor_header[1] += tmc5160_m2a # Motor 2A 187 stepper_motor_header[2] += tmc5160_m1a # Motor 1A 188 stepper_motor_header[3] += tmc5160_m1b # Motor 1B 189 stepper_motor_header[4] += tmc5160_m2b # Motor 2B 190 191 # 192 # Second TMC5160 Instance 193 # 194 195 # Connect ESP32 header 2 pins 1 and 2 to TMC5160 header 2 pins 7 and 8 respectively 196 esp32_3v3 += tmc5160b_3v3 # Connect pin 1 of ESP32 header 2 to pin 7 of TMC5160 header 2 197 esp32_gnd2 += tmc5160b_gnd2 # Connect pin 2 of ESP32 header 2 to pin 8 of TMC5160 header 2 198 199 # Connect 36V_V+ and 36V_GND to TMC5160 header 1 200 V_plus_36V += tmc5160b_vmot # Connect 36V_V+ to pin 1 of TMC5160 header 1 201 GND_36V += tmc5160b_gnd1 # Connect 36V_GND to pin 2 of TMC5160 header 1 202 vcc_gnd += tmc5160b_gnd2 203 204 # Connect the closest ESP32 header 1 and TMC5160 header 2 pins. 205 esp32_gpio27 += tmc5160b_dir # (DIRECTION PIN) 206 esp32_gpio26 += tmc5160b_step # (STEP PIN) 207 esp32_gpio17 += tmc5160b_en # (ENABLE PIN) 208 209 # Additional connections for ESP32 header 2 and TMC5160 header 2 210 esp32_gpio23 += tmc5160b_sdi # Connect pin 15 of ESP32 header 2 to pin 2 of TMC5160 header 2 211 esp32_gpio19 += tmc5160b_sdo # Connect pin 10 of ESP32 header 2 to pin 5 of TMC5160 header 2 212 esp32_gpio18 += tmc5160b_sck # Connect pin 9 of ESP32 header 2 to pin 3 of TMC5160 header 2 213 esp32_gpio25 += tmc5160b_csn # Connect pin 8 of ESP32 header 2 to pin 4 of TMC5160 header 2 214 215 # Connect stepper motor header pins to TMC5160 header 1 216 stepper_motor_header_b[1] += tmc5160b_m2a # Connect pin 1 of stepper motor header to pin 3 of TMC5160 header 1 217 stepper_motor_header_b[2] += tmc5160b_m1a # Connect pin 2 of stepper motor header to pin 4 of TMC5160 header 1 218 stepper_motor_header_b[3] += tmc5160b_m1b # Connect pin 3 of stepper motor header to pin 5 of TMC5160 header 1 219 stepper_motor_header_b[4] += tmc5160b_m2b # Connect pin 4 of stepper motor header to pin 6 of TMC5160 header 1 220 221 # 222 # Third TMC5160 Instance 223 # 224 225 # Connect ESP32 header 2 pins 1 and 2 to TMC5160 header 2 pins 7 and 8 respectively 226 esp32_3v3 += tmc5160c_3v3 # Connect pin 1 of ESP32 header 2 to pin 7 of TMC5160 header 2 227 esp32_gnd2 += tmc5160c_gnd2 # Connect pin 2 of ESP32 header 2 to pin 8 of TMC5160 header 2 228 229 # Connect 36V_V+ and 36V_GND to TMC5160 header 1 230 V_plus_36V += tmc5160c_vmot # Connect 36V_V+ to pin 1 of TMC5160 header 1 231 GND_36V += tmc5160c_gnd1 # Connect 36V_GND to pin 2 of TMC5160 header 1 232 vcc_gnd += tmc5160c_gnd2 233 234 # Connect the closest ESP32 header 1 and TMC5160 header 2 pins. 235 esp32_gpio32 += tmc5160c_dir # Connect ESP32 header 1 pin 10 to TMC5160 header 2 pin 8 (DIRECTION PIN) 236 esp32_gpio2 += tmc5160c_step # Connect ESP32 header 1 pin 9 to TMC5160 header 2 pin 7 (STEP PIN) 237 esp32_gpio22 += tmc5160c_en # Connext ESP32 header 1 pin 3 to TMC5160 header 2 pin 1 (ENABLE PIN) 238 239 # Additional connections for ESP32 header 2 and TMC5160 header 2 240 esp32_gpio23 += tmc5160c_sdi # Connect pin 15 of ESP32 header 2 to pin 2 of TMC5160 header 2 241 esp32_gpio19 += tmc5160c_sdo # Connect pin 10 of ESP32 header 2 to pin 5 of TMC5160 header 2 242 esp32_gpio18 += tmc5160c_sck # Connect pin 9 of ESP32 header 2 to pin 3 of TMC5160 header 2 243 esp32_gpio33 += tmc5160c_csn # Connect pin 8 of ESP32 header 2 to pin 4 of TMC5160 header 2 244 245 # Connect stepper motor header pins to TMC5160 header 1 246 stepper_motor_header_c[1] += tmc5160c_m2a # Connect pin 1 of stepper motor header to pin 3 of TMC5160 header 1 247 stepper_motor_header_c[2] += tmc5160c_m1a # Connect pin 2 of stepper motor header to pin 4 of TMC5160 header 1 248 stepper_motor_header_c[3] += tmc5160c_m1b # Connect pin 3 of stepper motor header to pin 5 of TMC5160 header 1 249 stepper_motor_header_c[4] += tmc5160c_m2b # Connect pin 4 of stepper motor header to pin 6 of TMC5160 header 1 250 251 generate_netlist() 252