Hand assembling a controller

Hi, I’ve recorded the process of hand assembling one of my DRV8316 controller boards:

The KiCad project, and source code are up on GitHub:


Jason this looks like a very nice board:) I cant say that SimpleFOC compiles for the pico D4 I have. Did you need to do anything special to get the ma702 to function correctly? I dd try the the MA730 but it wasnt stable…for my setup that is

Could you tell me what the power consumption of the pico is like without wifi

And again congrats I like it

I had to do the mcpwm.h correction, but the only other change I did was in esp32_mcu.cpp, to add this last line:

void _configureTimerFrequency(long pwm_frequency, mcpwm_dev_t* mcpwm_num, mcpwm_unit_t mcpwm_unit, float dead_zone = NOT_SET){
mcpwm_config_t pwm_config;
pwm_config.counter_mode = MCPWM_UP_DOWN_COUNTER; // Up-down counter (triangle wave)
pwm_config.duty_mode = MCPWM_DUTY_MODE_0; // Active HIGH
pwm_config.frequency = pwm_frequency;

Because I was getting a division by zero. I think it’s to do with the version of esp-idf that platformio’s arduino library was compiled against.

What errors are you having?

No, just defining the device correctly:

// magnetic sensor instance - SPI
MagneticSensorSPIConfig_s MA702_SPI = {
  .spi_mode = SPI_MODE0,
  .clock_speed = 1000000,
  .bit_resolution = 14,
  .angle_register = 0x0000,
  .data_start_bit = 15, 
  .command_rw_bit = 0,
  .command_parity_bit = 0

Then initializing the SPI on the correct pins. My full code is here.

The MA702 has a much faster filter function than the 730.
To get -3dB on the 730, you’d need to limit your angle sampling rate to 23Hz - which probably won’t be good for simpleFOC.



I measure a total board consumption of 33mA while idle in the main loop. Maybe a bit of this is going to the motor… This is with the ESP32 clocked to 160Mhz

1 Like

You are spot on there and makes sense now. At lower speeds the ma730 was ok…any higher and it would seem like it was changing its natural magnetic direction. I dont get why they say its good to 60 thou rpm then…but you seem to get the math a bit more than me…the filter graph is now obvious

The esp pico is certainly not a low power device, though I can imagine that if you turn the clock speed down a little it would also save some mA. we did some of this for the esp32 wrover modules and I think we could have a crack at it…I basically have everything except the drv8316 here…which I would love to get now. Id love to match an idle state to that of one of the stm32f4s with the stm32f411 i get less than 10mA on idle…not a big deal for one motor but with multi motor robotics it adds up.

Thanks for answering very much appreciated Jason

One last question, how is the can bus going and are you using it between boards? This is the last mystery I was attempting today.

No problems.

ti.com currently have preproduction samples in stock :slight_smile:

I’m currently just using UART, but this is something I’ll have to work on now that I have multiple can capable controllers.

1 Like

Great video!

Great video +1 sub here.
Is there a CAN library for PICO? Update: - dumb question from me - just realised this is esp32 pico not raspberry pi pico!! (esp32 has TWAI library).

I got some new motors to go with the DRV8316 drivers.

They’re Sunnysky V2806 motors. 400kv, 7 pole pairs, and have 0.61 Ohms resistance. This means that I can run them at 4v without hitting the dirver’s max current.

(kind of make my drivers look huge!)

If I up the voltage a bit to 5v, I can get nearly 300rad/s:
But I wouldn’t run them at this voltage for heavy loads.


Hi, I was looking at making these boards myself for my robot dog project but DRV8316R motor driver is not available on stock.Is there a alternative driver I could use ?


Welcome to the forum. Hope you’ll find what you are looking for.

The closest one out there is DRV8332. Please check out the following thread:

Unfortunately the DRV8332 board is neither easy to make nor cheap, and again is not in stock. However, unlike DRV8316, this driver could be hand-soldered. Also, this one is double-sided.

Please ask more questions if not clear.