diff --git a/firmware/include/lemon-pepper.h b/firmware/include/lemon-pepper.h index f3b020b..09a0a2d 100644 --- a/firmware/include/lemon-pepper.h +++ b/firmware/include/lemon-pepper.h @@ -1,55 +1,72 @@ #pragma once -// MOTOR DRIVER L6226Q -#define U_PWM PA10 -#define V_PWM PA9 -#define W_PWM PA1 +#ifdef LEMONPEPPER -#define MOT_A1 PA0 -#define MOT_A2 PA10 -#define MOT_B1 PA9 -#define MOT_B2 PA1 +// MOTOR DRIVER L6226 +#define U_PWM PA10 // TIM2_CH4 +#define V_PWM PA9 // TIM2_CH3 +#define W_PWM PA1 // TIM2_CH2 + +#define MOT_A1 PA0 // TIM2_CH1 +#define MOT_A2 PA10 // TIM2_CH4 +#define MOT_B1 PA9 // TIM2_CH3 +#define MOT_B2 PA1 // TIM2_CH2 #define MOT_EN PB12 // ENCODER MT6835 -#define ENC_A PB4 -#define ENC_B PB5 -#define ENC_Z PB3 +#define ENC_A PB4 // TIM3_CH1 +#define ENC_B PB5 // TIM3_CH2 +#define ENC_Z PB3 // TIM3_ETR -#define ENC_COPI PA7 -#define ENC_CIPO PA6 -#define ENC_SCK PA5 -#define ENC_CS PC4 +#define ENC_COPI PA7 // SPI1_MOSI +#define ENC_CIPO PA6 // SPI1_MISO +#define ENC_SCK PA5 // SPI1_SCK +#define ENC_CS PC4 + +#define CAL_EN PA4 // CURRENT SENSE -#define ISENSE_U PA3 -#define ISENSE_V PB13 -#define ISENSE_W PB0 +#define ISENSE_U PA3 // VOPAMP1_P, ADC1_IN4 +#define ISENSE_V PB13 // VOPAMP3_P // COMMUNICATION +/** + * Note that you can only use one input peripheral + * at a time. If you want to use CANbus you also have + * to remove the resistors that join step-dir to CAN H/L + * R104 R105 to protect MCU from high common mode voltages. +*/ #define CAN_TX PB8 #define CAN_RX PB9 -// PCB REV CHANGES -#ifdef PCB_REV1 -#define STEP_PIN PB14 -#define DIR_PIN PB15 +#define UART3_TX PC10 +#define UART3_RX PC11 -#define CAL_EN PB1 -#endif +#define I2C3_SDA PC11 +#define I2C3_SCL PA8 -#ifdef PCB_REV2 -#define STEP_PIN PC11 -#define DIR_PIN PA8 +#define STEP_PIN PC10 +#define DIR_PIN PC11 -#define I2C_SDA PC11 -#define I2C_SCL PA8 +// USER CONNECTOR +/** + * Additional timer available for encoder interface. + * If not using, there are 5 GPIO available. +*/ +#define USER_ENCA PB6 // TIM4_CH1 +#define USER_ENCB PB7 // TIM4_CH2 -#define CAL_EN PA4 -#endif +#define USER1 PC6 +#define USER2 PB15 +#define USER3 PB14 +#define USER4 PB7 +#define USER5 PB6 -// AUX +// MISC +#define USER_BUTTON PC15 #define LED_GOOD PB10 #define LED_FAULT PB11 +#define MOT_VOLTAGE PA2 //ADC1_IN3 +#endif \ No newline at end of file diff --git a/firmware/include/old.h b/firmware/include/old.h new file mode 100644 index 0000000..f3b020b --- /dev/null +++ b/firmware/include/old.h @@ -0,0 +1,55 @@ +#pragma once + +// MOTOR DRIVER L6226Q +#define U_PWM PA10 +#define V_PWM PA9 +#define W_PWM PA1 + +#define MOT_A1 PA0 +#define MOT_A2 PA10 +#define MOT_B1 PA9 +#define MOT_B2 PA1 + +#define MOT_EN PB12 + +// ENCODER MT6835 +#define ENC_A PB4 +#define ENC_B PB5 +#define ENC_Z PB3 + +#define ENC_COPI PA7 +#define ENC_CIPO PA6 +#define ENC_SCK PA5 +#define ENC_CS PC4 + +// CURRENT SENSE +#define ISENSE_U PA3 +#define ISENSE_V PB13 +#define ISENSE_W PB0 + +// COMMUNICATION +#define CAN_TX PB8 +#define CAN_RX PB9 + +// PCB REV CHANGES +#ifdef PCB_REV1 +#define STEP_PIN PB14 +#define DIR_PIN PB15 + +#define CAL_EN PB1 +#endif + +#ifdef PCB_REV2 +#define STEP_PIN PC11 +#define DIR_PIN PA8 + +#define I2C_SDA PC11 +#define I2C_SCL PA8 + +#define CAL_EN PA4 +#endif + +// AUX +#define LED_GOOD PB10 +#define LED_FAULT PB11 + diff --git a/hardware/currentsense.kicad_sch b/hardware/currentsense.kicad_sch index 45d52a6..2b0e501 100644 --- a/hardware/currentsense.kicad_sch +++ b/hardware/currentsense.kicad_sch @@ -524,8 +524,6 @@ (uuid fcd534ea-b41d-4528-bc1a-4e524034ea88) ) - (no_connect (at 153.67 151.13) (uuid f5d8335a-9511-4bb6-951a-024181b821df)) - (wire (pts (xy 153.67 59.69) (xy 153.67 54.61)) (stroke (width 0) (type default)) (uuid 0cfebd83-704c-4e49-94be-7db78aaf7d4d) @@ -614,10 +612,6 @@ (stroke (width 0) (type default)) (uuid 4b8796b5-db3e-4e27-82c5-8928e7d356cf) ) - (wire (pts (xy 153.67 151.13) (xy 156.21 151.13)) - (stroke (width 0) (type default)) - (uuid 4eb6aaf3-6755-4374-ab4c-4820d3914d52) - ) (wire (pts (xy 143.51 111.76) (xy 153.67 111.76)) (stroke (width 0) (type default)) (uuid 582cc157-75bd-45cc-9b76-65a9fcd8282d) @@ -814,10 +808,6 @@ (uuid a211305c-cec6-43fb-9543-c19ca6abe168) ) - (hierarchical_label "W_SENSE" (shape input) (at 156.21 151.13 0) (fields_autoplaced) - (effects (font (size 1.27 1.27)) (justify left)) - (uuid 04131efd-46a9-4abd-9a5a-0ec18b54986e) - ) (hierarchical_label "U_OUT" (shape input) (at 88.9 62.23 180) (fields_autoplaced) (effects (font (size 1.27 1.27)) (justify right)) (uuid 1eb11783-23c0-4ea4-8639-255008e743e8) diff --git a/hardware/lemon-pepper.kicad_sch b/hardware/lemon-pepper.kicad_sch index c55c691..ad243ec 100644 --- a/hardware/lemon-pepper.kicad_sch +++ b/hardware/lemon-pepper.kicad_sch @@ -752,10 +752,6 @@ (stroke (width 0) (type default)) (uuid 110b3c7d-fe36-4a17-b9fa-6c6dd0f87db5) ) - (wire (pts (xy 217.17 114.3) (xy 217.17 101.6)) - (stroke (width 0) (type default)) - (uuid 146f4f76-8f6e-4abc-b6eb-5352e8e2c920) - ) (wire (pts (xy 62.23 41.91) (xy 92.71 41.91)) (stroke (width 0) (type default)) (uuid 18d1f09b-dd3b-4d53-96cf-03c5011a5bfe) @@ -963,10 +959,6 @@ (stroke (width 0) (type default)) (uuid 711a895f-5cdb-47d6-8e92-8b137ee53aa1) ) - (wire (pts (xy 135.89 101.6) (xy 217.17 101.6)) - (stroke (width 0) (type default)) - (uuid 744d308b-52bd-4ecc-8de8-28a0813e840a) - ) (wire (pts (xy 135.89 144.78) (xy 158.75 144.78)) (stroke (width 0) (type default)) (uuid 76aee612-335b-4ac0-9efc-7641331a3e6a) @@ -1020,7 +1012,7 @@ (stroke (width 0) (type default)) (uuid 93303732-00dc-4a7d-8441-4341093eaabe) ) - (wire (pts (xy 213.36 114.3) (xy 213.36 105.41)) + (wire (pts (xy 217.17 114.3) (xy 217.17 101.6)) (stroke (width 0) (type default)) (uuid 944c6c52-f3c3-4466-a1de-70dae2cf5e64) ) @@ -1132,7 +1124,7 @@ (stroke (width 0) (type default)) (uuid d5af3af2-4e06-4719-9efe-51cb8e8440d4) ) - (wire (pts (xy 135.89 105.41) (xy 213.36 105.41)) + (wire (pts (xy 135.89 101.6) (xy 217.17 101.6)) (stroke (width 0) (type default)) (uuid df0dcd16-2c44-477b-baec-88cf60c682d5) ) @@ -2149,7 +2141,7 @@ (effects (font (size 1.27 1.27)) (justify right)) (uuid 561a38ea-c042-4a51-aeac-d65f3cfa5542) ) - (pin "V_SENSE" output (at 213.36 114.3 90) + (pin "V_SENSE" output (at 217.17 114.3 90) (effects (font (size 1.27 1.27)) (justify right)) (uuid 311502d2-42b6-4f77-8bfd-872f2d064c6d) ) @@ -2157,10 +2149,6 @@ (effects (font (size 1.27 1.27)) (justify right)) (uuid 782932d6-e090-41b9-9e9e-b7b23097870e) ) - (pin "W_SENSE" output (at 217.17 114.3 90) - (effects (font (size 1.27 1.27)) (justify right)) - (uuid bb415e6c-5a62-4be4-aef9-0c2aca88bf0f) - ) (instances (project "lemon-pepper" (path "/0306e2fa-4433-4288-91d9-65a3484207ad" (page "8")) @@ -2206,10 +2194,6 @@ (effects (font (size 1.27 1.27)) (justify left)) (uuid e69298d2-b4c5-481c-8926-b071845f7ef3) ) - (pin "OPAMP2_VINP" input (at 135.89 101.6 0) - (effects (font (size 1.27 1.27)) (justify right)) - (uuid eaa445df-85cc-4225-b19e-5ae5bf2edaff) - ) (pin "SPI1_SCK" output (at 135.89 144.78 0) (effects (font (size 1.27 1.27)) (justify right)) (uuid 020a2a45-23d6-4b03-a554-204197d4b28f) @@ -2222,7 +2206,7 @@ (effects (font (size 1.27 1.27)) (justify right)) (uuid 1deb0b89-9c38-42f0-9076-12e2f6213433) ) - (pin "OPAMP3_VINP" input (at 135.89 105.41 0) + (pin "OPAMP3_VINP" input (at 135.89 101.6 0) (effects (font (size 1.27 1.27)) (justify right)) (uuid e38080eb-38c4-416c-a2b1-19f2f4020e59) ) diff --git a/hardware/mcu.kicad_sch b/hardware/mcu.kicad_sch index b7823ad..6187be8 100644 --- a/hardware/mcu.kicad_sch +++ b/hardware/mcu.kicad_sch @@ -1390,6 +1390,7 @@ (no_connect (at 109.22 109.22) (uuid 4aaf6370-e30d-4f53-a93f-809003565bc0)) (no_connect (at 109.22 76.2) (uuid 54e7272b-9df3-4bb0-8f21-ec5b918bf196)) (no_connect (at 76.2 101.6) (uuid 560db69f-37be-4fd4-92e3-370ff316d6a8)) + (no_connect (at 76.2 109.22) (uuid 6d83e239-50a3-47e4-91be-4d7326f96e7e)) (no_connect (at 189.23 48.26) (uuid 723bc003-4440-4fde-8075-7cc16a53689e)) (no_connect (at 88.9 66.04) (uuid 978c225f-ee58-48c6-9f3f-273d7f0dff63)) (no_connect (at 76.2 99.06) (uuid be6c71ad-b273-4b5a-a960-d02ff9e3835b)) @@ -1840,10 +1841,6 @@ (stroke (width 0) (type default)) (uuid ed35195f-623a-4503-ba85-1b6cb80bce7f) ) - (wire (pts (xy 66.04 109.22) (xy 76.2 109.22)) - (stroke (width 0) (type default)) - (uuid ede7552c-0797-45a6-b9e2-29cd0c4ede0f) - ) (wire (pts (xy 54.61 78.74) (xy 44.45 78.74)) (stroke (width 0) (type default)) (uuid eeb7d742-8886-40c3-8347-bfdb4bec3569) @@ -2099,10 +2096,6 @@ (effects (font (size 1.27 1.27)) (justify right)) (uuid d358859b-ec8e-4c3a-bf01-3644c8c83381) ) - (hierarchical_label "OPAMP2_VINP" (shape input) (at 66.04 109.22 180) (fields_autoplaced) - (effects (font (size 1.27 1.27)) (justify right)) - (uuid f75268da-ac5b-49c4-973b-54d7afbaa945) - ) (hierarchical_label "DIR" (shape input) (at 120.65 91.44 0) (fields_autoplaced) (effects (font (size 1.27 1.27)) (justify left)) (uuid f7b629f6-08f3-41ef-8c7d-8ac6dab2ecbf) diff --git a/lemon-pepper.pdf b/lemon-pepper.pdf index ef67495..450dcbc 100644 Binary files a/lemon-pepper.pdf and b/lemon-pepper.pdf differ diff --git a/pinout.png b/pinout.png index 69dfc33..3320e77 100644 Binary files a/pinout.png and b/pinout.png differ diff --git a/platformio.ini b/platformio.ini index 2feb463..bb92d16 100644 --- a/platformio.ini +++ b/platformio.ini @@ -38,7 +38,7 @@ build_flags = -D SN65HVD23x -D ARDUINO_GENERIC_G431CBUX -D SIMPLEFOC_STM32_CUSTOMCURRENTSENSE - -D PCB_REV1 ; or PCB_REV2 + ; -D PCB_REV1 ; or PCB_REV2 ; -D HAS_MONITOR ; lib_deps =