4
\$\begingroup\$

I'm currently considering a MCU-driven circuit that will do a variety of things, including drive some BLDC motors and do some analog sensing (of position sensors, temperatures and the like).

The designers of the chip I'd like to use (an STM32F4, FWIW) have deemed it appropriate to place the following two pins right next to each other:

  1. The only possible output pin for a timer that I would like to use as a PWM output to one of the motor drivers.
  2. ALL of the ADC inputs.

A few more tid-bits:

  • The PWM pin may run at very low/high duty cycles (<1% to >99%) at 20kHz
  • Analog signals of interest range from ~2Hz to ~200kHz, depending on sensor type.

Now, I'm going to go ahead and postulate that putting a PWM pin right next to an ADC input is bad practice, but I'm wondering:

  • has anyone tried this with success?
  • What are some potential mitigating solutions that would allow this to work?

Edit:

Here's what the MCU part looks like. I've highlighted the offending timer pin:

enter image description here

\$\endgroup\$
8
  • \$\begingroup\$ Can you publish your circuit? or it is TS? I can state that your adjacent PWM pins will induce some EMI/RFI to any nearby input pins. It is up to you how you design and layout. What steps have you taken to avoid any emissions and respective reception? \$\endgroup\$ Commented Oct 8, 2015 at 5:33
  • \$\begingroup\$ There isn't much of a circuit yet -- ST publishes a utility called STM32CubeMX which lets you lay out an MCU before committing to a design, which I'm currently using to explore the alternatives. In case you want detail, I'm looking at the F4 series in TQFP100/144 packages; the TIM8 CH1N output maps to two pins whose alternate functions are ADCs, and are right in the middle of the section of the chip where all the ADC pins are. I don't know what drove the designers to do this (I can only assume there was a good reason I can't see) and I'm debating moving to a larger chip to avoid the issue. \$\endgroup\$
    – PKL
    Commented Oct 8, 2015 at 6:46
  • \$\begingroup\$ One thing I considered is grounding the adjacent pins and running the PWM trace through a via as close to the pin as possible, moving the trace to the other side of a ground plane. That way, there's just a short section that's unshielded, and the adjacent pins aren't used. This solution isn't ideal: it would require I give up 2 of the 24 available ADC pins, which are in short supply for this application already. But I don't know how effective this solution would be, and the design is more time-sensitive than cost-sensitive for now. \$\endgroup\$
    – PKL
    Commented Oct 8, 2015 at 6:49
  • \$\begingroup\$ Please publish whatever you have and whatever you would be interested in using and asking questions about. \$\endgroup\$ Commented Oct 8, 2015 at 6:50
  • \$\begingroup\$ Invoking noise in ADC inputs is what you need in order to make oversampling work. If you're not performing that then avoid the noise. \$\endgroup\$ Commented Oct 8, 2015 at 7:34

3 Answers 3

4
\$\begingroup\$

You have indeed identified a legitimate crosstalk issue. Strictly speaking, the coupling magnitude of crosstalk is not a function of the frequency of the signal. It's a function of how fast the signal goes from high too low or low to high. Even a 1Hz PWM signal would couple over to a nearby line during the rising and falling edges. Obviously for your 20kHz signal, it happens 40,000 times a second, which may certainly be a problem. As an academic point of interest, a nice smooth sinewave signal will not induce as much crosstalk as a squarewave with the same frequency.

Besides the rise and fall time of the squarewave edges, crosstalk is also a function of the distance between the signal traces, the length the two traces travel together, and their distance above their reference plane.

Since the PWM pin and ADC pin are physically next to each other, their traces will be in close proximity for some trace length and there's nothing you can do about that. Obviously, any method to get the two traces away from each other as soon as possible will help. You can also reduce the coupling effect by making sure the reference plane is very close. On a PCB, that means using a 4 layer board (or more) so a ground plane can be placed no more than a pre-preg thickness away (usually only a few mils). On a 2 layer board, the ground plane will be the opposite side of the board, which is typically 63mils away and very bad for crosstalk.

There is a very good free online calculator called the Saturn PCB Design Toolkit that will allow you to approximate the crosstalk magnitude. You can get an idea of how bad the crosstalk will get based on your layout. You can't know the transition time without knowing the drive strength of the output driver and the exact impedance of the trace connected to the PWM pin, but you can use something like 10ns or so as a conservative approximation.

If very high accuracy is needed on your ADC readings and your calculated crosstalk magnitude is too high, perhaps the best thing to do is choose another MCU. There are tons more available by that same manufacturer, so it should be trivial to find one with a PWM and ADC pin apart from each other. If there is some reason you must use that specific MCU, then you will have to determine how much crosstalk you can live with and design to that.

\$\endgroup\$
1
  • \$\begingroup\$ Accepted for most thorough treatment on the subject. Thanks for taking the time, @Dan Laks! \$\endgroup\$
    – PKL
    Commented Oct 9, 2015 at 3:06
3
\$\begingroup\$

I'm surprised that no one here has mentioned anything about the impedance level on the ADC lines ! Obviously it is easier to disturb a high-impedance line to an input than it is to disturb a low impedance line. If your sensors have high impedance outputs I would recommend to buffer their output voltage locally (near the sensor). If your sensors have low output impedance outputs then buffering might not be needed.

You could also consider buffering the sensor's signals anyway at a short distance from the MCU and make sure the signals remain "clean". Then route them to the ADC inputs.

\$\endgroup\$
4
  • \$\begingroup\$ Depending on how good the layout tool is (assuming a layout), a guard ring around the ADC input could also be beneficial. \$\endgroup\$ Commented Oct 8, 2015 at 13:41
  • \$\begingroup\$ @PeterSmith, could you provide an example of this? The only way I can currently think of to implement a guard ring is to ground the adjacent pins and then pour GND over them. Combining this with a via very close to the PWM pin to take the signal to the far side of the board (and the other side of a ground plane) completes the design. But I'd like to avoid this if possible, since they're both ADC pins, and are in short supply on my design as it is. \$\endgroup\$
    – PKL
    Commented Oct 8, 2015 at 15:34
  • \$\begingroup\$ I will put something together in the morning \$\endgroup\$ Commented Oct 8, 2015 at 16:33
  • \$\begingroup\$ Minimise close parallel track length by taking either the PWM or ADC back under the STM and immediately via through to the other side of the board. I would take the PWM as it is noisiest and couldn't care about noise coming from the chip itself. \$\endgroup\$
    – ChrisR
    Commented Jan 18, 2016 at 13:08
0
\$\begingroup\$

You should set the GPIO speed to the lowest value to have the longer rise and fall time.This should help with crosstalk issue.This crosstalk is inductive, if your PWM line is not a low impedance line you should not have any issues.

\$\endgroup\$
2
  • \$\begingroup\$ While this is an interesting approach generally, in my specific case the edge timing is important because of potential shoot-through in the motor driver that this PWM signal is going to. I'd like to avoid anything that creates potential timing issues of that sort (leaving a note here for those who come after me). \$\endgroup\$
    – PKL
    Commented Oct 8, 2015 at 15:32
  • \$\begingroup\$ Ok, then you should keep the rise and fall time longer.Due to the low frequency(20 KHz) you should have a really small of overshoot or undershoot. \$\endgroup\$ Commented Oct 8, 2015 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.