Skip to content

Commit

Permalink
Working PIO builds for both view and nanofoc envs!
Browse files Browse the repository at this point in the history
  • Loading branch information
scottbez1 committed May 28, 2023
1 parent 120d1bc commit 5b8b795
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 77 deletions.
8 changes: 4 additions & 4 deletions firmware/src/motor_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
#include "motor_task.h"
#if SENSOR_MT6701
#include "mt6701_sensor.h"
#endif
#if SENSOR_TLV
#elif SENSOR_TLV
#include "tlv_sensor.h"
#endif
#if SENSOR_MAQ430
#elif SENSOR_MAQ430
#include "maq430_sensor.h"
#endif

#include "motors/motor_config.h"
#include "util.h"

// ####
Expand Down
12 changes: 12 additions & 0 deletions firmware/src/motors/mad2804.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

// Tuning parameters for the MAD2804 motor (orange stator).

#define FOC_PID_P 1
#define FOC_PID_I 0
#define FOC_PID_D 0.148
#define FOC_PID_OUTPUT_RAMP 5000
#define FOC_PID_LIMIT 3

#define FOC_VOLTAGE_LIMIT 3
#define FOC_LPF 0.0075
9 changes: 9 additions & 0 deletions firmware/src/motors/motor_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#if MOTOR_WANZHIDA_ONCE_TOP
#include "motors/wanzhida_once_top.h"
#elif MOTOR_MAD2804
#include "motors/mad2804.h"
#else
#error "No motor configuration specified!"
#endif
12 changes: 12 additions & 0 deletions firmware/src/motors/wanzhida_once_top.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

// Tuning parameters for the Wanzhida/Oncetop OT-EM3215D2450Y1R,
// sold by SparkFun (ROB-20441).

#define FOC_PID_P 4
#define FOC_PID_I 0
#define FOC_PID_D 0.04
#define FOC_PID_OUTPUT_RAMP 10000
#define FOC_PID_LIMIT 10

#define FOC_VOLTAGE_LIMIT 5
181 changes: 108 additions & 73 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ test_dir = firmware/test
data_dir = firmware/data

[base_config]
platform = espressif32
board = adafruit_feather_esp32s3
; board_build.arduino.memory_type = qio_opi ; NEEDED FOR PSRAM also dio_qspi/qsi_qspi for other configs
platform = espressif32@3.4
framework = arduino
monitor_speed = 921600
monitor_flags =
Expand All @@ -28,88 +26,65 @@ monitor_flags =
--filter=esp32_exception_decoder
upload_speed = 921600
lib_deps =
askuric/Simple FOC@^2.3.0
; infineon/TLV493D-Magnetic-Sensor @ 1.0.3
infineon/TLV493D-Magnetic-Sensor @ 1.0.3
bxparks/AceButton @ 1.9.1
bakercp/PacketSerial @ 1.4.0
nanopb/Nanopb @ 0.4.6 ; Ideally this would reference the nanopb submodule, but that would require
; everyone to check out submodules to just compile, so we use the library
; registry for the runtime. The submodule is available for manually updating
; the pre-compiled (checked in) .pb.h/c files when proto files change, but is
; otherwise not used during application firmware compilation.
build_flags =
-DPIO_FRAMEWORK_ARDUINO_ENABLE_CDC=1
-DUSBCON=1
-DARDUINO_USB_CDC_ON_BOOT=1
-DARDUINO_USB_MODE=1
-DCORE_DEBUG_LEVEL=2
; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
-DMONITOR_SPEED=921600
; -DBOARD_HAS_PSRAM

-DHSPI_SPEED=100000 ; MA/MAQ Nominal SPI Speed in Mhz (HSPI)
-DVSPI_SPEED=400000 ; TFt Nominal SPI Speed in Mhz (VSPI)

[env:view]
extends = base_config
board = adafruit_feather_esp32s3
board = esp32doit-devkit-v1
lib_deps =
${base_config.lib_deps}
bodmer/TFT_eSPI@2.5.0
; fastled/FastLED @ 3.5.0
; bogde/HX711 @ 0.7.5
; adafruit/Adafruit VEML7700 Library @ 1.1.1
bakercp/PacketSerial @ 1.4.0
nanopb/Nanopb @ 0.4.6 ; Ideally this would reference the nanopb submodule, but that would require
; everyone to check out submodules to just compile, so we use the library
; registry for the runtime. The submodule is available for manually updating
; the pre-compiled (checked in) .pb.h/c files when proto files change, but is
; otherwise not used during application firmware compilation.
askuric/Simple FOC @ 2.2.0
bodmer/TFT_eSPI@2.4.25
fastled/FastLED @ 3.5.0
bogde/HX711 @ 0.7.5
adafruit/Adafruit VEML7700 Library @ 1.1.1

