Skip to content

Commit

Permalink
Renamed VESC hardware files, enabled USB debug logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
rombrew committed Feb 16, 2024
1 parent 60eb176 commit cb86bb7
Show file tree
Hide file tree
Showing 19 changed files with 113 additions and 24 deletions.
24 changes: 12 additions & 12 deletions doc/HardwareVESC.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ This page gives you an overview of VESC hardware supported by PMC.

## Hardware

| Item | HWREV | Notes |
|:--------------------------------------|:---------:|:------------------|
| FLIPSKY FSESC 6.7 | VESC6A | Bad PCB design |
| Makerbase VESC 60100 V2 | VESC6A | |
| FLIPSKY MINI FSESC 6.7 PRO | VESC6B | Low side shunts |
| VESC 6 MkVI | VESC6C | |
| Holybro Mini FOC ESC Based on VESC6 | VESC6H | |
| FLIPSKY 75100 V202 ESC | VESC75A | Low side shunts |
| Makerbase VESC 75200 V2 84V 200A | VESC75A | Low side shunts |
| VESC 75/300 R3 | VESC75C | |
| Item | HWREV | Notes |
|:--------------------------------------|:-----------:|:------------------|
| FLIPSKY FSESC 6.7 | FSESC67 | Bad PCB design |
| FLIPSKY MINI FSESC 6.7 PRO | FSESC67PRO | Low side shunts |
| FLIPSKY 75100 V202 ESC | FSESC75100 | Low side shunts |
| Makerbase VESC 75200 V2 84V 200A | FSESC75100 | Low side shunts |
| Holybro Mini FOC ESC Based on VESC6 | HBESC6FOC | |
| Makerbase VESC 60100 V2 | MKESC60100 | |
| VESC 6 MkVI | VESC6MK5 | |
| VESC 75/300 R3 | VESC75300 | |

Note that some of VESC clone have bad PCB design that causes distorted current
measurement and total malfunction at high load. Also prefer to use PCB with
Expand All @@ -26,12 +26,12 @@ You can build the firmware binary yourself from sources or get it from the
bundle release.

$ cd phobia/src
$ make HWREV=VESC6A
$ make HWREV=MKESC60100

To load the firmware into the MCU first time you will need SWD probe. Next time
to upgrade the firmware you can use USB DFU or serial bootloader.

$ make HWREV=VESC6A stlink
$ make HWREV=MKESC60100 stlink

Also check [GettingStarted](GettingStarted.md) page howto build and load the
firmware to MCU.
Expand Down
3 changes: 0 additions & 3 deletions phobia/phobia.c
Original file line number Diff line number Diff line change
Expand Up @@ -4562,9 +4562,6 @@ page_lu_eabi(struct public *pub)
static void
page_lu_sincos(struct public *pub)
{
struct nk_sdl *nk = pub->nk;
struct nk_context *ctx = &nk->ctx;

/* TODO */
}

Expand Down
2 changes: 1 addition & 1 deletion src/cherry/usb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#endif

#ifndef CONFIG_USB_DBG_LEVEL
#define CONFIG_USB_DBG_LEVEL -1
#define CONFIG_USB_DBG_LEVEL USB_DBG_ERROR
#endif

#ifndef CONFIG_USB_ALIGN_SIZE
Expand Down
6 changes: 3 additions & 3 deletions src/epcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,8 @@ LD_TASK void task_EPCAN_TX(void *pData)

EPCAN_send_msg(&msg);

