Skip to content

Commit 5de9bbb

Browse files
committed
adding docs for new electronics
1 parent fe93e46 commit 5de9bbb

File tree

7 files changed

+162
-0
lines changed

7 files changed

+162
-0
lines changed

docs/03_Electronics/11-StepperMotorBackpack.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,3 +229,50 @@ void loop() {
229229
2. **Encoder Setup (AS5600)**: Uses I2C to read the encoder’s current position. The encoder provides feedback with a 12-bit resolution (4096 steps per revolution).
230230
3. **MoveStepper Function**: Moves the motor in a given direction (based on step count). The direction and steps are controlled using the DIR and STEP pins.
231231
4. **Feedback Loop**: The motor moves based on encoder feedback. If the encoder position is less than 180° (half of 4096 steps), the motor moves forward; otherwise, it moves backward to maintain a 360° operation.
232+
233+
234+
## Revision: CAN BUS
235+
236+
The updated version has several improvements:
237+
238+
- CAN BUS with a dedicated transreceiver
239+
- power safety features
240+
241+
242+
### The updated Pinout:
243+
244+
245+
```cpp
246+
// Pin definitions for Xiao ESP32S3
247+
#define PIN_PA02_A0_D0 0 // Analog/Digital Pin A0/D0
248+
#define PIN_PA04_A1_D1 1 // Analog/Digital Pin A1/D1
249+
#define PIN_PA06_A2_D2 2 // Analog/Digital Pin A2/D2
250+
#define PIN_PA15_A3_D3 3 // Analog/Digital Pin A3/D3
251+
#define PIN_PA13_A4_D4_SDA 4 // I2C SDA / Analog Pin A4/D4
252+
#define PIN_PA15_A5_D5_SCL 5 // I2C SCL / Analog Pin A5/D5
253+
#define PIN_PA6_D6_TX 6 // UART TX Pin
254+
#define PIN_PB09_D7_RX 7 // UART RX Pin
255+
256+
// Motor Control Pins
257+
#define PIN_MOT_EN 8 // Motor Enable
258+
#define PIN_MOT_STEP 9 // Motor Step
259+
#define PIN_MOT_DIR 10 // Motor Direction
260+
#define PIN_UART_PICO 11 // UART PICO
261+
262+
// CAN Bus Pins
263+
#define PIN_CAN_RECV 16 // CAN Receive
264+
#define PIN_CAN_SEND 17 // CAN Send
265+
266+
// I2C Bus (Alternate definition for clarity)
267+
#define I2C_SDA_PIN PIN_PA13_A4_D4_SDA
268+
#define I2C_SCL_PIN PIN_PA15_A5_D5_SCL
269+
270+
// Additional Pins
271+
#define PIN_ENDSTOP 12 // Endstop for motor
272+
#define PIN_MOT_DIAG 13 // Motor diagnostics
273+
```
274+
275+
276+
## Attention:
277+
278+
![](./IMAGES/ESP32S3CanOverview.jpeg)
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# HAT+
2+
3+
This is a HAT for the Raspberry Pi 5 that adapts the Raspberry pi to an esp32 that in turn talks to auxilary components like motors and illumination modules via CAN Bus and I2C (optionally).
4+
5+
6+
## Pinout
7+
8+
This is the hat's pinout on:
9+
10+
```json
11+
raspi_pinheader = {
12+
1: {"Pin": 1, "Function": "+3.3V"},
13+
2: {"Pin": 2, "Function": "+5V"},
14+
3: {"Pin": 3, "Function": "I2C_1_SDA (GPIO2)"},
15+
4: {"Pin": 4, "Function": "+5V"},
16+
5: {"Pin": 5, "Function": "I2C_1_SCL (GPIO3)"},
17+
6: {"Pin": 6, "Function": "GND"},
18+
7: {"Pin": 7, "Function": "GPIO4"},
19+
8: {"Pin": 8, "Function": "RPI_UART_TX (GPIO14)"},
20+
9: {"Pin": 9, "Function": "GND"},
21+
10: {"Pin": 10, "Function": "RPI_UART_RX (GPIO15)"},
22+
11: {"Pin": 11, "Function": "GPIO17"},
23+
12: {"Pin": 12, "Function": "GPIO18"},
24+
13: {"Pin": 13, "Function": "GPIO27"},
25+
14: {"Pin": 14, "Function": "GND"},
26+
15: {"Pin": 15, "Function": "GPIO22"},
27+
16: {"Pin": 16, "Function": "GPIO23"},
28+
17: {"Pin": 17, "Function": "+3.3V"},
29+
18: {"Pin": 18, "Function": "GPIO24"},
30+
19: {"Pin": 19, "Function": "CAN-ctrl_PICO (GPIO10)"},
31+
20: {"Pin": 20, "Function": "GND"},
32+
21: {"Pin": 21, "Function": "CAN-ctrl_POCI (GPIO9)"},
33+
22: {"Pin": 22, "Function": "GPIO25"},
34+
23: {"Pin": 23, "Function": "CAN-ctrl_SCK (GPIO11)"},
35+
24: {"Pin": 24, "Function": "CAN-ctrl_CS (GPIO8)"},
36+
25: {"Pin": 25, "Function": "GND"},
37+
26: {"Pin": 26, "Function": "EEPROM_SCL (GPIO0)"},
38+
27: {"Pin": 27, "Function": "EEPROM_SDA (GPIO1)"},
39+
28: {"Pin": 28, "Function": "Reserved"},
40+
29: {"Pin": 29, "Function": "GPIO5"},
41+
30: {"Pin": 30, "Function": "GND"},
42+
31: {"Pin": 31, "Function": "GPIO6"},
43+
32: {"Pin": 32, "Function": "GPIO12"},
44+
33: {"Pin": 33, "Function": "GPIO13"},
45+
34: {"Pin": 34, "Function": "GND"},
46+
35: {"Pin": 35, "Function": "GPIO19"},
47+
36: {"Pin": 36, "Function": "GPIO16"},
48+
37: {"Pin": 37, "Function": "GPIO26"},
49+
38: {"Pin": 38, "Function": "GPIO20"},
50+
39: {"Pin": 39, "Function": "GND"},
51+
40: {"Pin": 40, "Function": "GPIO21"},
52+
}
53+
```
54+
55+
![](./IMAGES/HAT+Pinout.jpeg)
56+
57+
58+
59+
## ESP32 CAN INterface
60+
61+
The HAT+ hosts an ESP32 that converts UART/Serial into CAN Control commands for the external components. The pinout is the following:
62+
63+
```cpp
64+
65+
// GPIO Pin Definitions for ESP32-S3 Xiao
66+
#define GPIO_TXD0 0 // UART TX
67+
#define GPIO_RXD0 1 // UART RX
68+
#define GPIO_SENSOR_VP 2 // Sensor VP
69+
#define GPIO_SENSOR_VN 3 // Sensor VN
70+
#define GPIO_STRAP_PIN_4 4 // Strapping pin 4
71+
#define GPIO_STRAP_PIN_5 5 // Strapping pin 5
72+
#define GPIO_IO6 6
73+
#define GPIO_IO7 7
74+
#define GPIO_IO8 8 // NeoPixel or LEDC PWM Output
75+
#define GPIO_IO9 9
76+
#define GPIO_IO10 10
77+
#define GPIO_IO11 11
78+
#define GPIO_IO12 12 // Strapping pin / JTAG
79+
#define GPIO_IO13 13 // Strapping pin / JTAG
80+
#define GPIO_IO14 14 // Strapping pin / JTAG
81+
#define GPIO_IO15 15 // Strapping pin / JTAG
82+
#define GPIO_IO16 16 // ESP_CAN_SEND
83+
#define GPIO_IO17 17 // ESP_CAN_RECV
84+
#define GPIO_I2C_SDA 18 // I2C SDA
85+
#define GPIO_I2C_SCL 19 // I2C SCL
86+
#define GPIO_DAC 20 // DAC Pin
87+
#define GPIO_IO21 21
88+
#define GPIO_IO22 22
89+
#define GPIO_IO23 23
90+
#define GPIO_IO24 24
91+
#define GPIO_IO25 25
92+
#define GPIO_IO26 26
93+
#define GPIO_IO27 27
94+
#define GPIO_IO28 28
95+
96+
// Additional Connections
97+
#define GPIO_CAM_TRIGGER_IN_0 29 // Camera Trigger Input Line 0
98+
#define GPIO_CAM_TRIGGER_OUT_1 30 // Camera Trigger Output Line 1
99+
#define GPIO_CAM_IO_LINE_2 31 // Camera I/O Line 2
100+
101+
// Default I2C Pins
102+
#define I2C_SDA_PIN GPIO_I2C_SDA
103+
#define I2C_SCL_PIN GPIO_I2C_SCL
104+
105+
// CAN Bus Pins
106+
#define CAN_SEND_PIN GPIO_IO16
107+
#define CAN_RECV_PIN GPIO_IO17
108+
```
109+
110+
![](./IMAGES/ESP32Pinout.jpeg)
111+
112+
113+
## HAT+ on Jetson
114+
115+
![](./IMAGES/HAT+Jetson.jpeg)
293 KB
Loading
323 KB
Loading
190 KB
Loading
188 KB
Loading
255 KB
Loading

0 commit comments

Comments
 (0)