I have designed the first revision of a BLDC driver board (based on STM32 and DRV8323 chips). Right out of the bath (after writing the firmware of course) I noticed that the coupling of PWM into the hall signals is very terrible!
The motors that I have designed this circuit for are rated at ~20Watts. Their hall sensor only works at 5V or higher. I use the XOR mode of the STM32 timer to capture and generate commutation event...the STM32 is 3.3V...but I assume it can tolerate 5V input but I do not know what is the hysteresis for detecting a low or high signal when the GPIO pins are configured in XOR mode:
At below 100% PWM, I get a lot of noise. The yellow trace is one of the hall sensors (the blue is commutation event). I only have 2 probes so I could not capture all 3 sensors and the commutation event (pulling an gpio high and low before and after updating timer output). As you can see, the noise over the hall sensor is quite bad:
I blame 2 things:
1.The layout: As I did not have prior experience, and because there are 2 motor connectors, I routed the hall sensors very close to the phase signals (greens are phases and yellow are halls).
2. Motor Cable: The motor cables are just 8 wires next to eachother (no twisting) for almost 50cm...so even if I did the best layout in the PCB the cable itself would cause the coupling issue.
I have tested the driver with 100% PWM (meaning no switching) and everything looks much better (the noise is very small and limited to when the half bridges switch at hall sensor update). So I really need to take care of this noise. I know that I can mitigate this effect in the software (e.g. by inserting timeout and other filtering methods...) but nothing can beat having a nice clean signal anyways.
So to make it short here is my questions:
1) What can I improve in the layout? separation of hall sensors and phase signals into different connectors?**
2) I will tear apart the motor cable and separate halls from phases and make them twisted pair...before I commit this, do you think it makes sense?
3) Should/Can I use a level-shifter and perhaps a Schmidt trigger to remove the noise and convert 5V to 3.3V before feeding it into the STM32 controller? If so, what chips do you suggest?
UPDATE:
Here is the RC filter for hall sensors, placed near MCU input.