build_flags =
${base_config.build_flags}
; Display enabled: 1=enable, 0=disable
-DSK_DISPLAY=0
-DSK_DISPLAY=1
; Display orientation: 0=usb bottom, 2=usb top
-DSK_DISPLAY_ROTATION=0
; LEDs enabled: 1=enable, 0=disable
-DSK_LEDS=0
-DSK_LEDS=1
; Number of LEDs
-DNUM_LEDS=8
-DSENSOR_MT6701=0
; Strain-gauge press input enabled: 1=enable, 0=disable
-DSK_STRAIN=0
-DSK_STRAIN=1
; Ambient light sensor (VEML7700) enabled: 1=enable (display/LEDs match ambient brightness), 0=disable (100% brightness all the time)
-DSK_ALS=1
; Use MT6701 magnetic encoder
-DSENSOR_MT6701=1
; Invert direction of angle sensor (motor direction is detected relative to angle sensor as part of the calibration procedure)
-DSK_INVERT_ROTATION=1
; Ambient light sensor (VEML7700) enabled: 1=enable (display/LEDs match ambient brightness), 0=disable (100% brightness all the time)
-DSK_ALS=0

-DSENSOR_MAQ430=1
-DPIN_MAQ_SCK=6
-DPIN_MAQ_MISO=7
-DPIN_MAQ_MOSI=5
-DPIN_MAQ_SS=4

-DFOC_PID_P=1
-DFOC_PID_I=0
-DFOC_PID_D=0.48
-DFOC_PID_OUTPUT_RAMP=5000
-DFOC_PID_LIMIT=3
-DFOC_LPF=0.0075

-DFOC_VOLTAGE_LIMIT=3
-DMOTOR_WANZHIDA_ONCE_TOP=1

; Pin configurations
-DPIN_UH=21
-DPIN_UL=12
-DPIN_VH=14
-DPIN_VL=10
-DPIN_WH=13
-DPIN_WL=11
-DPIN_UH=26
-DPIN_UL=25
-DPIN_VH=27
-DPIN_VL=32
-DPIN_WH=12
-DPIN_WL=33
-DPIN_BUTTON_NEXT=-1
-DPIN_BUTTON_PREV=-1
-DPIN_SDA=15
-DPIN_SCL=8
; -DPIN_MT_DATA=37
; -DPIN_MT_CLOCK=13
; -DPIN_MT_CSN=14
-DPIN_MT_DATA=37
-DPIN_MT_CLOCK=13
-DPIN_MT_CSN=14
-DPIN_LED_DATA=7
-DPIN_LCD_BACKLIGHT=08
-DSK_INVERT_ROTATION=1
-DPIN_LCD_BACKLIGHT=19

-DDESCRIPTION_FONT=Roboto_Thin_24
-DDESCRIPTION_Y_OFFSET=20
Expand All @@ -123,11 +98,11 @@ build_flags =
-DTFT_WIDTH=240
-DTFT_HEIGHT=240
-DTFT_MISO=-1
-DTFT_MOSI=48
-DTFT_SCLK=09
-DTFT_CS=47
-DTFT_DC=17
-DTFT_RST=18
-DTFT_MOSI=5
-DTFT_SCLK=20
-DTFT_CS=21
-DTFT_DC=22
-DTFT_RST=4
-DTFT_BL=-1
-DLOAD_GLCD=1
-DLOAD_GFXFF=1
Expand All @@ -136,14 +111,74 @@ build_flags =
; Reduce loop task stack size (only works on newer IDF Arduino core)
; -DARDUINO_LOOP_STACK_SIZE=2048

