Skip to content

Body v2: Hoverboard Motors #2308

Merged
adeebshihadeh merged 22 commits intomasterfrom
body-hoverboard
Apr 8, 2026
Merged

Body v2: Hoverboard Motors #2308
adeebshihadeh merged 22 commits intomasterfrom
body-hoverboard

Conversation

@jhuang2006
Copy link
Copy Markdown
Contributor

@jhuang2006 jhuang2006 commented Dec 19, 2025

  • Replaced brushed DC motor system with BLDC Field Oriented Control using Hall sensors and 3-phase PWM
  • Added bit-banged SPI driver for LED strip with rainbow, breathing, and fill effects
  • Main loop now has three modes: ignition on (rainbow LEDs, motors enabled, CAN active), ignition off (green breathe, motors off)
  • Python PandaBody API: added rpml/rpmr properties with auto USB writes, removed old motor methods
  • Ignition exception for Body --> 0x201 addr on bus 2 and bus 0
  • Added extra CAN ID 0x222 for BLDC identification to distinguish v2 body fingerprint

@stefpi stefpi marked this pull request as draft March 24, 2026 18:13
@stefpi stefpi marked this pull request as ready for review March 25, 2026 21:45
@stefpi stefpi marked this pull request as draft March 27, 2026 22:36
@adeebshihadeh adeebshihadeh changed the title Body Hoverboard Motors Implementation Body v2: Hoverboard Motors Apr 7, 2026
@stefpi stefpi marked this pull request as ready for review April 8, 2026 02:48
@@ -0,0 +1,386 @@
/*
* File: BLDC_controller_data.c
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where'd this come from?

set_gpio_output(IGNITION_ON_PORT, IGNITION_ON_PIN, 0);
}

board board_body = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you make a separate PR to name everything body v2 now?

Comment thread board/body/__init__.py Outdated
self._rpmr: int = 0

@property
def rpml(self) -> int:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's expand these out to be more readable

Comment thread board/body/dotstar.h Outdated
Comment on lines +29 to +33
static inline void dotstar_delay(void) {
for (volatile uint32_t i = 0U; i < 40U; i++) {
__asm__ volatile("nop");
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

panda has its own helper for this

Comment thread board/body/boards/board_declarations.h Outdated
Comment on lines +46 to +47
#define MICI_POWER_ON_PORT GPIOB
#define MICI_POWER_ON_PIN 12
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk what this is, needs a better name

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OBD-C port power supply for comma device

MICI_POWER_ON_PORT --> OBDC_POWER_ON_PORT
IGNITION_ON_PORT --> OBDC_IGNITION_ON_PORT

Comment thread board/body/can.h Outdated
Comment on lines +48 to +54
CANPacket_t pkt;
pkt.bus = bus;
pkt.addr = BODY_CAN_ADDR_VAR_VALUES;
pkt.returned = 0;
pkt.rejected = 0;
pkt.extended = 0;
pkt.fd = 0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be able to default initialize like this to save some lines

Suggested change
CANPacket_t pkt;
pkt.bus = bus;
pkt.addr = BODY_CAN_ADDR_VAR_VALUES;
pkt.returned = 0;
pkt.rejected = 0;
pkt.extended = 0;
pkt.fd = 0;
CANPacket_t pkt = {};

Comment thread board/body/can.h Outdated
Comment on lines +67 to +70
pkt.returned = 0;
pkt.rejected = 0;
pkt.extended = 0;
pkt.fd = 0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Comment thread board/body/can.h Outdated
Comment on lines +81 to +82
rpml = (int)(((float)left_target_deci_rpm) * 0.1f);
rpmr = (int)(((float)right_target_deci_rpm) * 0.1f);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expand!

@stefpi stefpi requested a review from adeebshihadeh April 8, 2026 03:38
@adeebshihadeh adeebshihadeh merged commit 7c0c1d9 into master Apr 8, 2026
5 checks passed
@adeebshihadeh adeebshihadeh deleted the body-hoverboard branch April 8, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants