1
\$\begingroup\$

I'm designing a PCB for my caving robot, which mainly consists of a STM32F723ZE and 16 motor controllers, with current measurement.

My question is: can I route the PWM signals going to the motor controllers just next to the analog voltage from the current measurement? Or will I get "significant" cross-talk?

In detail:

  • track space: 0.15 mm (I could probably increase a little bit if needed, but not much).

  • the analog track: the H-bridge has a "VpropI" pin with voltage proportional to current (I expect about 0.5 V). I add a RC filter (R = 100 kΩ, C = 10nF): the output of the RC filter goes to the ADC pin of the STM32 (about 6 cm long track). If needed, I can easily change for R = 10 kΩ, C = 100 nF.

  • the tracks are parallel for 5-6 cm.

  • the H-bridge supports up to 100 kHz PWM (I haven't chosen the PWM frequency yet, I was planning just to try different frequencies once I get the PCB and attach the motors to it).

  • let's say that 20 mV of noise are fine (50 mV would still be OK I think with software filtering).

So, do I have to dig into how to compute cross-talk/reduce it, or can I just go ahead like that?

Is there any simple rule of the thumb to know when I can just ignore cross-talk and when it needs further investigation?

EDIT: as suggested by I did a LTspice simulation:

The blue signal is the "middle point" between the 2 capacitors (that in real PCB is connected to ADC). The green signal is a 3.3V PWM signal, with 40 ns period, and 1 ns or 0.1 ns rise/fall times (NB: I plotted 0.5V+V_PWM/1000 (green signal) in order to get it on a similar scale as the noise).

With 1 ns rise/fall time:

With 1 ns rise/fall time

With 0.1 ns rise/fall time: enter image description here

@Neil_UK: is this the modelisation you where refering to?

If this is the correct way to model it, then with both capacitive and inductive effects, I get at most 5 mV of noise with 0.1 ns rise/fall time. So as long as the rise/fall time is >0.1 ns, I should be fine (crosstalk<5 mV). Correct?

EDIT 2 : new circuit based on the last comment Neil_UK (L1 in series with L1) : So with L1 in series with C1 (nb : I know divide the PWM only by 100 for plotting). With rise/fall time of 100 ns enter image description here

I have to admit I don't undestand why L1 should be in series with C1 and not with C2, but if so, then results are far worse : with 1ns rise, I get several volts of noise ; with 100 ns rise time, I'm still having about 45mV of noise

\$\endgroup\$
12
  • \$\begingroup\$ Depends. Can you place a ground route or copper pour in between them, or better yet, on opposite sides of a ground plane? \$\endgroup\$
    – winny
    Commented Jan 29, 2022 at 11:33
  • \$\begingroup\$ It all depends on what you need the analog signal for, what are you going to do with the current measurement?. If you have added a t=1 ms => 160 Hz low pass filter to the ADC input anyway, this is a very low speed measurement line. 100 kHz PWM crosstalk will be 55dB down just due to the first order filter. \$\endgroup\$
    – Neil_UK
    Commented Jan 29, 2022 at 11:51
  • \$\begingroup\$ @winny : if needed, yes I can do both things. However, the PCB is already very crowded, so if I do it, it will be at the cost of some other "optionnal" features that might help with debugging/prototyping (if I get some space left, I was planning on adding debug LEDs, debug pins, pins for unused GPIO in case I decide I want to use them later on, cut-traces+jumper in case I want to experiment with a motor independently of the STM32, ...). So if you say that without "protection" I will get to much noise, I will do so. But if it is nt needed, I'd rather not \$\endgroup\$
    – Sandro
    Commented Jan 29, 2022 at 12:21
  • \$\begingroup\$ @Neil_UK : the goal is to monitor motor current (ie torque), and for some motors to implement a (rough) current(ie torque) control. The issue is, the RC filter is placed next to the H-bridge, so the 6cm parrallel tracks are between the filter and the ADC :therefore, I'm not sure if I still benefit from the filtrer. Near the STM32, it is too crowded to add the filters, so it would be easier to run the analog signals on the components side (the rest is on bottom side) than to add the filters next to the STM32 \$\endgroup\$
    – Sandro
    Commented Jan 29, 2022 at 12:26
  • \$\begingroup\$ @Sandro If that filter is nailing your track to ground with 10n or 100n, it doesn't matter which end, then it's already pretty hard against capacitive coupled crosstalk. Estimate the capacitive coupling between aggressor and victim tracks, I'd guess it's in the 10-100 pF ballpark. That's a helluva ratio to 10n or 100n. As the PWM swings through a voltage, it injects a charge into the victim. A 5 V PWM swing would give a 5 mV step if the cap ratios are 1000:1. Edge rate of the PWM signal matters for inductive effects, you might be able to reduce those if needed, or it may not be required. \$\endgroup\$
    – Neil_UK
    Commented Jan 29, 2022 at 12:40

1 Answer 1

1
\$\begingroup\$

Motor current will have a strong ripple component at the PWM frequency.

If you drive the chip with PWM plus direction signal, and the motor receives either VCC or 0V, with polarity determined by direction... then VPROPI will only output a valid voltage when current actually goes through the sense resistor, which means when the PWM is in the ON state. So, instantaneous voltage on VPROPI will be proportional to the product of actual current and sense resistor when the PWM is ON, but it will be zero when it's off. Your filter will average that to a voltage that is proportional to the product of motor current, resistor, and duty cycle. This means at low duty cycle, you probably won't measure anything useful.

If you drive the chip with two independent PWMs, and the motor receives either +VCC or -VCC, which puts the neutral at 50% duty cycle, then current will always flow in the sense resistor and VPROPI will no longer be proportional to duty cycle.

Since the former is preferable, personally I would remove the filter completely and synchronize the ADC to the PWM peripheral (it's somewhere in STM32 manual, I don't remember where) so the ADC samples a small delay after the PWM turns on. To get this delay, add up the H-bridge switching time, current sense amp settling time, etc.

The time to sample sets a minimum duty cycle, but that shouldn't matter for motors, since a very low duty cycle means they won't turn at all anyway. It also sets a maximum switching frequency, which shouldn't matter either, because motors don't need to be driven at 100kHz, more like a few kHz.

If done right, this will result in less noise than the filter option, because when sampling is synchronized to PWM, it always samples at the same point in the current sawtooth waveform, which means it ignores the ripple. And since it samples after the switching is done, it will also ignore switching noise. The ideal solution is to sample all the motor channels while none of them are switching. Time to put that fast ADC to good use.

It also gets rid of the filter delay, so if you want to implement a feedback loop, less phase lag is always a plus.

The datasheet doesn't mention settling time or bandwidth for the current sense amp, which is suspicious. I would strongly recommend you measure it, because if it doesn't have enough bandwidth or settling is too slow, then synchronized sampling won't work. If the current sense amp limits slew rate, even the average with the filter may not work at all.

\$\endgroup\$
7
  • \$\begingroup\$ Thanks a lot. I will need quite some sensing to understand all of it, but it seems an interesting idea to do synchronized sampling. For the H bridge, I have to use a sigle PWM per motor, because I have 16 motors and don't have enough PWM outputs to give 2 per motor (excepted if doing soft PWM). \$\endgroup\$
    – Sandro
    Commented Jan 29, 2022 at 17:30
  • \$\begingroup\$ For the synchronisation, I will have to check if I can synchronize that many timers (I have the PWMs connected to 6 different timers, but I have only 3 ADCs). Otherwise, I could group the 8 motors that need torque control on 2 timers (synchronized with 2 ADC), and keep with my filter for the other 8, for which all I care is detecting stalling \$\endgroup\$
    – Sandro
    Commented Jan 29, 2022 at 17:31
  • \$\begingroup\$ Have you built a prototype? \$\endgroup\$
    – bobflux
    Commented Jan 29, 2022 at 23:10
  • \$\begingroup\$ Yes, why? For know, the prototype is based on 8 atmega328P, but it's quite time consuming to update the code on all 8, and I've got problems with I2C (to long wires catcing up noise, and the arduino I2C library hanging if the protocol is not perfectly respected). It is possible to remove one atmega328P in order to wire in a STM32 evaluation board (I have one with STM32F722ZE, which is nearly identical to the STM32F7223ZE I'm going to use). \$\endgroup\$
    – Sandro
    Commented Jan 31, 2022 at 14:18
  • \$\begingroup\$ Because if you use ADC synchronization with PWM, I think it would be best to test the code before you build the board... you never know, in case you misread something in the datasheet and the timer you wanted to use can't be used for that, or something. \$\endgroup\$
    – bobflux
    Commented Jan 31, 2022 at 15:49

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.