Project sanity check with MP6540, optical encoder, & SimpleFOC

I have a reasonable amount of (hobby level) Arduino & PCB design experience, but this is my first time working with motors at all, much less BLDC Motors, so I’m hoping someone can fill a few holes in my knowledge and help me piece this project together. Thanks in advance for the assistance! I’m sure my questions are in documentation somewhere that I just haven’t found yet.

EDIT: Unfortunately all new users have a limit on number of photos and links, so all photos have been uploaded here: https://imgur.com/a/AsI9FnK

I have a lighting fixture that I’m trying to replace the control board for. I’m trying to utilize the existing BLDC Motor. Unfortunately I don’t have a datasheet for it, but I do know it is NEMA-23 sized and powered by 36V. Here’s a photo of the motor and existing driver circuit. The MOSFETs are kind of hard to read, but they’re G420N06 (PDF Warning).

I would love to use a pre-built motor driver, but I haven’t been able to find a reasonably priced (under ~$20) that supports 36V, so I’m planning on building on into my PCB with the MCU (an ATSAMD51 if that matters). I plan to use the MP6540, which leads me to question 1: I have plenty of I/O and can run the MP6540H in PWM6 mode just fine, but what advantages does it give me? Also, is it useful to hook up the current sense pins to my MCU?

Next thing I’m wondering is about encoders. A photo of what is currently in place is below. The wheel on the right is press-fit around the output shaft, and the module on the left straddles the outer edge of the notched wheel. Looks like 2x optical sensors, would I set this up with the CPR the number of notches on the wheel? And would I use the receiver for sensor 1 as encA and sensor 2 as encB?

Link to the fixture is here for anyone interested in the rest of the hardware: https://www.alibaba.com/product-detail/Eastsun-LED-Kinetic-dmx-winch-control_60802357863.html

Hi, and welcome, @theautomator,

At first glance, all this seems very reasonable.

Nice! ATSAMD51 is supported. You could use the Feather M4 or Metro M4 boards to test.

How much power do you need? The DRV8316 is a nice driver supporting up to 40V and 3A (8A peaks).
For first tests, its not 36V but a solution based on a L298N board costs almost nothing and would probably move the motor?

Using 6-PWM you can control the “dead-time”, the amount of “off time” inserted between the PWM switch-off and switch-on when swapping the high and low side MOSFETs state.
Additionally (not yet supported in SimpleFOC though) you can put the motor in “coast” or “brake” mode to do active braking or recharge batteries from the braking energy.
I don’t see any of this as being relevant to your use case.

I would check the output levels and hook them up. They can be very useful to help detect problems, like for example stall conditions or badly initialized motors. Even if you don’t wind up using them it can’t hurt to create the capability. Connecting them once the PCB is made will be much harder :wink:

I can’t find anything on this encoder, but it is very typical to have 2 optical sensors for quadrature encoding.
I would power it and attach to oscilloscope to check the outputs. When interfacing to the MCU, the type of interface (open drain or push/pull) and voltage levels are important. You might need translation 5V to 3.3V.

Due to quadrature, I think the resolution is 4x the number of notches, but I’d experiment to find out.

Let us know how it goes!

Side note:
I wrote an example for controlling SimpleFOC from pureData / TouchOSC via OSC messages. It’s in the examples in GitHub.
Having a DMX interface to SimpleFOC would also be pretty cool!