/* Do not send messages too frequently especially if
* you were asked to.
/* Do not send messages too frequently
* especially if you were asked to.
* */
if (local.flow_tx_paused != 0) {

Expand Down Expand Up @@ -719,7 +719,7 @@ void EPCAN_startup()
local.tx_queue = xQueueCreate(80, sizeof(char));
local.remote_queue = xQueueCreate(40, sizeof(char));
local.log_queue = xQueueCreate(320, sizeof(char));
local.net_queue = xQueueCreate(1, sizeof(int));
local.net_queue = xQueueCreate(10, sizeof(int));

/* Allocate semaphore.
* */
Expand Down
86 changes: 86 additions & 0 deletions src/hal/hw/FSESC67.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#define HW_MCU_STM32F405

/* Tested on FLIPSKY FSESC 6.7
* */

#define HW_HAVE_DRV_ON_PCB
#define HW_HAVE_ANALOG_KNOB
#define HW_HAVE_BRAKE_KNOB
#define HW_HAVE_STEP_DIR_KNOB
#define HW_HAVE_NTC_ON_PCB
#define HW_HAVE_NTC_MACHINE
#define HW_HAVE_USB_CDC_ACM
#define HW_HAVE_NETWORK_EPCAN

#define HW_CLOCK_CRYSTAL_HZ 8000000U

#define HW_PWM_FREQUENCY_HZ 28571.f
#define HW_PWM_DEADTIME_NS 400.f /* NVMFS5C612NL */

#define HW_PWM_MINIMAL_PULSE 0.4f
#define HW_PWM_CLEARANCE_ZONE 9.0f
#define HW_PWM_SKIP_ZONE 2.0f
#define HW_PWM_BOOTSTRAP_RETENTION 100.f /* DRV8301 */

#define HW_DRV_ID_ON_PCB BUS_ID_SPI3

#define HW_DRV_PARTNO DRV_PART_DRV8301
#define HW_DRV_GATE_CURRENT 2
#define HW_DRV_OCP_LEVEL 32

#define HW_ADC_SAMPLING_SEQUENCE ADC_SEQUENCE__ABC_UTT_TXX

#define HW_ADC_REFERENCE_VOLTAGE 3.3f
#define HW_ADC_SHUNT_RESISTANCE 0.0005f
#define HW_ADC_AMPLIFIER_GAIN 20.f /* AD8418 */

#define HW_ADC_VOLTAGE_R1 39000.f
#define HW_ADC_VOLTAGE_R2 2200.f
#define HW_ADC_VOLTAGE_R3 1000000000000.f /* have no bias */

#define HW_ADC_KNOB_R1 0.f /* have no */
#define HW_ADC_KNOB_R2 1000.f

#define HW_NTC_PCB_TYPE NTC_VCC
#define HW_NTC_PCB_BALANCE 10000.f
#define HW_NTC_PCB_NTC0 10000.f
#define HW_NTC_PCB_TA0 25.f
#define HW_NTC_PCB_BETTA 3380.f /* unknown part */

#define HW_NTC_EXT_BALANCE 10000.f

#define GPIO_ADC_CURRENT_A XGPIO_DEF3('C', 0, 10)
#define GPIO_ADC_CURRENT_B XGPIO_DEF3('C', 1, 11)
#define GPIO_ADC_CURRENT_C XGPIO_DEF3('C', 2, 12)
#define GPIO_ADC_VOLTAGE_U XGPIO_DEF3('C', 3, 13)
#define GPIO_ADC_VOLTAGE_A XGPIO_DEF3('A', 0, 0)
#define GPIO_ADC_VOLTAGE_B XGPIO_DEF3('A', 1, 1)
#define GPIO_ADC_VOLTAGE_C XGPIO_DEF3('A', 2, 2)
#define GPIO_ADC_NTC_PCB XGPIO_DEF3('A', 3, 3)
#define GPIO_ADC_NTC_EXT XGPIO_DEF3('C', 4, 14)
#define GPIO_ADC_KNOB_ANG XGPIO_DEF3('A', 5, 5)
#define GPIO_ADC_KNOB_BRK XGPIO_DEF3('A', 6, 6)

#define GPIO_STEP XGPIO_DEF2('A', 5)
#define GPIO_DIR XGPIO_DEF2('A', 6)

#define GPIO_DRV_GATE_EN XGPIO_DEF2('B', 5)
#define GPIO_DRV_FAULT XGPIO_DEF2('B', 7)

#define GPIO_SPI3_NSS XGPIO_DEF2('C', 9)
#define GPIO_SPI3_SCK XGPIO_DEF4('C', 10, 0, 6)
#define GPIO_SPI3_MISO XGPIO_DEF4('C', 11, 0, 6)
#define GPIO_SPI3_MOSI XGPIO_DEF4('C', 12, 0, 6)

#define GPIO_USART3_TX XGPIO_DEF4('B', 10, 0, 7)
#define GPIO_USART3_RX XGPIO_DEF4('B', 11, 0, 7)

#define GPIO_OTG_FS_DM XGPIO_DEF4('A', 11, 0, 10)
#define GPIO_OTG_FS_DP XGPIO_DEF4('A', 12, 0, 10)

#define GPIO_CAN_RX XGPIO_DEF4('B', 8, 0, 9)
#define GPIO_CAN_TX XGPIO_DEF4('B', 9, 0, 9)

#define GPIO_LED_ALERT XGPIO_DEF2('B', 1)
#define GPIO_LED_MODE XGPIO_DEF2('B', 0)

2 changes: 1 addition & 1 deletion src/hal/hw/VESC6B.h → src/hal/hw/FSESC67PRO.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#define HW_CLOCK_CRYSTAL_HZ 8000000U

#define HW_PWM_FREQUENCY_HZ 28571.f
#define HW_PWM_DEADTIME_NS 330.f /* NVMFS5C612NL */
#define HW_PWM_DEADTIME_NS 400.f /* NVMFS5C612NL */

#define HW_PWM_MINIMAL_PULSE 0.4f
#define HW_PWM_CLEARANCE_ZONE 5.0f
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions src/hal/hw/VESC6A.h → src/hal/hw/MKESC60100.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#define HW_MCU_STM32F405

/* Tested on FLIPSKY FSESC 6.7
* Tested on Makerbase VESC 60100 V2
/* Tested on Makerbase VESC 60100 V2
* */

#define HW_HAVE_DRV_ON_PCB
Expand Down
2 changes: 1 addition & 1 deletion src/hal/hw/VESC6C.h → src/hal/hw/VESC6MK5.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#define HW_CLOCK_CRYSTAL_HZ 8000000U

#define HW_PWM_FREQUENCY_HZ 28571.f
#define HW_PWM_DEADTIME_NS 330.f /* IRF7749 */
#define HW_PWM_DEADTIME_NS 400.f /* IRF7749 */

#define HW_PWM_MINIMAL_PULSE 0.4f
#define HW_PWM_CLEARANCE_ZONE 5.0f
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions src/hal/mk/VESC6MK5.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
HWMCU = STM32F405
OBJ_HAL_DRV = 1
OBJ_HAL_STEP = 1
OBJ_CHERRY = 1
OBJ_HAL_USB = 1
OBJ_EPCAN = 1
OBJ_HAL_CAN = 1
File renamed without changes.
2 changes: 1 addition & 1 deletion src/hal/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ void USB_putc(int c)

if (xQueueSendToBack(priv_USB.tx_queue, &xbyte, (TickType_t) 100) != pdTRUE) {

log_TRACE("USB queue reset" EOL);
log_TRACE("USB queue overflow" EOL);

xQueueReset(priv_USB.tx_queue);
}
Expand Down

0 comments on commit cb86bb7

Please sign in to comment.