; ; FastLED setup
; ; Modify the default unusable pin mask to allow GPIO 7 (allowed to use on ESP32-PICO-V3-02)
; ; Unusable bits: 6, 8, 9, 10, 20
; ; (0ULL | _FL_BIT(6) | _FL_BIT(8) | _FL_BIT(9) | _FL_BIT(10) | _FL_BIT(20))
; -DFASTLED_UNUSABLE_PIN_MASK=0x100740LL
; ; 0~39 except from 24, 28~31 are valid
; ; (0xFFFFFFFFFFULL & ~(0ULL | _FL_BIT(24) | _FL_BIT(28) | _FL_BIT(29) | _FL_BIT(30) | _FL_BIT(31)))
; -DSOC_GPIO_VALID_GPIO_MASK=0xFF0EFFFFFF
; ; GPIO >= 34 are input only
; ; (SOC_GPIO_VALID_GPIO_MASK & ~(0ULL | _FL_BIT(34) | _FL_BIT(35) | _FL_BIT(36) | _FL_BIT(37) | _FL_BIT(38) | _FL_BIT(39)))
; -DSOC_GPIO_VALID_OUTPUT_GPIO_MASK=0x30EFFFFFF
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG

; FastLED setup
; Modify the default unusable pin mask to allow GPIO 7 (allowed to use on ESP32-PICO-V3-02)
; Unusable bits: 6, 8, 9, 10, 20
; (0ULL | _FL_BIT(6) | _FL_BIT(8) | _FL_BIT(9) | _FL_BIT(10) | _FL_BIT(20))
-DFASTLED_UNUSABLE_PIN_MASK=0x100740LL
; 0~39 except from 24, 28~31 are valid
; (0xFFFFFFFFFFULL & ~(0ULL | _FL_BIT(24) | _FL_BIT(28) | _FL_BIT(29) | _FL_BIT(30) | _FL_BIT(31)))
-DSOC_GPIO_VALID_GPIO_MASK=0xFF0EFFFFFF
; GPIO >= 34 are input only
; (SOC_GPIO_VALID_GPIO_MASK & ~(0ULL | _FL_BIT(34) | _FL_BIT(35) | _FL_BIT(36) | _FL_BIT(37) | _FL_BIT(38) | _FL_BIT(39)))
-DSOC_GPIO_VALID_OUTPUT_GPIO_MASK=0x30EFFFFFF


[env:nanofoc]
extends = base_config
platform = espressif32
board = adafruit_feather_esp32s3
lib_deps =
${base_config.lib_deps}
askuric/Simple FOC@^2.3.0
bodmer/TFT_eSPI@2.5.0

build_flags =
${base_config.build_flags}
; Display enabled: 1=enable, 0=disable
-DSK_DISPLAY=0
; Display orientation: 0=usb bottom, 2=usb top
-DSK_DISPLAY_ROTATION=0
; LEDs enabled: 1=enable, 0=disable
-DSK_LEDS=0
; Number of LEDs
-DNUM_LEDS=8
; Strain-gauge press input enabled: 1=enable, 0=disable
-DSK_STRAIN=0
; Ambient light sensor (VEML7700) enabled: 1=enable (display/LEDs match ambient brightness), 0=disable (100% brightness all the time)
-DSK_ALS=0

-DSENSOR_MAQ430=1
-DPIN_MAQ_SCK=6
-DPIN_MAQ_MISO=7
-DPIN_MAQ_MOSI=5
-DPIN_MAQ_SS=4
; Invert direction of angle sensor (motor direction is detected relative to angle sensor as part of the calibration procedure)
-DSK_INVERT_ROTATION=1

-DMOTOR_MAD2804=1

; Pin configurations
-DPIN_UH=21
-DPIN_UL=12
-DPIN_VH=14
-DPIN_VL=10
-DPIN_WH=13
-DPIN_WL=11
-DPIN_BUTTON_NEXT=-1
-DPIN_BUTTON_PREV=-1
-DPIN_LED_DATA=7
-DPIN_LCD_BACKLIGHT=08

-DPIO_FRAMEWORK_ARDUINO_ENABLE_CDC=1
-DUSBCON=1
-DARDUINO_USB_CDC_ON_BOOT=1
-DARDUINO_USB_MODE=1
-DCORE_DEBUG_LEVEL=2
-DHSPI_SPEED=100000 ; MA/MAQ Nominal SPI Speed in Mhz (HSPI)
-DVSPI_SPEED=400000 ; TFt Nominal SPI Speed in Mhz (VSPI)

; Reduce loop task stack size (only works on newer IDF Arduino core)
; -DARDUINO_LOOP_STACK_SIZE=2048

0 comments on commit 5b8b795

Please sign in to comment.